Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Start on Docker Integration #347

Open
wants to merge 16 commits into
base: staging
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .docker/db/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM postgres:9.6

COPY init.sql /docker-entrypoint-initdb.d/
2 changes: 2 additions & 0 deletions .docker/db/init.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
create database spongeauth;
create role spongeauth with login password 'spongeauth';
21 changes: 21 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -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
48 changes: 48 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# This Dockerfile is designed to be used for production
FROM openjdk:8-jdk-alpine

phase marked this conversation as resolved.
Show resolved Hide resolved
LABEL maintainer="Jadon Fowler <[email protected]>"

# 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"]
3 changes: 3 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion conf/application.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
32 changes: 32 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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'