Skip to content

Commit

Permalink
Restore Dockerfile changes from review
Browse files Browse the repository at this point in the history
I accidentally clobbered these changes when I was updating
#135 for merge. This restores the changes made
during review as well as fixing a missed reference to the CISA_USER
argument.

Co-authored-by: Shane Frasier <jeremy.frasier@trio.dhs.gov>
  • Loading branch information
mcdonnnj and jsf9k committed Nov 22, 2022
1 parent 81f6c71 commit 87fa1c0
Showing 1 changed file with 12 additions and 25 deletions.
37 changes: 12 additions & 25 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,40 +16,27 @@ LABEL org.opencontainers.image.vendor="Cybersecurity and Infrastructure Security
###
# Unprivileged user setup variables
###
ARG CISA_GID=421
ARG CISA_UID=${CISA_GID}
ENV CISA_USER="cisa"
ARG CISA_UID=421
ARG CISA_GID=${CISA_UID}
ARG CISA_USER="cisa"
ENV CISA_GROUP=${CISA_USER}
ENV CISA_HOME="/home/cisa"
ENV CISA_HOME="/home/${CISA_USER}"

###
# Unprivileged user setup dependencies
#
# Install shadow, so we have adduser and addgroup.
# Upgrade the system
#
# Note that we use apk --no-cache to avoid writing to a local cache.
# This results in a smaller final image, at the cost of slightly
# longer install times.
#
# Setup user dependencies are only needed for setting up the user and
# will be removed at the end of that process.
###
ENV SETUP_USER_DEPS \
shadow
RUN apk --update --no-cache --quiet upgrade
RUN apk --no-cache --quiet add ${SETUP_USER_DEPS}

###
# Create unprivileged user
###
RUN addgroup --system --gid ${CISA_UID} ${CISA_GROUP} \
RUN addgroup --system --gid ${CISA_GID} ${CISA_GROUP} \
&& adduser --system --uid ${CISA_UID} --ingroup ${CISA_GROUP} ${CISA_USER}

###
# Remove build dependencies for unprivileged user
###
RUN apk --no-cache --quiet del ${SETUP_USER_DEPS}

###
# Dependencies
#
Expand Down Expand Up @@ -82,17 +69,17 @@ WORKDIR ${CISA_HOME}
# slightly longer install times.
###
RUN wget --output-document sourcecode.tgz \
https://github.com/cisagov/skeleton-python-library/archive/v${VERSION}.tar.gz && \
tar --extract --gzip --file sourcecode.tgz --strip-components=1 && \
pip install --no-cache-dir --requirement requirements.txt && \
ln -snf /run/secrets/quote.txt src/example/data/secret.txt && \
rm sourcecode.tgz
https://github.com/cisagov/skeleton-python-library/archive/v${VERSION}.tar.gz \
&& tar --extract --gzip --file sourcecode.tgz --strip-components=1 \
&& pip install --no-cache-dir --requirement requirements.txt \
&& ln -snf /run/secrets/quote.txt src/example/data/secret.txt \
&& rm sourcecode.tgz

###
# Prepare to run
###
ENV ECHO_MESSAGE="Hello World from Dockerfile"
USER cisa
USER ${CISA_USER}
EXPOSE 8080/TCP
VOLUME ["/var/log"]
ENTRYPOINT ["example"]
Expand Down

0 comments on commit 87fa1c0

Please sign in to comment.