Skip to content

Commit

Permalink
Run process as non-root
Browse files Browse the repository at this point in the history
  • Loading branch information
joecorall committed Aug 8, 2024
1 parent ae6f345 commit 0ea0e47
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
26 changes: 26 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,42 @@
FROM golang:1.22-alpine

ENV GOSU_VERSION 1.17
RUN set -eux; \

Check failure on line 4 in Dockerfile

View workflow job for this annotation

GitHub Actions / build-push-base / build-push-ar

DL3047 info: Avoid use of wget without progress bar. Use `wget --progress=dot:giga <url>`. Or consider using `-q` or `-nv` (shorthands for `--quiet` or `--no-verbose`).

Check failure on line 4 in Dockerfile

View workflow job for this annotation

GitHub Actions / build-push-base / build-push-ar

DL4006 warning: Set the SHELL option -o pipefail before RUN with a pipe in it. If you are using /bin/sh in an alpine image or if your shell is symlinked to busybox then consider explicitly setting your SHELL to /bin/ash, or disable this check

Check failure on line 4 in Dockerfile

View workflow job for this annotation

GitHub Actions / build-push-base / build-push-ar

SC2155 warning: Declare and assign separately to avoid masking return values.
\
apk add --no-cache --virtual .gosu-deps \
ca-certificates==20240705-r0 \
dpkg==1.22.6-r1 \
gnupg==2.4.5-r0 && \
dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')" && \
wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch"; \
wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch.asc"; \
export GNUPGHOME="$(mktemp -d)"; \
gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4; \
gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu; \
gpgconf --kill all; \
rm -rf "$GNUPGHOME" /usr/local/bin/gosu.asc; \
apk del --no-network .gosu-deps; \
chmod +x /usr/local/bin/gosu; \
gosu --version; \
gosu nobody true

WORKDIR /app

SHELL ["/bin/ash", "-o", "pipefail", "-c"]

RUN adduser -S -G nobody scyllaridae

RUN apk update && \
apk add --no-cache \
curl==8.9.0-r0 \
bash==5.2.26-r0 \
ca-certificates==20240705-r0 \
openssl==3.3.1-r3

COPY . ./

RUN chown -R scyllaridae:nobody /app

RUN go mod download && \
go build -o /app/scyllaridae && \
go clean -cache -modcache && \
Expand Down
2 changes: 1 addition & 1 deletion docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ if [ -f /app/ca.pem ]; then
update-ca-certificates
fi

exec /app/scyllaridae
exec gosu scyllaridae /app/scyllaridae

0 comments on commit 0ea0e47

Please sign in to comment.