deployment/stacks/paper/Dockerfile

66 lines
1.8 KiB
Docker
Raw Normal View History

2021-12-27 18:28:57 +01:00
ARG BASE_IMAGE
# Build dumb-init
FROM alpine AS dumb-init-builder
ARG DI_VER=1.2.5
WORKDIR /app
# Build dumb-init & download tshock
RUN apk add --update --no-cache build-base unzip curl && \
curl -Lo - "https://github.com/Yelp/dumb-init/archive/refs/tags/v${DI_VER}.tar.gz" | tar -xzf - && \
cd "dumb-init-${DI_VER}" && \
make SHELL=/bin/sh && \
mv dumb-init ..
2021-12-27 18:28:57 +01:00
# We use ${:-} instead of a default value because the argument is always passed
# to the build, it'll just be blank most likely
2023-06-13 13:55:36 +02:00
FROM ${BASE_IMAGE:-'eclipse-temurin:18-jre-alpine'}
2021-12-27 18:28:57 +01:00
# Build arguments
ARG MC_VERSION
ARG PAPERMC_VERSION
2023-06-13 13:55:36 +02:00
# Install alex binary
2023-07-21 11:47:36 +02:00
ADD "https://git.rustybever.be/api/packages/Chewing_Bever/generic/alex/0.3.1/alex-linux-amd64" /bin/alex
2023-06-13 13:55:36 +02:00
RUN chmod +x /bin/alex && \
addgroup -Sg 1000 paper && \
adduser -SHG paper -u 1000 paper
2021-12-27 18:28:57 +01:00
# Create worlds and config directory
WORKDIR /app
2023-06-13 13:55:36 +02:00
RUN mkdir -p worlds config/cache backups
2021-12-27 18:28:57 +01:00
# Download server file
ADD "https://papermc.io/api/v2/projects/paper/versions/$MC_VERSION/builds/$PAPERMC_VERSION/downloads/paper-$MC_VERSION-$PAPERMC_VERSION.jar" server.jar
# Make sure the server user can access all necessary folders
RUN chown -R paper:paper /app
# Store the cache in an anonymous volume, which means it won't get stored in the other volumes
VOLUME /app/config/cache
2023-06-13 13:55:36 +02:00
ENV ALEX_JAR=/app/server.jar \
ALEX_CONFIG_DIR=/app/config \
ALEX_WORLD_DIR=/app/worlds \
ALEX_BACKUP_DIR=/app/backups \
2023-07-04 16:30:19 +02:00
ALEX_SERVER=paper \
2023-06-13 13:55:36 +02:00
ALEX_SERVER_VERSION="${MC_VERSION}-${PAPERMC_VERSION}"
2021-12-27 18:28:57 +01:00
# Document exposed ports
EXPOSE 25565
# Switch to non-root user
USER paper:paper
COPY --from=dumb-init-builder /app/dumb-init /dumb-init
ENTRYPOINT ["/dumb-init", "--"]
2023-07-04 16:30:19 +02:00
CMD /bin/alex run
2021-12-27 18:28:57 +01:00
2023-06-13 13:55:36 +02:00
# HEALTHCHECK --interval=30s --timeout=5s --start-period=1m --retries=5 \
# CMD mcstatus localhost:25565 ping