From c21fbf54e72fa578195cd3c3b8e08307e9c027f4 Mon Sep 17 00:00:00 2001 From: Nicholas McDonnell <50747025+mcdonnnj@users.noreply.github.com> Date: Tue, 21 Mar 2023 11:32:16 -0400 Subject: [PATCH] Update host mount directory creation Add a HOST_MOUNT argument to the Dockerfile to support adjusting the path for the host mount directory in the image. Rearrange some of the RUN instructions in the Dockerfile and change the host mount directory creation to also create any intermediate directories. --- Dockerfile | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 03f10a4..eaa7e81 100644 --- a/Dockerfile +++ b/Dockerfile @@ -69,8 +69,13 @@ ARG CISA_GID=${CISA_UID} ARG CISA_USER="cisa" ENV CISA_GROUP=${CISA_USER} ENV CISA_HOME="/home/${CISA_USER}" + +# Python virtual environment location ENV VIRTUAL_ENV="${CISA_HOME}/.venv" +# Host mount directory +ARG HOST_MOUNT="${CISA_HOME}/host_mount" + RUN apk --no-cache add \ ca-certificates=20240226-r0 \ chromium=119.0.6045.159-r0 \ @@ -81,19 +86,20 @@ RUN apk --no-cache add \ RUN addgroup --system --gid ${CISA_GID} ${CISA_GROUP} \ && adduser --system --uid ${CISA_UID} --ingroup ${CISA_GROUP} ${CISA_USER} +# Create the HOST MOUNT directory (and any intermediate directories) +RUN mkdir --parents ${HOST_MOUNT} + # Copy in the Python venv we created in the compile stage and re-symlink # python3 in the venv to the Python binary in this image COPY --from=compile-stage --chown=${CISA_USER}:${CISA_GROUP} ${VIRTUAL_ENV} ${VIRTUAL_ENV}/ RUN ln -sf "$(command -v python3)" "${VIRTUAL_ENV}"/bin/python3 ENV PATH="${VIRTUAL_ENV}/bin:$PATH" -WORKDIR ${CISA_HOME} -RUN mkdir host_mount - # Copy in the necessary files -COPY --chown=${CISA_USER}:${CISA_GROUP} src/version.txt src/vdp_scanner.py ./ +COPY --chown=${CISA_USER}:${CISA_GROUP} src/version.txt src/vdp_scanner.py ${CISA_HOME}/ # Prepare to run +WORKDIR ${CISA_HOME} USER ${CISA_USER}:${CISA_GROUP} ENTRYPOINT ["python3", "vdp_scanner.py"] CMD ["github"]