Skip to content

Commit

Permalink
feat(dockerfile): make docker image run as non root user by default (#12
Browse files Browse the repository at this point in the history
)
  • Loading branch information
LiyangW committed Oct 14, 2022
1 parent b2a401f commit dab46ea
Showing 1 changed file with 29 additions and 19 deletions.
48 changes: 29 additions & 19 deletions backwork/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,24 @@ LABEL maintainer="leonsp@ca.ibm.com"
# Apply security patches
# hadolint ignore=DL3018
RUN echo 'http://dl-3.alpinelinux.org/alpine/edge/community' >> /etc/apk/repositories \
&& echo 'http://dl-3.alpinelinux.org/alpine/edge/main' >> /etc/apk/repositories \
&& apk add --no-cache \
bash \
curl \
libressl \
mariadb-client \
mongodb-tools \
mysql \
postgresql \
tini \
&& apk add --upgrade --no-cache \
db \
expat \
freetype \
fontconfig \
libpng \
ncurses \
zlib
&& echo 'http://dl-3.alpinelinux.org/alpine/edge/main' >> /etc/apk/repositories \
&& apk add --no-cache \
bash \
curl \
libressl \
mariadb-client \
mongodb-tools \
mysql \
postgresql \
tini \
&& apk add --upgrade --no-cache \
db \
expat \
freetype \
fontconfig \
libpng \
ncurses \
zlib

# RUN curl -sL https://sentry.io/get-cli/ | bash

Expand All @@ -35,7 +35,17 @@ RUN python -m pip install --upgrade pip
RUN pip install setuptools==57.5.0
RUN pip install -r ./requirements.txt

COPY ./docker-entrypoint.sh /
# install sudo as root
RUN apk add --no-cache --update sudo

# add new user
RUN adduser -D myapp \
&& echo "myapp ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/myapp \
&& chmod 0440 /etc/sudoers.d/myapp

COPY --chown=myapp ./docker-entrypoint.sh /
RUN mkdir /backups && chown myapp /backups
USER myapp

VOLUME ["/backups"]
ENTRYPOINT ["/sbin/tini", "--"]
Expand Down

0 comments on commit dab46ea

Please sign in to comment.