From 18fc83dfa85f0679ea290dafa97d6483805e0bce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emmanuel=20BENO=C3=8ET?= Date: Fri, 3 Jan 2025 15:04:32 +0100 Subject: [PATCH] chore: build the backend container --- .gitignore | 1 + docker/Dockerfile.backend | 24 +++++++++++++++++++++ docker/backend-entrypoint.sh | 41 ++++++++++++++++++++++++++++++++++++ docker/compose.yml | 21 ++++++++++++++++++ docker/env.example | 5 +++++ pom.xml | 6 +++--- 6 files changed, 95 insertions(+), 3 deletions(-) create mode 100644 .gitignore create mode 100644 docker/Dockerfile.backend create mode 100755 docker/backend-entrypoint.sh create mode 100644 docker/compose.yml create mode 100644 docker/env.example diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..da41f82 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +docker/.env diff --git a/docker/Dockerfile.backend b/docker/Dockerfile.backend new file mode 100644 index 0000000..af1a301 --- /dev/null +++ b/docker/Dockerfile.backend @@ -0,0 +1,24 @@ +FROM maven:3-jdk-7 AS build +ENV BUILD_UID=1000 +ENV BUILD=/src +ENV MAVEN_HOME=/var/maven +ENV MAVEN_CONFIG=/var/maven/.m2 +RUN mkdir -p $MAVEN_HOME && chown $BUILD_UID $MAVEN_HOME +RUN mkdir -p $BUILD +ADD .. $BUILD +RUN chown -R $BUILD_UID $BUILD +USER $BUILD_UID +WORKDIR $BUILD +RUN --mount=type=cache,target=$MAVEN_HOME/.m2,uid=$BUILD_UID mvn -e -Duser.home=$MAVEN_HOME package + +FROM openjdk:7u211-jre-alpine +RUN <data-source.xml < + + + + + + + + +EOF +fi + +cmd="$1" +shift +if [ "$cmd" == server ]; then + exec /usr/bin/java \ + -Dlog4j.configuration=log4j.properties \ + -jar server.jar +elif [ "$cmd" == shell ]; then + exec /bin/sh +elif [ "$cmd" == tool ]; then + exec /usr/bin/java \ + -jar legacyworlds-server-main-*.jar \ + --run-tool "$*" +else + echo "Invalid command '$cmd'" >&2 + exit 1 +fi diff --git a/docker/compose.yml b/docker/compose.yml new file mode 100644 index 0000000..5949843 --- /dev/null +++ b/docker/compose.yml @@ -0,0 +1,21 @@ +name: lwb6 + +services: + + backend: + build: + context: .. + dockerfile: docker/Dockerfile.backend + restart: always + environment: + LW_CONFIGURE: 1 + LW_DB_HOST: db + LW_DB_NAME: lwb6 + LW_DB_USER: lwb6 + LW_DB_PASSWORD_FILE: /run/secrets/lw_db_password + secrets: + - lw_db_password + +secrets: + lw_db_password: + environment: LW_DB_PASSWORD diff --git a/docker/env.example b/docker/env.example new file mode 100644 index 0000000..76c4f76 --- /dev/null +++ b/docker/env.example @@ -0,0 +1,5 @@ +# Password for the database superuser +DB_PASSWORD=hVVCS5cQG17aZBk32m0wDHAluvzgyj4n + +# Legacyworlds database password +LW_DB_PASSWORD=aXIQkMFFzjb4Ad7nvJgO5JhNtWxo62Du diff --git a/pom.xml b/pom.xml index 8f8a680..abbe5b3 100644 --- a/pom.xml +++ b/pom.xml @@ -15,8 +15,8 @@ maven-compiler-plugin 2.2 - 1.6 - 1.6 + 1.7 + 1.7 @@ -69,4 +69,4 @@ legacyworlds-utils - \ No newline at end of file +