Skip to content

Commit

Permalink
Update default_nonroot_user.df (#141)
Browse files Browse the repository at this point in the history
  • Loading branch information
floryn90 authored Sep 15, 2024
2 parents fab6b5a + 62d7c44 commit 7133eae
Show file tree
Hide file tree
Showing 14 changed files with 57 additions and 40 deletions.
8 changes: 3 additions & 5 deletions src/docker/_imports/default_nonroot_user.df
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
FROM main as ext

RUN addgroup --gid 1000 hugo \
&& adduser --uid 1000 --gid 1000 --disabled-password --gecos "" hugo \
# Create a custom user with UID 1234 and GID 1234
RUN getent group hugo 2>&1 > /dev/null || groupadd -g 1234 hugo && \
getent passwd hugo 2>&1 > /dev/null || useradd -m -u 1234 -g hugo hugo \
&& chown -R hugo /src \
&& chown -R hugo /target

USER hugo
4 changes: 4 additions & 0 deletions src/docker/_imports/default_nonroot_user_alpine.df
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
RUN getent group hugo 2>&1 > /dev/null || addgroup -g 1234 hugo \
&& getent passwd hugo 2>&1 > /dev/null || adduser -u 1234 -D -H -G hugo -g "" hugo \
&& chown -R hugo /src \
&& chown -R hugo /target
9 changes: 8 additions & 1 deletion src/docker/alpine-ext/ext-alpine.df
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ ENV HUGO_BIND="0.0.0.0" \
GOROOT="/usr/local/lib/go" \
HOME="/tmp"

USER root

RUN apk -U upgrade && apk add --no-cache libc6-compat gcompat libstdc++ openssl ncurses-libs busybox-suid bash bash-completion git tzdata make \
# Python 3
python3 py3-pip py3-setuptools
Expand Down Expand Up @@ -51,8 +53,12 @@ RUN true \

EXPOSE 1313

IMPORT ../_imports/default_nonroot_user_alpine.df

WORKDIR /src

USER hugo

ENTRYPOINT ["hugo"]


Expand All @@ -62,5 +68,6 @@ IMPORT ../_imports/ci.df
IMPORT ../_imports/onbuild.df



FROM main

USER hugo
8 changes: 5 additions & 3 deletions src/docker/alpine-ext/ext-asciidoctor.df
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
FROM ext-alpine AS main

USER root

RUN apk -U upgrade && apk --no-cache add asciidoctor \
&& gem install coderay --no-document \
&& find /tmp -mindepth 1 -maxdepth 1 | xargs rm -rf


IMPORT ../_imports/default_nonroot_user_alpine.df

IMPORT ../_imports/ci.df

IMPORT ../_imports/onbuild.df

FROM main


FROM main
USER hugo
6 changes: 3 additions & 3 deletions src/docker/alpine-ext/ext-pandoc.df
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ FROM ext-alpine AS main

COPY --from=base--pandoc / /


IMPORT ../_imports/default_nonroot_user_alpine.df

IMPORT ../_imports/ci.df

IMPORT ../_imports/onbuild.df

FROM main


FROM main
USER hugo
12 changes: 4 additions & 8 deletions src/docker/alpine/alpine.df
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,20 @@ ENV HUGO_BIND="0.0.0.0" \
HOME="/tmp"

COPY --from=image / /

USER root
RUN apk -U upgrade && apk --no-cache add busybox-suid bash bash-completion tzdata make \
&& find /tmp -mindepth 1 -maxdepth 1 | xargs rm -rf \
&& mkdir -p /src /target \
&& chmod a+w /src /target

EXPOSE 1313

IMPORT ../_imports/default_nonroot_user_alpine.df
WORKDIR /src

ENTRYPOINT ["hugo"]



IMPORT ../_imports/ci.df

IMPORT ../_imports/onbuild.df



FROM main
FROM main
USER hugo
8 changes: 4 additions & 4 deletions src/docker/alpine/asciidoctor.df
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
FROM alpine AS main

USER root
RUN apk -U upgrade && apk --no-cache add asciidoctor \
&& gem install coderay asciidoctor-rouge --no-document \
&& find /tmp -mindepth 1 -maxdepth 1 | xargs rm -rf


IMPORT ../_imports/default_nonroot_user_alpine.df

IMPORT ../_imports/ci.df

IMPORT ../_imports/onbuild.df

FROM main


FROM main
USER hugo
6 changes: 3 additions & 3 deletions src/docker/alpine/pandoc.df
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ ENV HUGO_PANDOC="pandoc-default"

COPY --from=base--pandoc / /


IMPORT ../_imports/default_nonroot_user_alpine.df

IMPORT ../_imports/ci.df

IMPORT ../_imports/onbuild.df

FROM main


FROM main
USER hugo
6 changes: 5 additions & 1 deletion src/docker/debian-ext/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ ENV HUGO_EDITION="extended" \

COPY --from=image / /

USER root

RUN true \
#
# Install software
Expand Down Expand Up @@ -64,6 +66,8 @@ IMPORT ../_imports/ci.df

IMPORT ../_imports/onbuild.df


IMPORT ../_imports/default_nonroot_user.df

FROM main

USER hugo
6 changes: 3 additions & 3 deletions src/docker/debian/base.df
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ENV HUGO_BIND="0.0.0.0" \
HUGO_DESTINATION="public" \
HUGO_ENV="DEV" \
HOME="/tmp"

USER root
RUN apt update \
&& apt full-upgrade -y \
&& DEBIAN_FRONTEND=noninteractive apt install -y wget bash-completion tzdata make ca-certificates \
Expand All @@ -18,7 +18,7 @@ RUN apt update \
COPY --from=base--files--debian / /

EXPOSE 1313

IMPORT ../_imports/default_nonroot_user.df
WORKDIR /src

USER hugo
ENTRYPOINT ["hugo"]
6 changes: 3 additions & 3 deletions src/docker/debian/debian.df
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ ENV HUGO_EDITION="standard"

COPY --from=base--hugo--standard / /



IMPORT ../_imports/ci.df

IMPORT ../_imports/onbuild.df

IMPORT ../_imports/default_nonroot_user.df

FROM main

FROM main
USER hugo
6 changes: 4 additions & 2 deletions src/docker/ubuntu-ext/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ ENV HUGO_EDITION="extended" \

COPY --from=image / /

USER root

RUN true \
#
# Install software
Expand Down Expand Up @@ -58,12 +60,12 @@ RUN true \

COPY --from=base--golang / /



IMPORT ../_imports/ci.df

IMPORT ../_imports/onbuild.df

IMPORT ../_imports/default_nonroot_user.df

FROM main

USER hugo
6 changes: 5 additions & 1 deletion src/docker/ubuntu/base.df
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ ENV HUGO_BIND="0.0.0.0" \

COPY --from=base--files--ubuntu / /

USER root

RUN apt update \
&& apt -y full-upgrade \
&& DEBIAN_FRONTEND=noninteractive apt install -y wget bash-completion tzdata make ca-certificates \
Expand All @@ -18,7 +20,9 @@ RUN apt update \
&& chmod a+w /src /target

EXPOSE 1313

IMPORT ../_imports/default_nonroot_user.df
WORKDIR /src

USER hugo

ENTRYPOINT ["hugo"]
6 changes: 3 additions & 3 deletions src/docker/ubuntu/ubuntu.df
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ ENV HUGO_EDITION="standard"

COPY --from=base--hugo--standard / /



IMPORT ../_imports/ci.df

IMPORT ../_imports/onbuild.df

IMPORT ../_imports/default_nonroot_user.df

FROM main
FROM main

USER hugo

0 comments on commit 7133eae

Please sign in to comment.