From a11b35f4c2fcf799021ce789012d03e429b3916f Mon Sep 17 00:00:00 2001 From: Brad Cowie Date: Wed, 30 Mar 2022 10:54:35 +1300 Subject: [PATCH] Change base image from faucet/base to python:3.9-alpine3.15. --- Dockerfile | 8 ++++++-- entrypoint.sh | 15 +++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) create mode 100755 entrypoint.sh diff --git a/Dockerfile b/Dockerfile index 3bfbcdc..da1140c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,11 @@ ## Image name: faucet/python3 -FROM faucet/base:7.0.0 +FROM python:3.9-alpine3.15 -RUN apk add --no-cache python3 py-pip && \ +RUN apk add --no-cache bash su-exec && \ if [ ! -e /usr/bin/pip ]; then ln -s /usr/bin/pip3 /usr/bin/pip; fi && \ if [ ! -e /usr/bin/python ]; then ln -s /usr/bin/python3 /usr/bin/python; fi + +COPY entrypoint.sh /usr/local/bin/entrypoint.sh + +ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..ee0d70b --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +# Add local user +# Either use the LOCAL_USER_ID if passed in at runtime or +# fallback to 0 to maintain backwards compatibility + +USER_ID=${LOCAL_USER_ID:-0} +GROUP_ID=${LOCAL_GROUP_ID:-0} + +echo "Starting with UID=$USER_ID GID=$GROUP_ID" +export HOME="/home/faucet" +addgroup -g "${GROUP_ID}" faucet >/dev/null 2>&1 || true +adduser -u "${USER_ID}" -G faucet -g "" -h "${HOME}" -D faucet >/dev/null 2>&1 || true + +exec /sbin/su-exec faucet "$@"