Skip to content

Commit

Permalink
docker-compose
Browse files Browse the repository at this point in the history
  • Loading branch information
cmhh committed Aug 13, 2021
1 parent 18c1465 commit ccf179d
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 22 deletions.
13 changes: 13 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.bloop
.bsp
.idea
.metals
.vscode
docs
examples
img
project
src
target
!target/scala-2.13/seasadj.jar
**/.access^
23 changes: 9 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
```

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name := """seasadj"""
organization := "org.cmhh"
scalaVersion := "2.13.4"
scalaVersion := "2.13.6"
version := "0.2.0"
scalacOptions += "-deprecation"

Expand Down
8 changes: 4 additions & 4 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
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 - && \
mv x13ashtml /usr/bin/ && \
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"]
2 changes: 1 addition & 1 deletion Dockerfile → docker/Dockerfile.alt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion project/assembly.sbt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.10")
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "1.0.0")
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.4.5
sbt.version=1.5.5
10 changes: 10 additions & 0 deletions seasadj.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: "3.8"
services:
seasadj:
image: seasadj
build:
context: ./
dockerfile: docker/Dockerfile
ports:
- 9001:9001
tty: true

0 comments on commit ccf179d

Please sign in to comment.