From e2c2af79c989044c8404ae54661e3580c8098e34 Mon Sep 17 00:00:00 2001 From: George Taylor Date: Mon, 18 Nov 2024 15:05:08 +0000 Subject: [PATCH] feat: add basic utils image --- .github/workflows/build-push-utils.yml | 42 ++++++++++++++++++++++++++ tools/utils/Dockerfile | 9 ++++++ 2 files changed, 51 insertions(+) create mode 100644 .github/workflows/build-push-utils.yml create mode 100644 tools/utils/Dockerfile diff --git a/.github/workflows/build-push-utils.yml b/.github/workflows/build-push-utils.yml new file mode 100644 index 0000000..031eab5 --- /dev/null +++ b/.github/workflows/build-push-utils.yml @@ -0,0 +1,42 @@ +name: Build and push image [Utils] + +on: + push: + workflow_dispatch: + +env: + IMAGE_NAME: hmpps-delius-alfresco-utils + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: checkout code + uses: actions/checkout@v4 + - name: Log in to the Container registry + uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 + with: + images: ${{ env.IMAGE_NAME }} + - name: Build and push Docker image + if: github.ref == 'refs/heads/main' + uses: docker/build-push-action@5176d81f87c23d6fc96624dfdbcd9f3830bbe445 + with: + context: ./tools/utils/ + push: true + tags: ghcr.io/${{ github.repository_owner }}/${{ steps.meta.outputs.tags }}, ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:latest + labels: ${{ steps.meta.outputs.labels }} + - name: Build and push Docker image + if: github.ref != 'refs/heads/main' + uses: docker/build-push-action@5176d81f87c23d6fc96624dfdbcd9f3830bbe445 + with: + context: ./tools/utils/ + push: true + tags: ghcr.io/${{ github.repository_owner }}/${{ steps.meta.outputs.tags }}, ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }}-${{ github.run_id }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/tools/utils/Dockerfile b/tools/utils/Dockerfile new file mode 100644 index 0000000..f6ae61f --- /dev/null +++ b/tools/utils/Dockerfile @@ -0,0 +1,9 @@ +FROM debian:bookworm-slim + +# Install utils +RUN apt-get update && apt-get install -y curl jq + +# Create a non-root user and set the home directory +RUN useradd -u 999 -ms /bin/bash job +USER job +WORKDIR /home/job