From f0c5d2c42ba2b2db30e6fd3906a0e668c0b233a6 Mon Sep 17 00:00:00 2001 From: Guntis Smaukstelis Date: Sat, 1 Mar 2025 18:16:56 +0200 Subject: [PATCH] Fix Dockerfile.local except volumes --- Dockerfile | 2 +- Dockerfile.local | 8 +++----- README.md | 4 ++-- build.sbt | 13 ++++++++++++- src/main/scala/parse/grib/GribParser.scala | 4 +++- 5 files changed, 21 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index bb3835b..ff9d52d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ FROM amazoncorretto:17-alpine WORKDIR /app COPY ./web/dist/ web/dist/ -COPY ./target/scala-2.13/WeatherTool-assembly-0.1.1-SNAPSHOT.jar app.jar +COPY ./target/scala-2.13/app.jar app.jar VOLUME /app/data diff --git a/Dockerfile.local b/Dockerfile.local index 8018270..2e837c4 100644 --- a/Dockerfile.local +++ b/Dockerfile.local @@ -7,11 +7,9 @@ RUN sbt clean assembly FROM amazoncorretto:17-alpine -WORKDIR /app +COPY --from=build /app/web/dist/ /web/dist/ +COPY --from=build /app/target/scala-2.13/app.jar /app.jar -COPY --from=build /app/web/dist/ web/dist/ -COPY --from=build /app/target/scala-2.13/WeatherTool-assembly-0.1.1-SNAPSHOT.jar app.jar - -VOLUME /app/data +VOLUME /data CMD ["java", "-jar", "app.jar"] diff --git a/README.md b/README.md index 509ebc5..0970bd5 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,8 @@ Rename `.env-sample` to `.env` and fill in credentials ## Run ``` -docker-compose up node --build -docker-compose up scala --build +docker-compose up --build node +docker-compose up --build scala ``` ## Web diff --git a/build.sbt b/build.sbt index f9d9870..7437e68 100644 --- a/build.sbt +++ b/build.sbt @@ -5,7 +5,18 @@ ThisBuild / scalaVersion := "2.13.10" lazy val root = (project in file(".")) .settings( name := "WeatherTool", - Compile / mainClass := Some("Main") + Compile / mainClass := Some("Main"), + + // Assembly settings for consistent JAR name + assembly / assemblyJarName := "app.jar", + + // Merge strategy for assembly to handle conflicts + assembly / assemblyMergeStrategy := { + case PathList("META-INF", xs @ _*) => MergeStrategy.discard + case "module-info.class" => MergeStrategy.discard + case x if x.endsWith(".conf") => MergeStrategy.concat + case x => MergeStrategy.first + } ) val doobieVersion = "1.0.0-RC1" diff --git a/src/main/scala/parse/grib/GribParser.scala b/src/main/scala/parse/grib/GribParser.scala index cf4bc3a..fb2d70b 100644 --- a/src/main/scala/parse/grib/GribParser.scala +++ b/src/main/scala/parse/grib/GribParser.scala @@ -83,8 +83,10 @@ object GribParser { hour = bytes(16) minute = bytes(17) second = bytes(18) + currentMonth = ZonedDateTime.now(ZoneOffset.UTC).getMonthValue() + validMonth = if (month < 1 || month > 12) currentMonth else month referenceTime = ZonedDateTime.of( - year, month, day, + year, validMonth, day, hour, minute, second, 0, // last 0 is nanos ZoneOffset.UTC // This is what 'Z' represents - UTC/Zero offset )