Skip to content

Commit

Permalink
Add an example custom image
Browse files Browse the repository at this point in the history
It's basically just the harness base + the aws cli in a full ubuntu container to ensure awscli doesn't bork.  Will serve as good working documentation of how to build your own custom stack
  • Loading branch information
michaeljguarino committed Jul 28, 2024
1 parent f092adf commit ad628a6
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 0 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/publish-harness.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -253,3 +253,58 @@ jobs:
PYTHON_VERSION=${{ matrix.versions.python }}
HARNESS_BASE_IMAGE_REPO=ghcr.io/pluralsh/stackrun-harness-base
HARNESS_BASE_IMAGE_TAG=${{ needs.publish-harness-base.outputs.version }}
publish-harness-custom:
name: Build and push harness custom container
runs-on: ubuntu-20.04
needs: [publish-harness-base]
permissions:
contents: write
discussions: write
pull-requests: write
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/pluralsh/harness
docker.io/pluralsh/harness
tags: |
type=semver,pattern={{version}},suffix=-custom-${{ version }},priority=1000
type=sha,suffix=-custom-${{ version }},priority=800
type=ref,event=pr,suffix=-custom-${{ version }},priority=600
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to Docker
uses: docker/login-action@v3
with:
username: mjgpluralsh
password: ${{ secrets.DOCKER_ACCESS_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: "."
file: "./dockerfiles/harness/custom.Dockerfile"
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
HARNESS_BASE_IMAGE_REPO=ghcr.io/pluralsh/stackrun-harness-base
HARNESS_BASE_IMAGE_TAG=${{ needs.publish-harness-base.outputs.version }}
27 changes: 27 additions & 0 deletions dockerfiles/harness/custom.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
ARG HARNESS_BASE_IMAGE_TAG=latest

Check notice

Code scanning / Trivy

No HEALTHCHECK defined Low

Artifact: dockerfiles/harness/custom.Dockerfile
Type: dockerfile
Vulnerability DS026
Severity: LOW
Message: Add HEALTHCHECK instruction in your Dockerfile
Link: DS026
ARG HARNESS_BASE_IMAGE_REPO=ghcr.io/pluralsh/stackrun-harness-base
ARG HARNESS_BASE_IMAGE=$HARNESS_BASE_IMAGE_REPO:$HARNESS_BASE_IMAGE_TAG

FROM $HARNESS_BASE_IMAGE as harness

Check warning

Code scanning / Trivy

':latest' tag used Medium

Artifact: dockerfiles/harness/custom.Dockerfile
Type: dockerfile
Vulnerability DS001
Severity: MEDIUM
Message: Specify a tag in the 'FROM' statement for image 'ghcr.io/pluralsh/stackrun-harness-base'
Link: DS001

Check warning

Code scanning / Trivy

':latest' tag used Medium

Artifact: dockerfiles/harness/custom.Dockerfile
Type: dockerfile
Vulnerability DS001
Severity: MEDIUM
Message: Specify a tag in the 'FROM' statement for image 'latest'
Link: DS001

FROM debian:12-slim

COPY --from=harness /harness /usr/local/bin/harness

# Change ownership of the harness binary to UID/GID 65532
RUN chown -R 65532:65532 /usr/local/bin/harness
RUN apt-get -y update && apt-get -y install curl unzip

Check failure

Code scanning / Trivy

'apt-get' missing '--no-install-recommends' High

Artifact: dockerfiles/harness/custom.Dockerfile
Type: dockerfile
Vulnerability DS029
Severity: HIGH
Message: '--no-install-recommends' flag is missed: 'apt-get -y update && apt-get -y install curl unzip'
Link: DS029

# Install build dependencies, Ansible, and openssh-client
RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" && \
unzip awscliv2.zip && \
./aws/install

RUN addgroup --gid 65532 nonroot

# Switch to the non-root user
USER 65532:65532

WORKDIR /plural

ENTRYPOINT ["/harness", "--working-dir=/plural"]

0 comments on commit ad628a6

Please sign in to comment.