Fix JRE_VERSION being unscoped in the final stage

This commit is contained in:
Salt 2022-05-17 11:33:48 -05:00
parent a107b4b76e
commit 025d88f7e0

View File

@ -1,16 +1,20 @@
# The first stage just builds up the modpack
FROM alpine:latest AS build
# Args # Args
ARG MINECRAFT_VERSION="1.16.5" ARG MINECRAFT_VERSION="1.16.5"
ARG FORGE_VERSION="36.2.26" ARG FORGE_VERSION="36.2.26"
ARG JRE_VERSION="openjdk8-jre" ARG JRE_VERSION="openjdk8-jre"
# The first stage just builds up the modpack
FROM alpine:latest AS build
# Use all of our arguments
ARG MINECRAFT_VERSION
ARG FORGE_VERSION
ARG JRE_VERSION
# Build us up the basics of the Minecraft server environment # Build us up the basics of the Minecraft server environment
COPY start-server.sh /minecraft/start-server.sh COPY start-server.sh /minecraft/start-server.sh
WORKDIR /minecraft WORKDIR /minecraft
RUN apk add curl &&\ RUN apk add curl "${JRE_VERSION}" &&\
apk add "${JRE_VERSION}" &&\
curl -L "https://files.minecraftforge.net/maven/net/minecraftforge/forge/${MINECRAFT_VERSION}-${FORGE_VERSION}/forge-${MINECRAFT_VERSION}-${FORGE_VERSION}-installer.jar" -o installer.jar &&\ curl -L "https://files.minecraftforge.net/maven/net/minecraftforge/forge/${MINECRAFT_VERSION}-${FORGE_VERSION}/forge-${MINECRAFT_VERSION}-${FORGE_VERSION}-installer.jar" -o installer.jar &&\
java -jar installer.jar --installServer &&\ java -jar installer.jar --installServer &&\
echo "eula=true" > eula.txt &&\ echo "eula=true" > eula.txt &&\
@ -19,8 +23,12 @@ RUN apk add curl &&\
# Stuff them in a smaller container with fewer layers # Stuff them in a smaller container with fewer layers
FROM alpine:latest AS final FROM alpine:latest AS final
RUN apk add bash rsync screen &&\
apk add "${JRE_VERSION}" # Use only a subset of arguments
ARG JRE_VERSION
# Build the thing up
RUN apk add bash rsync screen "${JRE_VERSION}"
WORKDIR /minecraft WORKDIR /minecraft
COPY --from=build /minecraft . COPY --from=build /minecraft .
CMD [ "bash", "start-server.sh" ] CMD [ "bash", "start-server.sh" ]