From 2037324375389c60b536589b4f93ce346ce8ec5d Mon Sep 17 00:00:00 2001 From: Jeremy McClure Date: Sat, 29 Mar 2025 04:08:02 -0400 Subject: [PATCH] convert to "rootless" --- Dockerfile | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/Dockerfile b/Dockerfile index e1e0031..377876b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,32 +1,36 @@ FROM ubuntu:noble +ARG UID=1000 +ARG GID=1000 + ENV DEBIAN_FRONTEND=noninteractive +SHELL ["/bin/bash", "-o", "pipefail", "-c"] + # install prerequisites -RUN apt update \ - && apt install -y --no-install-recommends \ - curl ca-certificates \ - jq \ - libxml2-utils \ - && apt autoremove \ - && apt clean \ - && rm -rf /var/lib/apt/lists/* +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + curl \ + ca-certificates \ + jq \ + libxml2-utils \ + sudo && \ + apt-get autoremove && apt-get clean && \ + rm -rf /var/lib/apt/lists/* # Remove default ubuntu user -RUN userdel -r ubuntu \ - && useradd --create-home -u 1000 minecraft \ - && mkdir -p /data \ - && chown -R 1000:1000 /data +RUN userdel -r ubuntu && \ + useradd --create-home -u 1000 minecraft && \ + echo 'minecraft ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers && \ + mkdir -p /data && \ + chown -R ${UID}:${GID} /data -USER minecraft - -RUN curl -sL https://github.com/Jabba-Team/jabba/raw/main/install.sh | bash \ - && . ~/.jabba/jabba.sh - -USER root +RUN su -c "curl -sL https://github.com/Jabba-Team/jabba/raw/main/install.sh | bash && . ~/.jabba/jabba.sh" minecraft COPY ./scripts/init / COPY ./scripts/mc /usr/local/bin RUN chmod +x /init && chmod +x /usr/local/bin/mc -CMD ["/init"] \ No newline at end of file +USER minecraft + +CMD ["/init"]