feat: add game initialization to backend container
This commit is contained in:
parent
10e70a4cbc
commit
1ae7dbe936
3 changed files with 31 additions and 4 deletions
|
@ -12,12 +12,14 @@ RUN --mount=type=cache,target=$MAVEN_HOME/.m2,uid=$BUILD_UID \
|
|||
FROM openjdk:7u211-jre-alpine AS backend
|
||||
RUN <<EOF
|
||||
set -e
|
||||
mkdir -p /app
|
||||
chown 1000 /app
|
||||
mkdir -p /app/state
|
||||
chown -R 1000 /app/state
|
||||
EOF
|
||||
COPY --from=build /src/legacyworlds-server/legacyworlds-server-main/target/*.jar /app/server.jar
|
||||
COPY --from=build /src/legacyworlds-server/legacyworlds-server-main/target/lib /app/lib
|
||||
COPY --from=build /src/legacyworlds-server/legacyworlds-server-main/data /app/data
|
||||
ADD docker/backend-entrypoint.sh /app/entrypoint.sh
|
||||
VOLUME /app/state
|
||||
ENTRYPOINT ["/app/entrypoint.sh"]
|
||||
CMD ["server"]
|
||||
|
||||
|
|
|
@ -1,5 +1,23 @@
|
|||
#!/bin/sh
|
||||
|
||||
|
||||
# Function used to run initialization commands.
|
||||
run_init_command() {
|
||||
local stage="$1"
|
||||
shift
|
||||
if ! [ -f state/init-$stage ]; then
|
||||
echo "Running initialization stage $stage"
|
||||
echo " --> $@"
|
||||
if /app/entrypoint.sh tool "$*"
|
||||
then
|
||||
touch state/init-$stage
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
cd /app
|
||||
|
||||
if ! [ -z "$LW_CONFIGURE" ]; then
|
||||
|
@ -26,6 +44,9 @@ fi
|
|||
cmd="$1"
|
||||
shift
|
||||
if [ "$cmd" == server ]; then
|
||||
run_init_command import-text ImportText data/i18n-text.xml
|
||||
run_init_command import-techs ImportTechs data/techs.xml
|
||||
run_init_command import-buildables ImportBuildables data/buildables.xml
|
||||
exec /usr/bin/java \
|
||||
-Dlog4j.configuration=log4j.properties \
|
||||
-jar server.jar
|
||||
|
@ -33,8 +54,9 @@ elif [ "$cmd" == shell ]; then
|
|||
exec /bin/sh
|
||||
elif [ "$cmd" == tool ]; then
|
||||
exec /usr/bin/java \
|
||||
-jar legacyworlds-server-main-*.jar \
|
||||
--run-tool "$*"
|
||||
-Dlog4j.configuration=log4j.properties \
|
||||
-jar server.jar \
|
||||
--run-tool "$@"
|
||||
else
|
||||
echo "Invalid command '$cmd'" >&2
|
||||
exit 1
|
||||
|
|
|
@ -25,6 +25,8 @@ services:
|
|||
dockerfile: docker/Dockerfile.application
|
||||
target: backend
|
||||
restart: always
|
||||
volumes:
|
||||
- init-state:/app/state
|
||||
environment:
|
||||
LW_CONFIGURE: 1
|
||||
LW_DB_HOST: db
|
||||
|
@ -54,6 +56,7 @@ services:
|
|||
|
||||
volumes:
|
||||
database:
|
||||
init-state:
|
||||
|
||||
secrets:
|
||||
db_password:
|
||||
|
|
Loading…
Add table
Reference in a new issue