-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from cisagov/first-commits
Initial Functionality
- Loading branch information
Showing
14 changed files
with
661 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,77 @@ | ||
ARG VERSION=unspecified | ||
ARG PY_VERSION=3.9 | ||
|
||
FROM python:3.9-alpine | ||
|
||
ARG VERSION | ||
FROM python:${PY_VERSION} AS compile-stage | ||
|
||
# For a list of pre-defined annotation keys and value types see: | ||
# https://github.com/opencontainers/image-spec/blob/master/annotations.md | ||
# Note: Additional labels are added by the build workflow. | ||
LABEL org.opencontainers.image.authors="mark.feldhousen@cisa.dhs.gov" | ||
LABEL org.opencontainers.image.authors="nicholas.mcdonnell@cisa.dhs.gov" | ||
LABEL org.opencontainers.image.vendor="Cyber and Infrastructure Security Agency" | ||
|
||
ARG CISA_UID=421 | ||
ENV CISA_HOME="/home/cisa" | ||
ENV ECHO_MESSAGE="Hello World from Dockerfile" | ||
RUN apt-get update \ | ||
&& apt-get install -y --allow-downgrades --no-install-recommends \ | ||
libxml2-dev=2.9.4+dfsg1-7+deb10u1 \ | ||
libxslt1-dev=1.1.32-2.2~deb10u1 | ||
|
||
ENV PY_VENV=/.venv | ||
|
||
# Manually set up the virtual environment | ||
RUN python -m venv --system-site-packages ${PY_VENV} | ||
ENV PATH="${PY_VENV}/bin:$PATH" | ||
|
||
# Install core Python dependencies | ||
RUN python -m pip install --no-cache-dir \ | ||
pip==21.0.1 \ | ||
pipenv==2020.11.15 \ | ||
setuptools==53.0.0 \ | ||
wheel==0.36.2 | ||
|
||
# Install vdp_scanner.py requirements | ||
COPY src/Pipfile Pipfile | ||
COPY src/Pipfile.lock Pipfile.lock | ||
# PIPENV_VENV_IN_PROJECT=1 directs pipenv to use the current directory for venvs | ||
RUN PIPENV_VENV_IN_PROJECT=1 pipenv sync | ||
|
||
# We only need pipenv to set up the environment, so we remove it from the venv | ||
# as a last step. | ||
RUN python -m pip uninstall --yes pipenv | ||
|
||
FROM python:${PY_VERSION}-slim AS build-stage | ||
|
||
ARG SERVERLESS_CHROME_VERSION="v1.0.0-57" | ||
ARG SERVERLESS_CHROME_LOCAL="/usr/local/bin/serverless-chrome" | ||
|
||
RUN apt-get update \ | ||
&& apt-get install -y --allow-downgrades --no-install-recommends \ | ||
ca-certificates=20200601~deb10u2 \ | ||
chromium-common=88.0.4324.182-1~deb10u1 \ | ||
curl=7.64.0-4+deb10u2 \ | ||
libnss3=2:3.42.1-1+deb10u3 \ | ||
libxml2-dev=2.9.4+dfsg1-7+deb10u1 \ | ||
libxslt1-dev=1.1.32-2.2~deb10u1 \ | ||
openssl=1.1.1d-0+deb10u6 \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
RUN addgroup --system --gid ${CISA_UID} cisa \ | ||
&& adduser --system --uid ${CISA_UID} --ingroup cisa cisa | ||
# Download the specified serverless chrome release and install it for use | ||
SHELL ["/bin/bash", "-o", "pipefail", "-c"] | ||
# Follow redirects and output as the specified file name | ||
RUN curl -L \ | ||
https://github.com/adieuadieu/serverless-chrome/releases/download/${SERVERLESS_CHROME_VERSION}/stable-headless-chromium-amazonlinux-2.zip \ | ||
| gunzip --stdout - > ${SERVERLESS_CHROME_LOCAL} | ||
RUN chmod 755 ${SERVERLESS_CHROME_LOCAL} | ||
|
||
RUN apk --update --no-cache add \ | ||
ca-certificates \ | ||
openssl \ | ||
py-pip | ||
ENV PY_VENV=/.venv | ||
COPY --from=compile-stage ${PY_VENV} ${PY_VENV} | ||
ENV PATH="${PY_VENV}/bin:$PATH" | ||
|
||
WORKDIR ${CISA_HOME} | ||
ENV TASK_HOME="/task" | ||
|
||
RUN wget -O sourcecode.tgz https://github.com/cisagov/skeleton-python-library/archive/v${VERSION}.tar.gz && \ | ||
tar xzf sourcecode.tgz --strip-components=1 && \ | ||
pip install --requirement requirements.txt && \ | ||
ln -snf /run/secrets/quote.txt src/example/data/secret.txt && \ | ||
rm sourcecode.tgz | ||
WORKDIR ${TASK_HOME} | ||
RUN mkdir host_mount | ||
|
||
USER cisa | ||
COPY src/version.txt version.txt | ||
COPY src/vdp_scanner.py vdp_scanner.py | ||
|
||
EXPOSE 8080/TCP | ||
VOLUME ["/var/log"] | ||
ENTRYPOINT ["example"] | ||
CMD ["--log-level", "DEBUG"] | ||
ENTRYPOINT ["python", "vdp_scanner.py"] | ||
CMD ["github"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
[[source]] | ||
url = "https://pypi.org/simple" | ||
verify_ssl = true | ||
name = "pypi" | ||
|
||
[packages] | ||
docopt = "*" | ||
hash-http-content = {file = "https://github.com/cisagov/hash-http-content/archive/v0.0.1.tar.gz"} | ||
requests = "*" | ||
urllib3 = "*" | ||
pip = "*" | ||
setuptools = "*" | ||
wheel = "*" | ||
|
||
[dev-packages] | ||
|
||
[requires] | ||
python_version = "3" |
Oops, something went wrong.