diff --git a/Dockerfile b/Dockerfile index e2fcdaa..81b2fe0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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" ] diff --git a/start-server.sh b/start-server.sh index c1bef15..efdac89 100755 --- a/start-server.sh +++ b/start-server.sh @@ -1,4 +1,4 @@ -#! /bin/sh +#! /bin/bash # # start-server.sh # Copyright (C) 2021 Vintage Salt @@ -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