-
Notifications
You must be signed in to change notification settings - Fork 7
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 #7 from cisagov/improvement/docker_updates
Docker and README updates
- Loading branch information
Showing
9 changed files
with
209 additions
and
73 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1 @@ | ||
*.csv | ||
*.json | ||
*.txt | ||
.* | ||
.git* | ||
.idea | ||
__pycache__ | ||
pca_assessment/tests/data |
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,57 @@ | ||
--- | ||
name: release | ||
|
||
on: | ||
release: | ||
types: [prereleased, released] | ||
|
||
env: | ||
IMAGE_NAME: cisagov/gophish-tools | ||
DOCKER_PW: ${{ secrets.DOCKER_PW }} | ||
DOCKER_USER: ${{ secrets.DOCKER_USER }} | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-python@v1 | ||
with: | ||
python-version: 3.8 | ||
- name: Determine image version | ||
id: get_ver | ||
run: | | ||
echo "##[set-output name=version;]$(./bump_version.sh project show)" | ||
- name: Build Docker image | ||
run: | | ||
docker build \ | ||
--tag "$IMAGE_NAME" \ | ||
--build-arg GIT_COMMIT=$(git log -1 --format=%H) \ | ||
--build-arg GIT_REMOTE=$(git remote get-url origin) \ | ||
--build-arg VERSION=${{ steps.get_ver.outputs.version }} \ | ||
. | ||
- name: Tag Docker image | ||
run: | | ||
IFS='.' read -r -a version_array \ | ||
<<< "${{ steps.get_ver.outputs.version }}" | ||
docker login --username "$DOCKER_USER" --password "$DOCKER_PW" | ||
docker tag "$IMAGE_NAME" "${IMAGE_NAME}:latest" | ||
docker tag "$IMAGE_NAME" \ | ||
"${IMAGE_NAME}:${{ steps.get_ver.outputs.version }}" | ||
docker tag "$IMAGE_NAME" \ | ||
"${IMAGE_NAME}:${version_array[0]}.${version_array[1]}" | ||
docker tag "$IMAGE_NAME" "${IMAGE_NAME}:${version_array[0]}" | ||
- name: Publish image to Docker Hub | ||
run: | | ||
IFS='.' read -r -a version_array \ | ||
<<< "${{ steps.get_ver.outputs.version }}" | ||
docker push "${IMAGE_NAME}:latest" | ||
docker push "${IMAGE_NAME}:${{ steps.get_ver.outputs.version }}" | ||
docker push "${IMAGE_NAME}:${version_array[0]}.${version_array[1]}" | ||
docker push "${IMAGE_NAME}:${version_array[0]}" | ||
- name: Publish README.md to Docker Hub | ||
uses: peter-evans/dockerhub-description@v2 | ||
env: | ||
DOCKERHUB_USERNAME: ${{ secrets.DOCKER_USER }} | ||
DOCKERHUB_PASSWORD: ${{ secrets.DOCKER_PW }} | ||
DOCKERHUB_REPOSITORY: ${{ env.IMAGE_NAME }} |
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,25 +1,39 @@ | ||
FROM python:3 | ||
MAINTAINER Bryce Beuerlein <[email protected]> | ||
ENV PCA_HOME="/home/pca" \ | ||
PCA_CON_SRC="/usr/src/pca-assessment" | ||
ARG GIT_COMMIT=unspecified | ||
ARG GIT_REMOTE=unspecified | ||
ARG VERSION=unspecified | ||
|
||
RUN groupadd --system pca && useradd --system --gid pca pca | ||
FROM python:3.7-alpine | ||
|
||
RUN apt-get update && \ | ||
apt-get install --no-install-recommends -y \ | ||
at &&\ | ||
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* | ||
ARG GIT_COMMIT | ||
ARG GIT_REMOTE | ||
ARG VERSION | ||
|
||
RUN mkdir ${PCA_HOME} && chown pca:pca ${PCA_HOME} | ||
VOLUME ${PCA_HOME} | ||
LABEL git_commit=$GIT_COMMIT | ||
LABEL git_remote=$GIT_REMOTE | ||
LABEL maintainer="[email protected]" | ||
LABEL vendor="Cyber and Infrastructure Security Agency" | ||
LABEL version=$VERSION | ||
|
||
WORKDIR ${PCA_CON_SRC} | ||
ARG CISA_UID=421 | ||
ENV CISA_HOME="/home/cisa" | ||
ENV GOPHISH_TOOLS_SRC="/usr/src/gophish-tools" | ||
|
||
RUN addgroup --system --gid $CISA_UID cisa \ | ||
&& adduser --system --uid $CISA_UID --ingroup cisa cisa | ||
|
||
RUN apk --update --no-cache add \ | ||
bash \ | ||
py-pip | ||
|
||
VOLUME $CISA_HOME | ||
|
||
WORKDIR $GOPHISH_TOOLS_SRC | ||
COPY . $GOPHISH_TOOLS_SRC | ||
|
||
COPY . ${PCA_CON_SRC} | ||
RUN pip install --no-cache-dir . | ||
RUN chmod +x ${PCA_CON_SRC}/var/getenv | ||
RUN ln -snf ${PCA_CON_SRC}/var/getenv /usr/local/bin | ||
RUN chmod +x ${GOPHISH_TOOLS_SRC}/var/getenv | ||
RUN ln -snf ${GOPHISH_TOOLS_SRC}/var/getenv /usr/local/bin | ||
|
||
USER pca | ||
WORKDIR ${PCA_HOME} | ||
USER cisa | ||
WORKDIR $CISA_HOME | ||
CMD ["getenv"] |
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,2 +1,2 @@ | ||
"""This file defines the version of this project.""" | ||
__version__ = "0.0.2" | ||
__version__ = "0.0.3" |
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
Oops, something went wrong.