diff --git a/.docker/db/Dockerfile b/.docker/db/Dockerfile new file mode 100644 index 000000000..a93cd9f9d --- /dev/null +++ b/.docker/db/Dockerfile @@ -0,0 +1,3 @@ +FROM postgres:9.6 + +COPY init.sql /docker-entrypoint-initdb.d/ diff --git a/.docker/db/init.sql b/.docker/db/init.sql new file mode 100644 index 000000000..d43b8ccd5 --- /dev/null +++ b/.docker/db/init.sql @@ -0,0 +1,2 @@ +create database spongeauth; +create role spongeauth with login password 'spongeauth'; diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..ffd0a2a7b --- /dev/null +++ b/.dockerignore @@ -0,0 +1,21 @@ +/* + +!app/ + +!conf/ +# This is created in the Dockerfile +conf/application.conf + +!OreTestPlugin/ + +!project/ +project/target/ +project/project/ +# Hydra Scala Compiler +project/hydra.sbt + +!public/ + +!scripts/ + +!build.sbt diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..449e47def --- /dev/null +++ b/Dockerfile @@ -0,0 +1,48 @@ +# This Dockerfile is designed to be used for production +FROM openjdk:8-jdk-alpine + +LABEL maintainer="Jadon Fowler " + +# 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 . ./ + +# 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.template conf/application.conf +RUN apk update +RUN apk add --virtual --no-cache curl ca-certificates bash + +# Downloads SBT with the version given above and extracts it +RUN curl -sL "https://piccolo.link/sbt-$SBT_VERSION.tgz" -o "sbt-$SBT_VERSION.tgz" +RUN tar -xvzf "sbt-$SBT_VERSION.tgz" -C /usr/local + +# Compiles Ore and makes a production distribution (but not in an archive, unlike 'dist') +RUN sbt stage +RUN mkdir -p /home/ore/prod + +# Copy the 'stage' task result _content_ into the production directory +RUN 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 +RUN rm -rf /home/ore/build + +# SBT is no longer needed too +RUN rm -rf $SBT_HOME +RUN apk del curl + +WORKDIR /home/ore/prod/bin + +# Ore runs on port 9000 +EXPOSE 9000 + +CMD ["./ore"] diff --git a/build.sbt b/build.sbt index 59442e730..faf96fdde 100755 --- a/build.sbt +++ b/build.sbt @@ -54,6 +54,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, guice) lazy val flexmarkVersion = "0.34.40" diff --git a/conf/application.conf.template b/conf/application.conf.template index 1896c1077..1399fc4d8 100755 --- a/conf/application.conf.template +++ b/conf/application.conf.template @@ -11,7 +11,7 @@ application { uploadsDir = ${?UPLOADS_DIR} # Add a dot at the start of the url to trust all subdomains - trustedUrlHosts = [ ".spongepowered.org" ] + trustedUrlHosts = [ ".spongepowered.org", "spongeauth" ] fakeUser { enabled = false diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 000000000..5635db622 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,32 @@ +version: '3' + +services: + app: + image: ore:1.6.16 + build: . + depends_on: + - 'db' + - 'spongeauth' + - 'mail' + ports: + - '9000:9000' + stdin_open: true + db: + build: '.docker/db/' + restart: always + ports: + - '5432:5432' + environment: + POSTGRES_USER: root + POSTGRES_PASSWORD: '' + POSTGRES_DB: ore + mail: + image: mailhog/mailhog:latest + ports: + - "8025:8025" + spongeauth: + image: lukegb/spongeauth:latest + depends_on: + - 'db' + ports: + - '8000:8000'