Add trap to gracefully cleanup, add screen session

This commit is contained in:
Salt 2021-05-12 22:41:01 -05:00
parent df3c6166ac
commit ed6fc1af16
2 changed files with 8 additions and 3 deletions

View File

@ -17,7 +17,7 @@ RUN apk add curl openjdk8-jre &&\
# The second stage is the actual container
FROM openjdk:8
RUN apt-get update && apt-get install rsync -y
RUN apt-get update && apt-get install rsync screen -y
WORKDIR /minecraft
COPY --from=build /minecraft .
CMD [ "bash", "start-server.sh" ]

View File

@ -1,4 +1,4 @@
#! /bin/sh
#! /bin/bash
#
# start-server.sh
# Copyright (C) 2021 Vintage Salt <rehashedsalt@cock.li>
@ -33,5 +33,10 @@ java -version
echo "Invoking java with args: $args"
# Start 'er up
java $args
cleanup() {
screen -p 0 -S minecraft -X stuff save-all^M
screen -p 0 -S minecraft -X stuff stop^M
}
trap cleanup EXIT
screen -DmS minecraft java $args