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
|
FROM openjdk:7u211-jre-alpine AS backend
|
||||||
RUN <<EOF
|
RUN <<EOF
|
||||||
set -e
|
set -e
|
||||||
mkdir -p /app
|
mkdir -p /app/state
|
||||||
chown 1000 /app
|
chown -R 1000 /app/state
|
||||||
EOF
|
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/*.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/target/lib /app/lib
|
||||||
|
COPY --from=build /src/legacyworlds-server/legacyworlds-server-main/data /app/data
|
||||||
ADD docker/backend-entrypoint.sh /app/entrypoint.sh
|
ADD docker/backend-entrypoint.sh /app/entrypoint.sh
|
||||||
|
VOLUME /app/state
|
||||||
ENTRYPOINT ["/app/entrypoint.sh"]
|
ENTRYPOINT ["/app/entrypoint.sh"]
|
||||||
CMD ["server"]
|
CMD ["server"]
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,23 @@
|
||||||
#!/bin/sh
|
#!/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
|
cd /app
|
||||||
|
|
||||||
if ! [ -z "$LW_CONFIGURE" ]; then
|
if ! [ -z "$LW_CONFIGURE" ]; then
|
||||||
|
@ -26,6 +44,9 @@ fi
|
||||||
cmd="$1"
|
cmd="$1"
|
||||||
shift
|
shift
|
||||||
if [ "$cmd" == server ]; then
|
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 \
|
exec /usr/bin/java \
|
||||||
-Dlog4j.configuration=log4j.properties \
|
-Dlog4j.configuration=log4j.properties \
|
||||||
-jar server.jar
|
-jar server.jar
|
||||||
|
@ -33,8 +54,9 @@ elif [ "$cmd" == shell ]; then
|
||||||
exec /bin/sh
|
exec /bin/sh
|
||||||
elif [ "$cmd" == tool ]; then
|
elif [ "$cmd" == tool ]; then
|
||||||
exec /usr/bin/java \
|
exec /usr/bin/java \
|
||||||
-jar legacyworlds-server-main-*.jar \
|
-Dlog4j.configuration=log4j.properties \
|
||||||
--run-tool "$*"
|
-jar server.jar \
|
||||||
|
--run-tool "$@"
|
||||||
else
|
else
|
||||||
echo "Invalid command '$cmd'" >&2
|
echo "Invalid command '$cmd'" >&2
|
||||||
exit 1
|
exit 1
|
||||||
|
|
|
@ -25,6 +25,8 @@ services:
|
||||||
dockerfile: docker/Dockerfile.application
|
dockerfile: docker/Dockerfile.application
|
||||||
target: backend
|
target: backend
|
||||||
restart: always
|
restart: always
|
||||||
|
volumes:
|
||||||
|
- init-state:/app/state
|
||||||
environment:
|
environment:
|
||||||
LW_CONFIGURE: 1
|
LW_CONFIGURE: 1
|
||||||
LW_DB_HOST: db
|
LW_DB_HOST: db
|
||||||
|
@ -54,6 +56,7 @@ services:
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
database:
|
database:
|
||||||
|
init-state:
|
||||||
|
|
||||||
secrets:
|
secrets:
|
||||||
db_password:
|
db_password:
|
||||||
|
|
Loading…
Add table
Reference in a new issue