From 623e9535f3a001de026c981ab62152e0faf36525 Mon Sep 17 00:00:00 2001 From: Laica Lunasys Date: Mon, 15 Jul 2024 10:24:07 +0900 Subject: [PATCH] Add packy --- plain/Dockerfile | 40 +++++++++++++++++++++++++++------------- plain/entrypoint.sh | 2 +- plain/launcher.sh | 8 ++++++++ 3 files changed, 36 insertions(+), 14 deletions(-) diff --git a/plain/Dockerfile b/plain/Dockerfile index 8893596..801c1d6 100644 --- a/plain/Dockerfile +++ b/plain/Dockerfile @@ -1,35 +1,49 @@ -FROM docker.io/alpine:latest AS download_velocity -WORKDIR /velocity +FROM docker.io/alpine:latest AS download_assets ARG VELOCITY_VERSION=3.1.1 +ARG TARGETPLATFORM +ARG TARGETOS +ARG TARGETARCH RUN apk add --no-cache curl jq COPY utils/velocity.sh /velocity/ +# Download tools +WORKDIR /tmp +RUN wget -O packy.tar.gz https://github.com/synchthia/packy/releases/latest/download/packy_${TARGETOS}_${TARGETARCH}.tar.gz && \ + tar -xvzf ./packy.tar.gz && \ + wget -O yq https://github.com/mikefarah/yq/releases/latest/download/yq_${TARGETOS}_${TARGETARCH} && \ + chmod +x yq + # Download velocity +WORKDIR /velocity RUN sh /velocity/velocity.sh ${VELOCITY_VERSION} + # --- # --- -FROM docker.io/eclipse-temurin:17-alpine +FROM docker.io/eclipse-temurin:21 EXPOSE 25565 -ENV LANG en_US.UTF-8 +ENV LANG=en_US.UTF-8 # Config -ENV ONLINE_MODE true -ENV PORT 25565 +ENV ONLINE_MODE=true +ENV PORT=25565 + +# Install assets +COPY --from=download_assets /tmp/packy /tmp/yq /usr/local/bin/ # Install velocity -COPY --from=download_velocity /velocity/velocity.jar /velocity/ +COPY --from=download_assets /velocity/velocity.jar /velocity/ -# Setup user -RUN chmod u+s /bin/* && \ - apk --no-cache add su-exec shadow yq +RUN apt-get update -qq && \ + apt-get install -y gosu && \ + apt-get clean # Copy Entry point COPY entrypoint.sh launcher.sh autoconfig.sh / -RUN addgroup -g 1000 app && \ - adduser app -u 1000 -S -G app +RUN addgroup --gid 1000 app && \ + useradd app --uid 1000 -g app -s /bin/bash # Copy basements... COPY templates/ /app/templates/ @@ -43,4 +57,4 @@ RUN mkdir -p \ WORKDIR /app/server -CMD ["sh", "/entrypoint.sh"] +CMD ["bash", "/entrypoint.sh"] diff --git a/plain/entrypoint.sh b/plain/entrypoint.sh index d1f8232..cf4d93d 100644 --- a/plain/entrypoint.sh +++ b/plain/entrypoint.sh @@ -15,4 +15,4 @@ if [ $(id -u) = 0 ]; then fi chown ${UID:-app}:${GID:-app} -R /app/ -exec su-exec ${UID:-app} sh /launcher.sh start +exec gosu ${UID:-app} bash /launcher.sh start diff --git a/plain/launcher.sh b/plain/launcher.sh index 54e836a..b3c0ad1 100644 --- a/plain/launcher.sh +++ b/plain/launcher.sh @@ -22,7 +22,15 @@ _task_prepare() { done } + _fetch() { + if [ "$USE_PACKY" ]; then + packy fetch -s "velocity" -d /app/plugins + fi + } + _template + + _fetch } ## start - start server