diff --git a/.dockerignore b/.dockerignore index 45117aa99..988ddbf38 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,3 +1,19 @@ +/* + +!app/ + +!conf/ # This is created in the Dockerfile conf/application.conf +!OreTestPlugin/ + +!project/ +project/target/ +project/project/ + +!public/ + +!scripts/ + +!build.sbt diff --git a/Dockerfile b/Dockerfile index 63f51af79..0d44ab513 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,23 +1,42 @@ +# This Dockerfile is designed to be used for production FROM openjdk:8-jdk-alpine -MAINTAINER Jadon Fowler +LABEL maintainer="Jadon Fowler " -# Install Activator -RUN apk update -RUN apk add curl unzip bash postgresql -RUN curl -O http://downloads.typesafe.com/typesafe-activator/1.3.6/typesafe-activator-1.3.6.zip -RUN unzip typesafe-activator-1.3.6.zip -d / && rm typesafe-activator-1.3.6.zip && chmod a+x /activator-dist-1.3.6/activator -ENV PATH $PATH:/activator-dist-1.3.6 +# Temporary build folder for the 'stage' task +WORKDIR /home/ore/build +# The .dockerignore file on the project root avoids build cache and personal configuration to be included in the image +ADD . ./ -# Copy Ore -RUN mkdir -p /home/play/ore/ -WORKDIR /home/play/ore/ -ADD . /home/play/ore/ +# TODO use Docker secrets for the app key and passwords (and any other sensible information) +ENV SBT_VERSION=1.2.1 \ + SBT_HOME=/usr/local/sbt \ + JDBC_DATABASE_URL=jdbc:postgresql://db/ore \ + SPONGE_AUTH_URL=http://spongeauth:8000 \ + APPLICATION_SECRET="some_secret" + +ENV PATH=${PATH}:${SBT_HOME}/bin + +# TODO a shell script to extract the SBT version from project/build.properties and set SBT_VERSION to the output value +RUN cp conf/application.conf conf/application.conf && \ + apk add --virtual --no-cache curl ca-certificates bash && \ +# Downloads SBT with the version given above and extracts it + curl -sL "https://piccolo.link/sbt-$SBT_VERSION.tgz" -o "sbt-$SBT_VERSION.tgz" && \ + tar -xvzf "sbt-$SBT_VERSION.tgz" -C /usr/local && \ +# Compiles Ore and makes a production distribution (but not in an archive, unlike 'dist') + sbt stage && \ + mkdir -p /home/ore/prod && \ +# Copy the 'stage' task result _content_ into the production directory + cp -r /home/ore/build/target/universal/stage/* /home/ore/prod && \ +# Cleans the temporary build directory, as we don't need it in the final image + rm -rf /home/ore/build && \ +# SBT is no longer needed too + rm -rf $SBT_HOME && \ + apk del curl + +WORKDIR /home/ore/prod/bin # Ore runs on port 9000 -# 8888 is the Activator UI EXPOSE 9000 -RUN cp conf/application.conf.template conf/application.conf - -CMD ["/home/play/ore/docker.sh"] +CMD ["./ore"] diff --git a/build.sbt b/build.sbt index d6d2e9d8a..60c4b9f79 100755 --- a/build.sbt +++ b/build.sbt @@ -11,6 +11,9 @@ resolvers ++= Seq( "Akka Snapshot Repository" at "http://repo.akka.io/snapshots/" ) +sources in (Compile, doc) := Seq.empty +publishArtifact in (Compile, packageDoc) := false + libraryDependencies ++= Seq( ehcache , ws , specs2 % Test , guice ) libraryDependencies ++= Seq( "org.spongepowered" % "play-discourse" % "3.0", diff --git a/docker-compose.yml b/docker-compose.yml index c835e6bd2..eb58ffece 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,24 +1,27 @@ -version: "2" +version: '3' services: app: + image: ore:1.6.8 build: . depends_on: - 'db' - 'spongeauth' ports: - - "9000:9000" + - '9000:9000' stdin_open: true db: build: '.docker/db/' restart: always + ports: + - '5432:5432' environment: POSTGRES_USER: root - POSTGRES_PASSWORD: "" + POSTGRES_PASSWORD: '' POSTGRES_DB: ore spongeauth: image: spongepowered/spongeauth depends_on: - 'db' ports: - - "8000:8000" + - '8000:8000' diff --git a/docker.sh b/docker.sh index 3adfb62fa..fe01fb4dd 100755 --- a/docker.sh +++ b/docker.sh @@ -1,4 +1,5 @@ #!/bin/sh +# This is probably not needed anymore # We want to connect to db/ore -env JDBC_DATABASE_URL="jdbc:postgresql://db/ore" SPONGE_AUTH_URL="http://spongeauth:8000" activator run +JDBC_DATABASE_URL="jdbc:postgresql://db/ore" SPONGE_AUTH_URL="http://spongeauth:8000" java -jar