From ccf179d9e648cd02814e0ebd44cf3fff39cc0a7e Mon Sep 17 00:00:00 2001 From: Chris Hansen Date: Fri, 13 Aug 2021 22:34:40 +1200 Subject: [PATCH] docker-compose --- .dockerignore | 13 +++++++++++++ README.md | 23 +++++++++-------------- build.sbt | 2 +- docker/Dockerfile | 8 ++++---- Dockerfile => docker/Dockerfile.alt | 2 +- project/assembly.sbt | 2 +- project/build.properties | 2 +- seasadj.yml | 10 ++++++++++ 8 files changed, 40 insertions(+), 22 deletions(-) create mode 100644 .dockerignore rename Dockerfile => docker/Dockerfile.alt (98%) create mode 100644 seasadj.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..28842c8 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,13 @@ +.bloop +.bsp +.idea +.metals +.vscode +docs +examples +img +project +src +target +!target/scala-2.13/seasadj.jar +**/.access^ \ No newline at end of file diff --git a/README.md b/README.md index c58c470..fae66d1 100755 --- a/README.md +++ b/README.md @@ -31,25 +31,18 @@ And, of course, X13-ARIMA-SEATS itself must be present, and in the search path. On a Linux platform, it is relatively easy to build X13-ARIMA-SEATS from source, and a utility script, [buildx13.sh](buildx13.sh), is provided which will do this, storing the resulting binary in `${HOME}/.local/bin`. -Alternatively, the service is easily containerised, and a simple example Dockerfile is included. To build the container, ensure `seasadj.jar` is copied to the `docker` folder, and run: +Alternatively, the service is easily containerised, and a simple example Dockerfile is included. To build the container run: ```bash -docker build -t seasadj docker +docker-compose -f seasadj.yml build ``` -To run the service via Docker, simply run: +N.b. this still assumes `sbt assembly` has been run, and `target/scala-2.13/seasadj.jar` exists. There is an alternate Dockerfile, `docker/Dockerfile.alt` which will copy the source and compile as part of the build, but it will take a little while to build. Either way, to run the service: ```bash -docker run -td --rm --name seasadj -p 9001:9001 seasadj +docker-compose -f seasadj.yml up -d ``` -As a further alternative still, a `Dockerfile` is also included in the root directory which can be also used to build a container which can be run in the same way as above. This container differs in that the required jar file is built as part of the Docker build. The build will take _much_ longer, but it is also easier for those without experience with sbt. To build: - -```bash -docker build -t seasadj . -``` - - ## Overview X13-ARIMA-SEATS To adjust a single series, we generally prepare at minimum a so-called specification file with extension `spc`. For example, the following file, which is generally distributed with the X13-ARIMA-SEATS binary, is a complete example: @@ -352,7 +345,7 @@ scala> println(airpassengers) The `airpassengers` object is of type `TimeSeries`, and has methods useful for working with seasonal adjustment specifications. So consider the following complete specification: -``` +```plaintext series{ title="International Airline Passengers Data from Box and Jenkins" start=1949.01 @@ -467,6 +460,8 @@ and to look at the f3.q measure (which is a summary of overally adjustment quali ```scala scala> res.foreach(r => println(r.getDiagnostic("f3.q"))) +``` +```plaintext 0.22 ``` @@ -602,7 +597,7 @@ Internally, all adjustments are run with the `-g` flag, which means most tables X13-ARIMA-SEATS specifications often refer to files on disk. For example, assume the airline data was saved in a file called `airline.dat` as follows: -``` +```plaintext 1949 1 112 1949 2 118 1949 3 132 @@ -632,7 +627,7 @@ val ap2 = ap.resolveFiles("/foo/bar") Since specifications are immutable, this would leave `ap` unchanged, but return a new specification, `ap2`, with content: -``` +```plaintext series { title="International Airline Passengers Data from Box and Jenkins" start=1949.01 diff --git a/build.sbt b/build.sbt index 86b3d2c..223e3ba 100755 --- a/build.sbt +++ b/build.sbt @@ -1,6 +1,6 @@ name := """seasadj""" organization := "org.cmhh" -scalaVersion := "2.13.4" +scalaVersion := "2.13.6" version := "0.2.0" scalacOptions += "-deprecation" diff --git a/docker/Dockerfile b/docker/Dockerfile index 39985d4..2633326 100755 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,6 +1,6 @@ -FROM oracle/graalvm-ce:latest +FROM ghcr.io/graalvm/graalvm-ce:java11-21.2.0 -RUN yum install -y curl && \ +RUN microdnf install -y curl && \ mkdir -p /tmp/x13 && \ cd /tmp/x13 && \ curl -s https://www.census.gov/ts/x13as/unix/x13ashtmlall_V1.1_B39.tar.gz | tar -xvf - && \ @@ -8,8 +8,8 @@ RUN yum install -y curl && \ cd .. && \ rm -fR /tmp/x13 -ADD seasadj.jar seasadj.jar +COPY target/scala-2.13/seasadj.jar seasadj.jar EXPOSE 9001 -CMD java -cp seasadj.jar org.cmhh.seasadj.Service +ENTRYPOINT ["java", "-cp", "/seasadj.jar", "org.cmhh.seasadj.Service"] diff --git a/Dockerfile b/docker/Dockerfile.alt similarity index 98% rename from Dockerfile rename to docker/Dockerfile.alt index 17b9d68..e6a410d 100755 --- a/Dockerfile +++ b/docker/Dockerfile.alt @@ -2,7 +2,7 @@ FROM ubuntu:20.04 ENV DEBIAN_FRONTEND noninteractive ENV SHELL /bin/bash -ENV SBT_VERSION 1.4.5 +ENV SBT_VERSION 1.5.5 COPY src /seasadj/src COPY project/assembly.sbt /seasadj/project/assembly.sbt diff --git a/project/assembly.sbt b/project/assembly.sbt index c9c0554..91877e2 100755 --- a/project/assembly.sbt +++ b/project/assembly.sbt @@ -1 +1 @@ -addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.10") \ No newline at end of file +addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "1.0.0") \ No newline at end of file diff --git a/project/build.properties b/project/build.properties index c06db1b..10fd9ee 100755 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.4.5 +sbt.version=1.5.5 diff --git a/seasadj.yml b/seasadj.yml new file mode 100644 index 0000000..d388e9b --- /dev/null +++ b/seasadj.yml @@ -0,0 +1,10 @@ +version: "3.8" +services: + seasadj: + image: seasadj + build: + context: ./ + dockerfile: docker/Dockerfile + ports: + - 9001:9001 + tty: true \ No newline at end of file