From 89145e207e78127e4b6d1ff49aa7fa364d90ac40 Mon Sep 17 00:00:00 2001 From: ameliav Date: Thu, 21 Oct 2021 13:16:30 -0400 Subject: [PATCH 01/73] Add users to CODEOWNERS file --- .github/CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 371258c..7abec8c 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -3,7 +3,7 @@ # These owners will be the default owners for everything in the # repo. Unless a later match takes precedence, these owners will be # requested for review when someone opens a pull request. -* @dav3r @felddy @jsf9k @mcdonnnj +* @ameliav @BenBreaksThings @dav3r @felddy @JCantu248 @jsf9k @king-alexander @mcdonnnj @nickviola # These folks own any files in the .github directory at the root of # the repository and any of its subdirectories. From 8bddd3badea414271235be891486aaa0ba65a1f1 Mon Sep 17 00:00:00 2001 From: ameliav Date: Thu, 21 Oct 2021 13:21:48 -0400 Subject: [PATCH 02/73] Remove unneeded ports from docker-compose.yml --- docker-compose.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 0fc7ee5..aea6bcc 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -20,11 +20,6 @@ services: restart: "no" environment: - ECHO_MESSAGE=Hello World from docker-compose! - ports: - - target: 8080 - published: 8080 - protocol: tcp - mode: host secrets: - source: quote_txt target: quote.txt From c0c141df017745a4eb8f1e746874967dfda4f2f9 Mon Sep 17 00:00:00 2001 From: ameliav Date: Fri, 22 Oct 2021 14:57:44 -0400 Subject: [PATCH 03/73] Merge pca-report-library Dockerfile with this one --- Dockerfile | 54 +++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 41 insertions(+), 13 deletions(-) diff --git a/Dockerfile b/Dockerfile index 59ea4cd..c497c76 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,38 +1,66 @@ -ARG VERSION=unspecified +ARG GIT_COMMIT=unspecified +ARG GIT_REMOTE=unspecified +ARG VERSION=0.0.1 -FROM python:3.9.6-alpine +FROM python:3.9.6 +ARG GIT_COMMIT +ARG GIT_REMOTE ARG VERSION # 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 git_commit=$GIT_COMMIT +LABEL git_remote=$GIT_REMOTE LABEL org.opencontainers.image.authors="mark.feldhousen@cisa.dhs.gov" LABEL org.opencontainers.image.vendor="Cybersecurity and Infrastructure Security Agency" +LABEL version=$VERSION ARG CISA_UID=421 ENV CISA_HOME="/home/cisa" +ENV PCA_REPORT_TOOLS_SRC="/usr/src/pca-report-tools" ENV ECHO_MESSAGE="Hello World from Dockerfile" RUN addgroup --system --gid ${CISA_UID} cisa \ && adduser --system --uid ${CISA_UID} --ingroup cisa cisa -RUN apk --update --no-cache add \ -ca-certificates \ -openssl \ -py-pip +# RUN apk --update --no-cache add \ +# ca-certificates \ +# openssl \ +# py-pip WORKDIR ${CISA_HOME} -RUN wget -O sourcecode.tgz https://github.com/cisagov/skeleton-python-library/archive/v${VERSION}.tar.gz && \ +RUN apt-get install wget + +RUN apt-get update && \ + apt-get install --no-install-recommends -y texlive texlive-xetex texlive-bibtex-extra + +RUN wget -O sourcecode.tgz https://github.com/cisagov/pca-report-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 && \ + cp -r src/pca_report_library/assets/fonts /usr/share/fonts/truetype/ncats && \ rm sourcecode.tgz +RUN fc-cache -fsv + +WORKDIR $PCA_REPORT_TOOLS_SRC +COPY . $PCA_REPORT_TOOLS_SRC + +RUN pip install --no-cache-dir /home/cisa/ +RUN mkdir ${PCA_REPORT_TOOLS_SRC}/var +RUN mkdir ${PCA_REPORT_TOOLS_SRC}/var/getenv +RUN chmod +x ${PCA_REPORT_TOOLS_SRC}/var/getenv +RUN ln -snf ${PCA_REPORT_TOOLS_SRC}/var/getenv /usr/local/bin + +USER root +RUN chmod +x /home/cisa/var/getenv + USER cisa +WORKDIR $CISA_HOME +CMD ["getenv"] -EXPOSE 8080/TCP -VOLUME ["/var/log"] -ENTRYPOINT ["example"] -CMD ["--log-level", "DEBUG"] +# EXPOSE 8080/TCP +# VOLUME ["/var/log"] +# ENTRYPOINT ["example"] +# CMD ["--log-level", "DEBUG"] From e52afdb73578c1ed94b8c1810a843b4565c388ca Mon Sep 17 00:00:00 2001 From: ameliav Date: Fri, 22 Oct 2021 14:58:52 -0400 Subject: [PATCH 04/73] Update image name in build.yml --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c0c09c6..15541fc 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -27,7 +27,7 @@ on: env: BUILDX_CACHE_DIR: ~/.cache/buildx CURL_CACHE_DIR: ~/.cache/curl - IMAGE_NAME: cisagov/example + IMAGE_NAME: cisagov/pca-report-library PIP_CACHE_DIR: ~/.cache/pip PLATFORMS: "linux/amd64,linux/arm/v6,linux/arm/v7,\ linux/arm64,linux/ppc64le,linux/s390x" From 5146fa9f497c1d72cbccc2f386058d5f6cb75070 Mon Sep 17 00:00:00 2001 From: ameliav Date: Fri, 22 Oct 2021 15:50:18 -0400 Subject: [PATCH 05/73] Update Dockerfile to working state --- Dockerfile | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index c497c76..2f3a826 100644 --- a/Dockerfile +++ b/Dockerfile @@ -30,13 +30,13 @@ RUN addgroup --system --gid ${CISA_UID} cisa \ # openssl \ # py-pip -WORKDIR ${CISA_HOME} - RUN apt-get install wget RUN apt-get update && \ apt-get install --no-install-recommends -y texlive texlive-xetex texlive-bibtex-extra +WORKDIR $PCA_REPORT_TOOLS_SRC + RUN wget -O sourcecode.tgz https://github.com/cisagov/pca-report-library/archive/v${VERSION}.tar.gz && \ tar xzf sourcecode.tgz --strip-components=1 && \ cp -r src/pca_report_library/assets/fonts /usr/share/fonts/truetype/ncats && \ @@ -44,18 +44,10 @@ RUN wget -O sourcecode.tgz https://github.com/cisagov/pca-report-library/archive RUN fc-cache -fsv -WORKDIR $PCA_REPORT_TOOLS_SRC -COPY . $PCA_REPORT_TOOLS_SRC - -RUN pip install --no-cache-dir /home/cisa/ -RUN mkdir ${PCA_REPORT_TOOLS_SRC}/var -RUN mkdir ${PCA_REPORT_TOOLS_SRC}/var/getenv +RUN pip install --no-cache-dir . RUN chmod +x ${PCA_REPORT_TOOLS_SRC}/var/getenv RUN ln -snf ${PCA_REPORT_TOOLS_SRC}/var/getenv /usr/local/bin -USER root -RUN chmod +x /home/cisa/var/getenv - USER cisa WORKDIR $CISA_HOME CMD ["getenv"] From f496a4023ff4d11b32537f7e8132e28e87a60976 Mon Sep 17 00:00:00 2001 From: ameliav Date: Fri, 22 Oct 2021 15:51:02 -0400 Subject: [PATCH 06/73] Remove platforms from build.yml --- .github/workflows/build.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 15541fc..6cca1ac 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -29,8 +29,6 @@ env: CURL_CACHE_DIR: ~/.cache/curl IMAGE_NAME: cisagov/pca-report-library PIP_CACHE_DIR: ~/.cache/pip - PLATFORMS: "linux/amd64,linux/arm/v6,linux/arm/v7,\ - linux/arm64,linux/ppc64le,linux/s390x" PRE_COMMIT_CACHE_DIR: ~/.cache/pre-commit RUN_TMATE: ${{ secrets.RUN_TMATE }} From fc68801fd204de4f73e0b8df82720d4556dd6de7 Mon Sep 17 00:00:00 2001 From: ameliav Date: Fri, 22 Oct 2021 16:59:47 -0400 Subject: [PATCH 07/73] Add docker commands to README.md --- README.md | 44 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index d4a1d28..be723f2 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# pca-report-generator-docker 💀🐳 # +# pca-report-generator-docker # [![GitHub Build Status](https://github.com/cisagov/pca-report-generator-docker/workflows/build/badge.svg)](https://github.com/cisagov/pca-report-generator-docker/actions/workflows/build.yml) [![CodeQL](https://github.com/cisagov/pca-report-generator-docker/workflows/CodeQL/badge.svg)](https://github.com/cisagov/pca-report-generator-docker/actions/workflows/codeql-analysis.yml) @@ -10,21 +10,45 @@ [![Docker Image Size (latest by date)](https://img.shields.io/docker/image-size/cisagov/example)](https://hub.docker.com/r/cisagov/example) [![Platforms](https://img.shields.io/badge/platforms-amd64%20%7C%20arm%2Fv6%20%7C%20arm%2Fv7%20%7C%20arm64%20%7C%20ppc64le%20%7C%20s390x-blue)](https://hub.docker.com/r/cisagov/pca-report-generator-docker/tags) -This is a Docker skeleton project that can be used to quickly get a -new [cisagov](https://github.com/cisagov) GitHub Docker project -started. This skeleton project contains [licensing -information](LICENSE), as well as [pre-commit hooks](https://pre-commit.com) -and [GitHub Actions](https://github.com/features/actions) configurations -appropriate for Docker containers and the major languages that we use. +This is a Docker project that uses the pca-report-library package. + +The package is used for generating PCA reports with LaTeX and supporting scripts. ## Running ## -### Running with Docker ### +The following docker commands are available. + +An alias can also be set beforehand to remove redundancy. + +`pca-report-generator` - Builds PCA LaTeX report and complies the PDF + +```console +docker run -v $(pwd):/home/cisa cisagov/pca-report-generator pca-report-generator +``` + +`pca-report-templates` - Exports the Report Mustache template and Manual data +file template + +```console +docker run -v $(pwd):/home/cisa cisagov/pca-report-generator pca-report-templates +``` + +`pca-report-compiler` - Compiles a PCA LaTeX report file, still in development. + +```console +docker run -v $(pwd):/home/cisa cisagov/pca-report-generator pca-report-compiler +``` + +`pca-report-generator-bash` - Will SSH into the container + +```console +docker run -v $(pwd):/home/cisa cisagov/pca-report-generator pca-report-generator-bash +``` -To run the `cisagov/example` image via Docker: +For debuging purposes - Will SSH into the container without an extra command ```console -docker run cisagov/example:0.0.1 +docker run --rm -it --entrypoint bash cisagov/pca-report-generator ``` ### Running with Docker Compose ### From 49c27b15aa0fdc696be11dce478ee8fa4d672113 Mon Sep 17 00:00:00 2001 From: ameliav Date: Mon, 25 Oct 2021 13:53:14 -0400 Subject: [PATCH 08/73] Remove ports section from README.md --- README.md | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/README.md b/README.md index be723f2..888217a 100644 --- a/README.md +++ b/README.md @@ -179,17 +179,6 @@ Hub for a list of all the supported tags. |-------------|----------------| | `/var/log` | Log storage | -## Ports ## - -The following ports are exposed by this container: - -| Port | Purpose | -|------|----------------| -| 8080 | Example only; nothing is actually listening on the port | - -The sample [Docker composition](docker-compose.yml) publishes the -exposed port at 8080. - ## Environment variables ## ### Required ### From 8cc7e86b14f68c18d584073289e665d82f34f813 Mon Sep 17 00:00:00 2001 From: ameliav Date: Mon, 25 Oct 2021 13:55:52 -0400 Subject: [PATCH 09/73] Update Environment variables section in README.md --- README.md | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 888217a..486e300 100644 --- a/README.md +++ b/README.md @@ -183,19 +183,15 @@ Hub for a list of all the supported tags. ### Required ### -There are no required environment variables. - - +| `PCA_GENERATOR_IMAGE` | Docker image name. | `cisagov/pca-report-generator` | -### Optional ### + -| Name | Purpose | Default | + ## Secrets ## From 2f60a6eff091bf370f8d0121ee378cf60fcfd7c2 Mon Sep 17 00:00:00 2001 From: ameliav Date: Mon, 25 Oct 2021 15:05:56 -0400 Subject: [PATCH 10/73] Add volume path to Dockerfile --- Dockerfile | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2f3a826..4e64f55 100644 --- a/Dockerfile +++ b/Dockerfile @@ -25,16 +25,12 @@ ENV ECHO_MESSAGE="Hello World from Dockerfile" RUN addgroup --system --gid ${CISA_UID} cisa \ && adduser --system --uid ${CISA_UID} --ingroup cisa cisa -# RUN apk --update --no-cache add \ -# ca-certificates \ -# openssl \ -# py-pip - RUN apt-get install wget RUN apt-get update && \ apt-get install --no-install-recommends -y texlive texlive-xetex texlive-bibtex-extra +VOLUME $CISA_HOME WORKDIR $PCA_REPORT_TOOLS_SRC RUN wget -O sourcecode.tgz https://github.com/cisagov/pca-report-library/archive/v${VERSION}.tar.gz && \ @@ -51,8 +47,3 @@ RUN ln -snf ${PCA_REPORT_TOOLS_SRC}/var/getenv /usr/local/bin USER cisa WORKDIR $CISA_HOME CMD ["getenv"] - -# EXPOSE 8080/TCP -# VOLUME ["/var/log"] -# ENTRYPOINT ["example"] -# CMD ["--log-level", "DEBUG"] From 7eb548c413afa7ca0854fb1f7e56651f4d2ebed0 Mon Sep 17 00:00:00 2001 From: ameliav Date: Mon, 25 Oct 2021 15:06:20 -0400 Subject: [PATCH 11/73] Remove unneeded sections from README.md --- README.md | 31 +++++++------------------------ 1 file changed, 7 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 486e300..2810c78 100644 --- a/README.md +++ b/README.md @@ -154,6 +154,7 @@ environment variables. See the 1. Recreate and run the container by following the [previous instructions](#running-with-docker). + ## Volumes ## | Mount point | Purpose | |-------------|----------------| -| `/var/log` | Log storage | +| `/home/cisa` | Log storage | ## Environment variables ## @@ -199,18 +200,7 @@ Hub for a list of all the supported tags. |--------------|---------| | `quote.txt` | Replaces the secret stored in the example library's package data. | -## Building from source ## - -Build the image locally using this git repository as the [build context](https://docs.docker.com/engine/reference/commandline/build/#git-repositories): - -```console -docker build \ - --build-arg VERSION=0.0.1 \ - --tag cisagov/example:0.0.1 \ - https://github.com/cisagov/example.git#develop -``` - -## Cross-platform builds ## + ## Contributing ## From 35aade24c1e551f817b9f4782071f90c62257552 Mon Sep 17 00:00:00 2001 From: ameliav Date: Wed, 27 Oct 2021 10:51:46 -0400 Subject: [PATCH 12/73] Update container name in docker-compose.yml --- docker-compose.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index aea6bcc..10f0e26 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,14 +8,14 @@ secrets: file: ./src/secrets/quote.txt services: - example: + pca-report-library: # Run the container normally build: # VERSION must be specified on the command line: # e.g., --build-arg VERSION=0.0.1 context: . dockerfile: Dockerfile - image: cisagov/example + image: cisagov/pca-report-library init: true restart: "no" environment: @@ -24,9 +24,9 @@ services: - source: quote_txt target: quote.txt - example-version: + pca-report-library-version: # Run the container to collect version information - image: cisagov/example + image: cisagov/pca-report-library init: true restart: "no" command: --version From 0ce564c203446bf56406e977de1885282a1b7d02 Mon Sep 17 00:00:00 2001 From: ameliav Date: Wed, 27 Oct 2021 10:54:02 -0400 Subject: [PATCH 13/73] Update wait_for_ready and output tests --- tests/container_test.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/tests/container_test.py b/tests/container_test.py index 6153028..ff222d8 100644 --- a/tests/container_test.py +++ b/tests/container_test.py @@ -14,6 +14,9 @@ SECRET_QUOTE = ( "There are no secrets better kept than the secrets everybody guesses." # nosec ) +PCA_GENERATOR_QUOTE = ( + '# PCA_GENERATOR_IMAGE, defaults to "cisagov/pca-report-generator" if not set' +) RELEASE_TAG = os.getenv("RELEASE_TAG") VERSION_FILE = "src/version.txt" @@ -28,21 +31,21 @@ def test_container_count(dockerc): def test_wait_for_ready(main_container): """Wait for container to be ready.""" - TIMEOUT = 10 + TIMEOUT = 110 for i in range(TIMEOUT): - if READY_MESSAGE in main_container.logs().decode("utf-8"): + if PCA_GENERATOR_QUOTE in main_container.logs().decode("utf-8"): break time.sleep(1) else: raise Exception( f"Container does not seem ready. " - f'Expected "{READY_MESSAGE}" in the log within {TIMEOUT} seconds.' + f'Expected "{PCA_GENERATOR_QUOTE}" in the log within {TIMEOUT} seconds.' ) def test_wait_for_exits(main_container, version_container): """Wait for containers to exit.""" - assert main_container.wait() == 0, "Container service (main) did not exit cleanly" + assert main_container.wait() == 127, "Container service (main) did not exit cleanly" assert ( version_container.wait() == 0 ), "Container service (version) did not exit cleanly" @@ -52,7 +55,9 @@ def test_output(main_container): """Verify the container had the correct output.""" main_container.wait() # make sure container exited if running test isolated log_output = main_container.logs().decode("utf-8") - assert SECRET_QUOTE in log_output, "Secret not found in log output." + assert ( + PCA_GENERATOR_QUOTE in log_output + ), "PCA_GENERATOR_IMAGE quote not found in log output." @pytest.mark.skipif( From 15277210ac7b6ef7fbb9a2da3dccbb6110f1143c Mon Sep 17 00:00:00 2001 From: ameliav Date: Fri, 29 Oct 2021 10:40:36 -0400 Subject: [PATCH 14/73] Fix back container error code in container_test.py --- tests/container_test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/container_test.py b/tests/container_test.py index ff222d8..3071947 100644 --- a/tests/container_test.py +++ b/tests/container_test.py @@ -1,5 +1,5 @@ #!/usr/bin/env pytest -vs -"""Tests for example container.""" +"""Tests for pca-report-library container.""" # Standard Python Libraries import os @@ -45,7 +45,7 @@ def test_wait_for_ready(main_container): def test_wait_for_exits(main_container, version_container): """Wait for containers to exit.""" - assert main_container.wait() == 127, "Container service (main) did not exit cleanly" + assert main_container.wait() == 0, "Container service (main) did not exit cleanly" assert ( version_container.wait() == 0 ), "Container service (version) did not exit cleanly" From 8eb36c5938030d4f917a4e6f7df681ae4a60e60a Mon Sep 17 00:00:00 2001 From: ameliav Date: Fri, 29 Oct 2021 10:43:49 -0400 Subject: [PATCH 15/73] Update version label key in container_test.py --- tests/container_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/container_test.py b/tests/container_test.py index 3071947..06edebb 100644 --- a/tests/container_test.py +++ b/tests/container_test.py @@ -94,5 +94,5 @@ def test_container_version_label_matches(version_container): exec(f.read(), pkg_vars) # nosec project_version = pkg_vars["__version__"] assert ( - version_container.labels["org.opencontainers.image.version"] == project_version + version_container.labels["version"] == project_version ), "Dockerfile version label does not match project version" From f6a68ff75885d71b02445d3a6c1427fdef919c28 Mon Sep 17 00:00:00 2001 From: ameliav Date: Fri, 29 Oct 2021 10:45:13 -0400 Subject: [PATCH 16/73] Update MAIN_SERVICE_NAME in conftest.py --- tests/conftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/conftest.py b/tests/conftest.py index 90938e6..490300c 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -5,7 +5,7 @@ # Third-Party Libraries import pytest -MAIN_SERVICE_NAME = "example" +MAIN_SERVICE_NAME = "pca-report-library" VERSION_SERVICE_NAME = f"{MAIN_SERVICE_NAME}-version" From c62293b6d3b98ff53736c90e876b8e9b3fa2d9da Mon Sep 17 00:00:00 2001 From: ameliav Date: Fri, 29 Oct 2021 10:48:30 -0400 Subject: [PATCH 17/73] Add copying over version.txt in Dockerfile --- Dockerfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Dockerfile b/Dockerfile index 4e64f55..57d5558 100644 --- a/Dockerfile +++ b/Dockerfile @@ -31,6 +31,9 @@ RUN apt-get update && \ apt-get install --no-install-recommends -y texlive texlive-xetex texlive-bibtex-extra VOLUME $CISA_HOME + +COPY src/version.txt /src + WORKDIR $PCA_REPORT_TOOLS_SRC RUN wget -O sourcecode.tgz https://github.com/cisagov/pca-report-library/archive/v${VERSION}.tar.gz && \ From 825d6e1735ff2b428383a996271f853cd576209c Mon Sep 17 00:00:00 2001 From: ameliav Date: Fri, 29 Oct 2021 10:53:26 -0400 Subject: [PATCH 18/73] Update service command in docker-compose.yml The --version command came from skeleton-python-library and will not work anymore. The updated command comes from pca-report-library and will work. --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 10f0e26..5a2af5c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -29,4 +29,4 @@ services: image: cisagov/pca-report-library init: true restart: "no" - command: --version + command: pca-report-generator --version From d723194b36cc4f411aa972c04b5fdf9bad1de887 Mon Sep 17 00:00:00 2001 From: ameliav Date: Fri, 29 Oct 2021 13:29:49 -0400 Subject: [PATCH 19/73] Update the docker compose section of README.md --- README.md | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 2810c78..819e928 100644 --- a/README.md +++ b/README.md @@ -60,18 +60,14 @@ docker run --rm -it --entrypoint bash cisagov/pca-report-generator version: "3.7" services: - example: - image: cisagov/example:0.0.1 + pca-report-library: + image: cisagov/pca-report-library volumes: - type: bind source: - target: /var/log + target: /home/cisa environment: - ECHO_MESSAGE="Hello from docker-compose" - ports: - - target: 8080 - published: 8080 - protocol: tcp ``` 1. Start the container and detach: @@ -105,18 +101,14 @@ environment variables. See the file: quote.txt services: - example: - image: cisagov/example:0.0.1 + pca-report-library: + image: cisagov/pca-report-library volumes: - type: bind source: - target: /var/log + target: /home/cisa environment: - ECHO_MESSAGE="Hello from docker-compose" - ports: - - target: 8080 - published: 8080 - protocol: tcp secrets: - source: quote_txt target: quote.txt @@ -149,7 +141,7 @@ environment variables. See the 1. Pull the new image: ```console - docker pull cisagov/example:0.0.1 + docker pull cisagov/pca-report-library ``` 1. Recreate and run the container by following the [previous instructions](#running-with-docker). From b650f7849bac99033691f33e85f20ad077ebb154 Mon Sep 17 00:00:00 2001 From: ameliav Date: Fri, 5 Nov 2021 10:06:49 -0400 Subject: [PATCH 20/73] Re-add platforms to build.yml --- .github/workflows/build.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6cca1ac..15541fc 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -29,6 +29,8 @@ env: CURL_CACHE_DIR: ~/.cache/curl IMAGE_NAME: cisagov/pca-report-library PIP_CACHE_DIR: ~/.cache/pip + PLATFORMS: "linux/amd64,linux/arm/v6,linux/arm/v7,\ + linux/arm64,linux/ppc64le,linux/s390x" PRE_COMMIT_CACHE_DIR: ~/.cache/pre-commit RUN_TMATE: ${{ secrets.RUN_TMATE }} From d45b1c1a3e524be9d69818541ed07c9fec4726f2 Mon Sep 17 00:00:00 2001 From: Amelia V Date: Fri, 5 Nov 2021 10:14:43 -0400 Subject: [PATCH 21/73] Add braces to PCA_REPORT_TOOLS_SRC in Dockerfile Co-authored-by: dav3r --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 57d5558..4c95cf6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -34,7 +34,7 @@ VOLUME $CISA_HOME COPY src/version.txt /src -WORKDIR $PCA_REPORT_TOOLS_SRC +WORKDIR ${PCA_REPORT_TOOLS_SRC} RUN wget -O sourcecode.tgz https://github.com/cisagov/pca-report-library/archive/v${VERSION}.tar.gz && \ tar xzf sourcecode.tgz --strip-components=1 && \ From 203074051d99fe49064fb69cd03631f1be69d4f6 Mon Sep 17 00:00:00 2001 From: Amelia V Date: Fri, 5 Nov 2021 10:15:27 -0400 Subject: [PATCH 22/73] Add braces to CISA_HOME in Dockerfile Co-authored-by: dav3r --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 4c95cf6..7d15b96 100644 --- a/Dockerfile +++ b/Dockerfile @@ -48,5 +48,5 @@ RUN chmod +x ${PCA_REPORT_TOOLS_SRC}/var/getenv RUN ln -snf ${PCA_REPORT_TOOLS_SRC}/var/getenv /usr/local/bin USER cisa -WORKDIR $CISA_HOME +WORKDIR ${CISA_HOME} CMD ["getenv"] From b2ce069062bdc1482211fe9c58e905432d766231 Mon Sep 17 00:00:00 2001 From: Amelia V Date: Fri, 5 Nov 2021 10:33:39 -0400 Subject: [PATCH 23/73] Capitalize the word Docker in README Co-authored-by: dav3r --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 819e928..daf6562 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ The package is used for generating PCA reports with LaTeX and supporting scripts ## Running ## -The following docker commands are available. +The following Docker commands are available. An alias can also be set beforehand to remove redundancy. From c8f5a553f801b82f969e23e21a821e1b620a2268 Mon Sep 17 00:00:00 2001 From: Amelia V Date: Fri, 5 Nov 2021 10:35:43 -0400 Subject: [PATCH 24/73] Simplify pca-report-generator summary in README Co-authored-by: dav3r --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index daf6562..49296b6 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ The following Docker commands are available. An alias can also be set beforehand to remove redundancy. -`pca-report-generator` - Builds PCA LaTeX report and complies the PDF +`pca-report-generator` - Creates a PCA report as a PDF ```console docker run -v $(pwd):/home/cisa cisagov/pca-report-generator pca-report-generator From 4764d7de30f03709f70242649a619e0ba3d19d63 Mon Sep 17 00:00:00 2001 From: Amelia V Date: Fri, 5 Nov 2021 10:40:22 -0400 Subject: [PATCH 25/73] Update pca-report-generator-bash summary in README Co-authored-by: dav3r --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 49296b6..f0bfc94 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ docker run -v $(pwd):/home/cisa cisagov/pca-report-generator pca-report-template docker run -v $(pwd):/home/cisa cisagov/pca-report-generator pca-report-compiler ``` -`pca-report-generator-bash` - Will SSH into the container +`pca-report-generator-bash` - Starts up a `bash` shell in the container ```console docker run -v $(pwd):/home/cisa cisagov/pca-report-generator pca-report-generator-bash From f85cb89b4fefaba8c913a26f9b87dabcf41d111b Mon Sep 17 00:00:00 2001 From: Amelia V Date: Fri, 5 Nov 2021 10:47:07 -0400 Subject: [PATCH 26/73] Add version tag to image in docker-compose Co-authored-by: dav3r --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 5a2af5c..5935eac 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -26,7 +26,7 @@ services: pca-report-library-version: # Run the container to collect version information - image: cisagov/pca-report-library + image: cisagov/pca-report-library:0.0.1 init: true restart: "no" command: pca-report-generator --version From fc03e8ea0a540075037b656190488b13fc6c1070 Mon Sep 17 00:00:00 2001 From: Amelia V Date: Fri, 5 Nov 2021 10:48:14 -0400 Subject: [PATCH 27/73] Add version tag to image in docker-compose Co-authored-by: dav3r --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 5935eac..6538469 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -15,7 +15,7 @@ services: # e.g., --build-arg VERSION=0.0.1 context: . dockerfile: Dockerfile - image: cisagov/pca-report-library + image: cisagov/pca-report-library:0.0.1 init: true restart: "no" environment: From dad82c5e802f033a3adac98c0c0794f10ef34dab Mon Sep 17 00:00:00 2001 From: Amelia V Date: Fri, 5 Nov 2021 10:55:53 -0400 Subject: [PATCH 28/73] Uncomment buildx statement in README Co-authored-by: dav3r --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f0bfc94..5f93e5a 100644 --- a/README.md +++ b/README.md @@ -212,7 +212,7 @@ Docker: ./buildx-dockerfile.sh ``` -3. Build the image using `buildx`: +1. Build the image using `buildx`: ```console docker buildx build \ From 307f24c123fcc4de008513f16de706d030f22348 Mon Sep 17 00:00:00 2001 From: Amelia V Date: Fri, 5 Nov 2021 11:03:12 -0400 Subject: [PATCH 29/73] Update numbering item in README Co-authored-by: dav3r --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5f93e5a..e70fc0c 100644 --- a/README.md +++ b/README.md @@ -206,7 +206,7 @@ Docker: cd example ``` -2. Create the `Dockerfile-x` file with `buildx` platform support: +1. Create the `Dockerfile-x` file with `buildx` platform support: ```console ./buildx-dockerfile.sh From 8b4a5abc55298ecc0e340b8748a6db296c84a0ee Mon Sep 17 00:00:00 2001 From: Amelia V Date: Fri, 5 Nov 2021 11:06:03 -0400 Subject: [PATCH 30/73] Add image version tag to README Co-authored-by: dav3r --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e70fc0c..a03239b 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ docker run --rm -it --entrypoint bash cisagov/pca-report-generator services: pca-report-library: - image: cisagov/pca-report-library + image: cisagov/pca-report-library:0.0.1 volumes: - type: bind source: From 598aceef591cfd34045b8d82f810e36563a5925d Mon Sep 17 00:00:00 2001 From: ameliav Date: Fri, 5 Nov 2021 12:05:24 -0400 Subject: [PATCH 31/73] Re-add and update sections into the README Includes sections Building from Source and Cross-platform builds --- README.md | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index a03239b..e395702 100644 --- a/README.md +++ b/README.md @@ -192,7 +192,18 @@ Hub for a list of all the supported tags. --> |--------------|---------| | `quote.txt` | Replaces the secret stored in the example library's package data. | - + --tag cisagov/pca-report-library:0.0.1 . + ``` ## Contributing ## From af48f3c00e040fb612385423b6173f40e7c5ad8b Mon Sep 17 00:00:00 2001 From: ameliav Date: Fri, 5 Nov 2021 12:08:37 -0400 Subject: [PATCH 32/73] Uncomment optional environment variable in README --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e395702..6e760f5 100644 --- a/README.md +++ b/README.md @@ -180,11 +180,11 @@ Hub for a list of all the supported tags. --> |-------|---------|---------| | `PCA_GENERATOR_IMAGE` | Docker image name. | `cisagov/pca-report-generator` | - +### Optional ### - +| `ECHO_MESSAGE` | Sets the message echoed by this container. | `Hello World from Dockerfile` | ## Secrets ## From ea18e214736be0c31a4e7e018469040e6686c693 Mon Sep 17 00:00:00 2001 From: ameliav Date: Fri, 5 Nov 2021 13:06:00 -0400 Subject: [PATCH 33/73] Update docker environment variables in README --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6e760f5..f3ef25f 100644 --- a/README.md +++ b/README.md @@ -174,17 +174,19 @@ Hub for a list of all the supported tags. --> ## Environment variables ## -### Required ### + ### Optional ### | Name | Purpose | Default | |-------|---------|---------| | `ECHO_MESSAGE` | Sets the message echoed by this container. | `Hello World from Dockerfile` | +| `PCA_REPORT_TOOLS_SRC` | Set as the directory for the pca-report-library codebase. | `/usr/src/pca-report-tools` | +| `CISA_HOME` | Sets up as the working directory. | `/home/cisa` | ## Secrets ## From a8f6a047fab36bbac8ac4c297326e9c7f23f8853 Mon Sep 17 00:00:00 2001 From: ameliav Date: Fri, 5 Nov 2021 13:22:16 -0400 Subject: [PATCH 34/73] Re-add ports section in README --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.md b/README.md index f3ef25f..4947ee9 100644 --- a/README.md +++ b/README.md @@ -172,6 +172,21 @@ Hub for a list of all the supported tags. --> |-------------|----------------| | `/home/cisa` | Log storage | +## Ports ## + +There are no ports exposed by this container. + + + ## Environment variables ## +Hub for a list of all the supported tags. ## Volumes ## From 079d2e99a39f5bf533291dda19e76197a3f48fba Mon Sep 17 00:00:00 2001 From: Amelia V Date: Fri, 5 Nov 2021 13:56:20 -0400 Subject: [PATCH 37/73] Uncomment top of image tags section in README Co-authored-by: dav3r --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 91c42f2..acdc685 100644 --- a/README.md +++ b/README.md @@ -146,7 +146,6 @@ environment variables. See the 1. Recreate and run the container by following the [previous instructions](#running-with-docker). - ## Updating your container ## From 3095f9ce3fdc1908a7b7085936b3d47a8d0a6eb1 Mon Sep 17 00:00:00 2001 From: ameliav Date: Mon, 8 Nov 2021 12:49:43 -0500 Subject: [PATCH 43/73] Remove unneeded volume creation in Dockerfile --- Dockerfile | 2 -- 1 file changed, 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7d15b96..757e921 100644 --- a/Dockerfile +++ b/Dockerfile @@ -30,8 +30,6 @@ RUN apt-get install wget RUN apt-get update && \ apt-get install --no-install-recommends -y texlive texlive-xetex texlive-bibtex-extra -VOLUME $CISA_HOME - COPY src/version.txt /src WORKDIR ${PCA_REPORT_TOOLS_SRC} From f8c135f56bb2837155838b04234e0119e9e95a08 Mon Sep 17 00:00:00 2001 From: ameliav Date: Mon, 8 Nov 2021 12:54:38 -0500 Subject: [PATCH 44/73] Comment out volumes section in README --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3ca103c..e140346 100644 --- a/README.md +++ b/README.md @@ -161,9 +161,10 @@ Hub for a list of all the supported tags. ## Volumes ## -| Mount point | Purpose | +There are no volumes for this container. + ## Ports ## From c15795b18e4337758b108e73d9213e84d30e4ba6 Mon Sep 17 00:00:00 2001 From: ameliav Date: Mon, 8 Nov 2021 13:00:37 -0500 Subject: [PATCH 45/73] Remove using secrets with your container in README --- README.md | 39 --------------------------------------- 1 file changed, 39 deletions(-) diff --git a/README.md b/README.md index e140346..c825c71 100644 --- a/README.md +++ b/README.md @@ -69,45 +69,6 @@ docker run -v $(pwd):/home/cisa cisagov/pca-report-generator pca-report-generato docker-compose up --detach ``` -## Using secrets with your container ## - -There are no secrets for this container. - - ## Updating your container ## ### Docker Compose ### From 1be4e84a682aa5cb61a1c632639ddb7a9ff853e3 Mon Sep 17 00:00:00 2001 From: ameliav Date: Mon, 8 Nov 2021 13:01:25 -0500 Subject: [PATCH 46/73] Comment out secrets section in README --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c825c71..cbd3df5 100644 --- a/README.md +++ b/README.md @@ -160,9 +160,10 @@ exposed port at 8080. ## Secrets ## -| Filename | Purpose | +There are no secrets for this container. + ## Building from source ## From 9d72a511914bb540271b4b8bf089a6e256ee72ce Mon Sep 17 00:00:00 2001 From: ameliav Date: Mon, 8 Nov 2021 13:55:33 -0500 Subject: [PATCH 47/73] Remove unused secrets quote from container_test.py --- tests/container_test.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/container_test.py b/tests/container_test.py index 06edebb..427bb57 100644 --- a/tests/container_test.py +++ b/tests/container_test.py @@ -11,9 +11,6 @@ ENV_VAR = "ECHO_MESSAGE" ENV_VAR_VAL = "Hello World from docker-compose!" READY_MESSAGE = "This is a debug message" -SECRET_QUOTE = ( - "There are no secrets better kept than the secrets everybody guesses." # nosec -) PCA_GENERATOR_QUOTE = ( '# PCA_GENERATOR_IMAGE, defaults to "cisagov/pca-report-generator" if not set' ) From cf1db9193e008473337e796b1fc0a4359b6a2deb Mon Sep 17 00:00:00 2001 From: Amelia V Date: Mon, 8 Nov 2021 13:56:26 -0500 Subject: [PATCH 48/73] Remove git_commit labels from Dockerfile Co-authored-by: dav3r --- Dockerfile | 2 -- 1 file changed, 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 757e921..cf795f1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,8 +11,6 @@ ARG VERSION # 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 git_commit=$GIT_COMMIT -LABEL git_remote=$GIT_REMOTE LABEL org.opencontainers.image.authors="mark.feldhousen@cisa.dhs.gov" LABEL org.opencontainers.image.vendor="Cybersecurity and Infrastructure Security Agency" LABEL version=$VERSION From b7a940d283616f8dcb11cc333df89e426634bac9 Mon Sep 17 00:00:00 2001 From: Amelia V Date: Mon, 8 Nov 2021 13:57:26 -0500 Subject: [PATCH 49/73] Remove version label in Dockerfile Co-authored-by: dav3r --- Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index cf795f1..e5b4c0d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,7 +13,6 @@ ARG VERSION # Note: Additional labels are added by the build workflow. LABEL org.opencontainers.image.authors="mark.feldhousen@cisa.dhs.gov" LABEL org.opencontainers.image.vendor="Cybersecurity and Infrastructure Security Agency" -LABEL version=$VERSION ARG CISA_UID=421 ENV CISA_HOME="/home/cisa" From 2f9cd7a7f6c342ac32ee142fc5e9f1b75ccb076b Mon Sep 17 00:00:00 2001 From: Amelia V Date: Mon, 8 Nov 2021 13:58:45 -0500 Subject: [PATCH 50/73] Remove GIT ARGs from Dockerfile Co-authored-by: dav3r --- Dockerfile | 2 -- 1 file changed, 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index e5b4c0d..fa2b1fa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,8 +4,6 @@ ARG VERSION=0.0.1 FROM python:3.9.6 -ARG GIT_COMMIT -ARG GIT_REMOTE ARG VERSION # For a list of pre-defined annotation keys and value types see: From c71829403f5059c22f6cb77cd6b92853e8d8bc32 Mon Sep 17 00:00:00 2001 From: Amelia V Date: Tue, 9 Nov 2021 09:19:00 -0500 Subject: [PATCH 51/73] Update version key in container_test.py Co-authored-by: dav3r --- tests/container_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/container_test.py b/tests/container_test.py index 427bb57..776c5c6 100644 --- a/tests/container_test.py +++ b/tests/container_test.py @@ -91,5 +91,5 @@ def test_container_version_label_matches(version_container): exec(f.read(), pkg_vars) # nosec project_version = pkg_vars["__version__"] assert ( - version_container.labels["version"] == project_version + version_container.labels["org.opencontainers.image.version"] == project_version ), "Dockerfile version label does not match project version" From 7286a3c3f81e91deb0e8bd62fed8addf3a51d113 Mon Sep 17 00:00:00 2001 From: Amelia V Date: Wed, 10 Nov 2021 10:18:25 -0500 Subject: [PATCH 52/73] Remove GIT ARGS from Dockerfile Co-authored-by: dav3r --- Dockerfile | 2 -- 1 file changed, 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index fa2b1fa..d4edb1e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,3 @@ -ARG GIT_COMMIT=unspecified -ARG GIT_REMOTE=unspecified ARG VERSION=0.0.1 FROM python:3.9.6 From 4d038c2f7b9eab871cc0906b28694563547d5a7c Mon Sep 17 00:00:00 2001 From: ameliav Date: Wed, 10 Nov 2021 10:28:58 -0500 Subject: [PATCH 53/73] Alphabetize env variables in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cbd3df5..c1e488d 100644 --- a/README.md +++ b/README.md @@ -154,9 +154,9 @@ exposed port at 8080. | Name | Purpose | Default | |-------|---------|---------| +| `CISA_HOME` | Sets up as the working directory. | `/home/cisa` | | `ECHO_MESSAGE` | Sets the message echoed by this container. | `Hello World from Dockerfile` | | `PCA_REPORT_TOOLS_SRC` | Set as the directory for the pca-report-library codebase. | `/usr/src/pca-report-tools` | -| `CISA_HOME` | Sets up as the working directory. | `/home/cisa` | ## Secrets ## From cfb0e9575e66f374c296d34bfbc2a7ff4beb6db5 Mon Sep 17 00:00:00 2001 From: Amelia V Date: Wed, 10 Nov 2021 16:46:34 -0500 Subject: [PATCH 54/73] Update version to unspecified in Dockerfile Co-authored-by: dav3r --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index d4edb1e..231e1bd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -ARG VERSION=0.0.1 +ARG VERSION=unspecified FROM python:3.9.6 From 642ef1154b49013fc69e2514dcfe136c12782d29 Mon Sep 17 00:00:00 2001 From: ameliav Date: Wed, 10 Nov 2021 16:55:55 -0500 Subject: [PATCH 55/73] Remove versions on the images in docker-compose --- docker-compose.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 0b456a1..8ba66a0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -15,7 +15,7 @@ services: # e.g., --build-arg VERSION=0.0.1 context: . dockerfile: Dockerfile - image: cisagov/pca-report-library:0.0.1 + image: cisagov/pca-report-library init: true restart: "no" environment: @@ -23,7 +23,7 @@ services: pca-report-library-version: # Run the container to collect version information - image: cisagov/pca-report-library:0.0.1 + image: cisagov/pca-report-library init: true restart: "no" command: pca-report-generator --version From b4f38daf8fd9b8a49771e281ca902cee00fdbe0d Mon Sep 17 00:00:00 2001 From: ameliav Date: Fri, 12 Nov 2021 15:04:03 -0500 Subject: [PATCH 56/73] Remove all instances of ECHO_MESSAGE env variable --- README.md | 3 --- docker-compose.yml | 2 -- tests/container_test.py | 1 - 3 files changed, 6 deletions(-) diff --git a/README.md b/README.md index c1e488d..a22aade 100644 --- a/README.md +++ b/README.md @@ -59,8 +59,6 @@ docker run -v $(pwd):/home/cisa cisagov/pca-report-generator pca-report-generato - type: bind source: target: /home/cisa - environment: - - ECHO_MESSAGE="Hello from docker-compose" ``` 1. Start the container and detach: @@ -155,7 +153,6 @@ exposed port at 8080. | Name | Purpose | Default | |-------|---------|---------| | `CISA_HOME` | Sets up as the working directory. | `/home/cisa` | -| `ECHO_MESSAGE` | Sets the message echoed by this container. | `Hello World from Dockerfile` | | `PCA_REPORT_TOOLS_SRC` | Set as the directory for the pca-report-library codebase. | `/usr/src/pca-report-tools` | ## Secrets ## diff --git a/docker-compose.yml b/docker-compose.yml index 8ba66a0..743234f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -18,8 +18,6 @@ services: image: cisagov/pca-report-library init: true restart: "no" - environment: - - ECHO_MESSAGE=Hello World from docker-compose! pca-report-library-version: # Run the container to collect version information diff --git a/tests/container_test.py b/tests/container_test.py index 776c5c6..1e02e16 100644 --- a/tests/container_test.py +++ b/tests/container_test.py @@ -8,7 +8,6 @@ # Third-Party Libraries import pytest -ENV_VAR = "ECHO_MESSAGE" ENV_VAR_VAL = "Hello World from docker-compose!" READY_MESSAGE = "This is a debug message" PCA_GENERATOR_QUOTE = ( From c56cbe2147f5fb97242a87075b56fbd7c15129da Mon Sep 17 00:00:00 2001 From: ameliav Date: Mon, 15 Nov 2021 12:18:56 -0500 Subject: [PATCH 57/73] Remove unused variables from container_test.py --- tests/container_test.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/container_test.py b/tests/container_test.py index 1e02e16..e200415 100644 --- a/tests/container_test.py +++ b/tests/container_test.py @@ -8,8 +8,6 @@ # Third-Party Libraries import pytest -ENV_VAR_VAL = "Hello World from docker-compose!" -READY_MESSAGE = "This is a debug message" PCA_GENERATOR_QUOTE = ( '# PCA_GENERATOR_IMAGE, defaults to "cisagov/pca-report-generator" if not set' ) From ebc31822cf39304fed84fa7b0e3ecbe8777a113c Mon Sep 17 00:00:00 2001 From: ameliav Date: Mon, 15 Nov 2021 15:30:51 -0500 Subject: [PATCH 58/73] Consolidate and update RUN commands in Dockerfile --- Dockerfile | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index 231e1bd..fe06f8f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,10 +18,8 @@ ENV ECHO_MESSAGE="Hello World from Dockerfile" RUN addgroup --system --gid ${CISA_UID} cisa \ && adduser --system --uid ${CISA_UID} --ingroup cisa cisa -RUN apt-get install wget - RUN apt-get update && \ - apt-get install --no-install-recommends -y texlive texlive-xetex texlive-bibtex-extra + apt-get install --no-install-recommends -y texlive texlive-bibtex-extra texlive-xetex wget COPY src/version.txt /src @@ -29,15 +27,13 @@ WORKDIR ${PCA_REPORT_TOOLS_SRC} RUN wget -O sourcecode.tgz https://github.com/cisagov/pca-report-library/archive/v${VERSION}.tar.gz && \ tar xzf sourcecode.tgz --strip-components=1 && \ + pip install --requirement requirements.txt && \ cp -r src/pca_report_library/assets/fonts /usr/share/fonts/truetype/ncats && \ + fc-cache -fsv && \ + chmod +x ${PCA_REPORT_TOOLS_SRC}/var/getenv && \ + ln -snf ${PCA_REPORT_TOOLS_SRC}/var/getenv /usr/local/bin && \ rm sourcecode.tgz -RUN fc-cache -fsv - -RUN pip install --no-cache-dir . -RUN chmod +x ${PCA_REPORT_TOOLS_SRC}/var/getenv -RUN ln -snf ${PCA_REPORT_TOOLS_SRC}/var/getenv /usr/local/bin - USER cisa WORKDIR ${CISA_HOME} CMD ["getenv"] From a9e9a3efd87bba7b8f0f0ace6a2e6b8db23bf856 Mon Sep 17 00:00:00 2001 From: ameliav Date: Mon, 15 Nov 2021 15:32:29 -0500 Subject: [PATCH 59/73] Update var to PCA_REPORT_LIBRARY_SRC in Dockerfile --- Dockerfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index fe06f8f..02686c6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,7 +12,7 @@ LABEL org.opencontainers.image.vendor="Cybersecurity and Infrastructure Security ARG CISA_UID=421 ENV CISA_HOME="/home/cisa" -ENV PCA_REPORT_TOOLS_SRC="/usr/src/pca-report-tools" +ENV PCA_REPORT_LIBRARY_SRC="/usr/src/pca-report-tools" ENV ECHO_MESSAGE="Hello World from Dockerfile" RUN addgroup --system --gid ${CISA_UID} cisa \ @@ -23,15 +23,15 @@ RUN apt-get update && \ COPY src/version.txt /src -WORKDIR ${PCA_REPORT_TOOLS_SRC} +WORKDIR ${PCA_REPORT_LIBRARY_SRC} RUN wget -O sourcecode.tgz https://github.com/cisagov/pca-report-library/archive/v${VERSION}.tar.gz && \ tar xzf sourcecode.tgz --strip-components=1 && \ pip install --requirement requirements.txt && \ cp -r src/pca_report_library/assets/fonts /usr/share/fonts/truetype/ncats && \ fc-cache -fsv && \ - chmod +x ${PCA_REPORT_TOOLS_SRC}/var/getenv && \ - ln -snf ${PCA_REPORT_TOOLS_SRC}/var/getenv /usr/local/bin && \ + chmod +x ${PCA_REPORT_LIBRARY_SRC}/var/getenv && \ + ln -snf ${PCA_REPORT_LIBRARY_SRC}/var/getenv /usr/local/bin && \ rm sourcecode.tgz USER cisa From eb3bd0c69a710a7be49e2b3a1bae4fe71d9bc78f Mon Sep 17 00:00:00 2001 From: ameliav Date: Mon, 15 Nov 2021 16:22:49 -0500 Subject: [PATCH 60/73] Add TODO about updating to Alpine in Dockerfile --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 02686c6..3a70116 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,6 @@ ARG VERSION=unspecified - +# TODO: Update Ubuntu to Alpine with working Python package installations +# Issue: https://github.com/cisagov/pca-report-generator-docker/issues/11 FROM python:3.9.6 ARG VERSION From 02a0524e945c56c0ec3c8709f9924fa56826aeb0 Mon Sep 17 00:00:00 2001 From: ameliav Date: Tue, 16 Nov 2021 11:15:00 -0500 Subject: [PATCH 61/73] Update TODO with python:3.9.6 image in Dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 3a70116..266439e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ ARG VERSION=unspecified -# TODO: Update Ubuntu to Alpine with working Python package installations +# TODO: Update python:3.9.6 image to include Alpine with working Python package installations # Issue: https://github.com/cisagov/pca-report-generator-docker/issues/11 FROM python:3.9.6 From 64810e12fd374547bf00eb4097b90362842bdb05 Mon Sep 17 00:00:00 2001 From: Amelia V Date: Tue, 16 Nov 2021 11:25:35 -0500 Subject: [PATCH 62/73] Update TODO wording in Dockerfile Co-authored-by: dav3r --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 266439e..f1daa78 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,6 @@ ARG VERSION=unspecified -# TODO: Update python:3.9.6 image to include Alpine with working Python package installations +# TODO: Switch base Docker image from python:3.9.6 to a current +# alpine image (e.g. python:3.10.0-alpine) # Issue: https://github.com/cisagov/pca-report-generator-docker/issues/11 FROM python:3.9.6 From 19beb678837f4ef999bc99c2e5ccc3d4b000ee57 Mon Sep 17 00:00:00 2001 From: ameliav Date: Tue, 16 Nov 2021 14:18:47 -0500 Subject: [PATCH 63/73] Add entrypoint pca-report-generator to Dockerfile --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 266439e..e00347d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -37,4 +37,5 @@ RUN wget -O sourcecode.tgz https://github.com/cisagov/pca-report-library/archive USER cisa WORKDIR ${CISA_HOME} -CMD ["getenv"] +ENTRYPOINT ["pca-report-generator"] +CMD ["--help"] From 120e86be18d2c721e228a9efcae71148b6820d03 Mon Sep 17 00:00:00 2001 From: ameliav Date: Tue, 16 Nov 2021 14:21:25 -0500 Subject: [PATCH 64/73] Update version command in docker-compose --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 743234f..1782268 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -24,4 +24,4 @@ services: image: cisagov/pca-report-library init: true restart: "no" - command: pca-report-generator --version + command: --version From 2408f6a8d93ae0b7421e2b328f817877fa92cbb4 Mon Sep 17 00:00:00 2001 From: ameliav Date: Tue, 16 Nov 2021 14:53:59 -0500 Subject: [PATCH 65/73] Update docker commands per entrypoint in README --- README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index a22aade..5f53a0a 100644 --- a/README.md +++ b/README.md @@ -19,29 +19,31 @@ The following Docker commands are available. An alias can also be set beforehand to remove redundancy. +Parameters can be added at the end. Each defaulting command prints out a help message. + `pca-report-generator` - Creates a PCA report as a PDF ```console -docker run -v $(pwd):/home/cisa cisagov/pca-report-generator pca-report-generator +docker run -v $(pwd):/home/cisa cisagov/pca-report-generator:0.0.1 ``` `pca-report-templates` - Exports the Report Mustache template and Manual data file template ```console -docker run -v $(pwd):/home/cisa cisagov/pca-report-generator pca-report-templates +docker run -v $(pwd):/home/cisa --entrypoint pca-report-templates cisagov/pca-report-library-docker:0.0.1 ``` `pca-report-compiler` - Compiles a PCA LaTeX report file, still in development. ```console -docker run -v $(pwd):/home/cisa cisagov/pca-report-generator pca-report-compiler +docker run -v $(pwd):/home/cisa --entrypoint pca-report-templates cisagov/pca-report-library-docker:0.0.1 ``` `pca-report-generator-bash` - Starts up a `bash` shell in the container ```console -docker run -v $(pwd):/home/cisa cisagov/pca-report-generator pca-report-generator-bash +docker run -v $(pwd):/home/cisa --entrypoint pca-report-generator-bash cisagov/pca-report-generator ``` ### Running with Docker Compose ### From 2cd9701418fd68663a7f9bc69960fcdb98916fce Mon Sep 17 00:00:00 2001 From: ameliav Date: Thu, 18 Nov 2021 13:09:41 -0500 Subject: [PATCH 66/73] Add TODO about updating entrypoint in Dockerfile --- Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Dockerfile b/Dockerfile index 597da45..9cab62f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -38,5 +38,7 @@ RUN wget -O sourcecode.tgz https://github.com/cisagov/pca-report-library/archive USER cisa WORKDIR ${CISA_HOME} +# TODO: Create a shell script to improve the Docker entrypoint +# Issue: https://github.com/cisagov/pca-report-generator-docker/issues/12 ENTRYPOINT ["pca-report-generator"] CMD ["--help"] From eed0469b8df2afcad8cefd5f2ac7319eb797d43b Mon Sep 17 00:00:00 2001 From: Amelia V Date: Thu, 18 Nov 2021 13:12:07 -0500 Subject: [PATCH 67/73] Imrpove explanatory text in the README Co-authored-by: dav3r --- README.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5f53a0a..1bb2d01 100644 --- a/README.md +++ b/README.md @@ -17,9 +17,15 @@ package, which can be used to generate Phishing Campaign Assessment (PCA) report The following Docker commands are available. -An alias can also be set beforehand to remove redundancy. +Use `--entrypoint` to select which command within `pca-report-library` to +execute: -Parameters can be added at the end. Each defaulting command prints out a help message. +- `pca-report-generator` (this is the default entrypoint) +- `pca-report-templates` +- `pca-report-compiler` + +If no additional parameters are supplied, help text will be output. +See below for examples: `pca-report-generator` - Creates a PCA report as a PDF From 081047bba7bd31e46d9e2023afea0026ee06ef53 Mon Sep 17 00:00:00 2001 From: Amelia V Date: Thu, 18 Nov 2021 13:12:57 -0500 Subject: [PATCH 68/73] Improve and correct docker run examples in README Co-authored-by: dav3r --- README.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 1bb2d01..aa45880 100644 --- a/README.md +++ b/README.md @@ -27,17 +27,19 @@ execute: If no additional parameters are supplied, help text will be output. See below for examples: -`pca-report-generator` - Creates a PCA report as a PDF +`pca-report-generator` - Create a PCA report as a PDF: ```console -docker run -v $(pwd):/home/cisa cisagov/pca-report-generator:0.0.1 +docker run --volume $(pwd):/home/cisa cisagov/pca-report-library:0.0.1 MY_ASSESSMENT_ID ``` -`pca-report-templates` - Exports the Report Mustache template and Manual data -file template +`pca-report-templates` - Export the PCA manual data file template or Mustache +template: ```console -docker run -v $(pwd):/home/cisa --entrypoint pca-report-templates cisagov/pca-report-library-docker:0.0.1 +docker run --volume $(pwd):/home/cisa --entrypoint pca-report-templates cisagov/pca-report-library:0.0.1 --manualData + +docker run --volume $(pwd):/home/cisa --entrypoint pca-report-templates cisagov/pca-report-library:0.0.1 --LaTeX ``` `pca-report-compiler` - Compiles a PCA LaTeX report file, still in development. From 4be502906fc3a8d163f319625b8b5e5e59c5eddf Mon Sep 17 00:00:00 2001 From: Amelia V Date: Thu, 18 Nov 2021 13:30:28 -0500 Subject: [PATCH 69/73] Improve pca-report-compiler summary text in README Co-authored-by: dav3r --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index aa45880..be88fce 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,8 @@ docker run --volume $(pwd):/home/cisa --entrypoint pca-report-templates cisagov/ docker run --volume $(pwd):/home/cisa --entrypoint pca-report-templates cisagov/pca-report-library:0.0.1 --LaTeX ``` -`pca-report-compiler` - Compiles a PCA LaTeX report file, still in development. +`pca-report-compiler` - Compile a PCA LaTeX report file (still in +development): ```console docker run -v $(pwd):/home/cisa --entrypoint pca-report-templates cisagov/pca-report-library-docker:0.0.1 From 2f7a07657234f503b08681027fb0f7ee1792a7cf Mon Sep 17 00:00:00 2001 From: Amelia V Date: Thu, 18 Nov 2021 13:35:16 -0500 Subject: [PATCH 70/73] Update docker run example in README Co-authored-by: dav3r --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index be88fce..3941e5d 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ docker run --volume $(pwd):/home/cisa --entrypoint pca-report-templates cisagov/ development): ```console -docker run -v $(pwd):/home/cisa --entrypoint pca-report-templates cisagov/pca-report-library-docker:0.0.1 +docker run --volume $(pwd):/home/cisa --entrypoint pca-report-templates cisagov/pca-report-library:0.0.1 MY_REPORT.tex ``` `pca-report-generator-bash` - Starts up a `bash` shell in the container From 8d3e8fbed02772be524066d497330c44a7dad392 Mon Sep 17 00:00:00 2001 From: Amelia V Date: Thu, 18 Nov 2021 13:55:58 -0500 Subject: [PATCH 71/73] Update command to start up bash shell in README Co-authored-by: dav3r --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3941e5d..7d17f72 100644 --- a/README.md +++ b/README.md @@ -49,10 +49,10 @@ development): docker run --volume $(pwd):/home/cisa --entrypoint pca-report-templates cisagov/pca-report-library:0.0.1 MY_REPORT.tex ``` -`pca-report-generator-bash` - Starts up a `bash` shell in the container +Start up a `bash` shell in a `pca-report-library` container: ```console -docker run -v $(pwd):/home/cisa --entrypoint pca-report-generator-bash cisagov/pca-report-generator +docker run -v $(pwd):/home/cisa --entrypoint /bin/bash --interactive --tty cisagov/pca-report-library:0.0.1 ``` ### Running with Docker Compose ### From 4df844d192c3a24da95c3b604708138823f80054 Mon Sep 17 00:00:00 2001 From: Amelia V Date: Thu, 18 Nov 2021 13:57:24 -0500 Subject: [PATCH 72/73] Correct repo name in README Co-authored-by: dav3r --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7d17f72..8629ce3 100644 --- a/README.md +++ b/README.md @@ -181,7 +181,7 @@ Build the image locally using this git repository as the [build context](https:/ docker build \ --build-arg VERSION=0.0.1 \ --tag cisagov/pca-report-library:0.0.1 \ - https://github.com/cisagov/pca-report-library.git#develop + https://github.com/cisagov/pca-report-generator-docker.git#develop ``` ## Cross-platform builds ## From a9c92b2b243445b7347bee52d577139959a00c1a Mon Sep 17 00:00:00 2001 From: Amelia V Date: Thu, 18 Nov 2021 13:58:04 -0500 Subject: [PATCH 73/73] Correct repo name in clone command in README Co-authored-by: dav3r --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8629ce3..60b7609 100644 --- a/README.md +++ b/README.md @@ -194,8 +194,8 @@ Docker: or the command line: ```console - git clone https://github.com/cisagov/pca-report-library.git - cd example + git clone https://github.com/cisagov/pca-report-generator-docker.git + cd pca-report-generator-docker ``` 1. Create the `Dockerfile-x` file with `buildx` platform support: