From 0d4e0152ac4cfe01df0f4864fd57f05f431a537d Mon Sep 17 00:00:00 2001 From: Ilya Siamionau Date: Tue, 25 Feb 2025 13:25:33 +0100 Subject: [PATCH 1/2] CM-45223 - Build docker image on pull requests --- .github/workflows/docker-image.yml | 44 +++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 1db2b804..2144a6e0 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -2,6 +2,7 @@ name: Build and Publish Docker Image. On dispatch event build the latest tag and on: workflow_dispatch: + pull_request: push: tags: [ 'v*.*.*' ] @@ -11,7 +12,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 @@ -26,6 +27,36 @@ jobs: run: | git checkout ${{ steps.latest_tag.outputs.LATEST_TAG }} + - name: Set up Python 3.8 + uses: actions/setup-python@v5 + with: + python-version: '3.8' + + - name: Load cached Poetry setup + id: cached_poetry + uses: actions/cache@v4 + with: + path: ~/.local + key: poetry-ubuntu-0 # increment to reset cache + + - name: Setup Poetry + if: steps.cached_poetry.outputs.cache-hit != 'true' + uses: snok/install-poetry@v1 + with: + version: 1.8.3 + + - name: Add Poetry to PATH + run: echo "$HOME/.local/bin" >> $GITHUB_PATH + + - name: Install Poetry Plugin + run: poetry self add "poetry-dynamic-versioning[plugin]" + + - name: Get CLI Version + id: cli_version + run: | + echo "::debug::Package version: $(poetry version --short)" + echo "CLI_VERSION=$(poetry version --short)" >> $GITHUB_OUTPUT + - name: Set up QEMU uses: docker/setup-qemu-action@v3 @@ -40,9 +71,20 @@ jobs: - name: Build and push id: docker_build + if: ${{ github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/v') }} uses: docker/build-push-action@v6 with: context: . platforms: linux/amd64,linux/arm64 push: true tags: cycodehq/cycode_cli:${{ steps.latest_tag.outputs.LATEST_TAG }},cycodehq/cycode_cli:latest + + - name: Verify build + id: docker_verify_build + if: ${{ github.event_name != 'workflow_dispatch' && !startsWith(github.ref, 'refs/tags/v') }} + uses: docker/build-push-action@v6 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: false + tags: cycodehq/cycode_cli:${{ steps.cli_version.outputs.CLI_VERSION }} From 69ff0c6b36cac0834a473addaafeb97fa80fe5db Mon Sep 17 00:00:00 2001 From: Ilya Siamionau Date: Tue, 25 Feb 2025 14:38:29 +0100 Subject: [PATCH 2/2] update dockerfile --- .github/workflows/docker-image.yml | 2 +- Dockerfile | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 2144a6e0..42467e02 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -1,4 +1,4 @@ -name: Build and Publish Docker Image. On dispatch event build the latest tag and push to Docker Hub +name: Build Docker Image. On tag creation push to Docker Hub. On dispatch event build the latest tag and push to Docker Hub on: workflow_dispatch: diff --git a/Dockerfile b/Dockerfile index 1b3a5815..641b829d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,12 @@ -FROM python:3.12.6-alpine3.20 AS base +FROM python:3.12.9-alpine3.21 AS base WORKDIR /usr/cycode/app -RUN apk add git=2.45.2-r0 +RUN apk add git=2.47.2-r0 FROM base AS builder ENV POETRY_VERSION=1.8.3 # deps are required to build cffi -RUN apk add --no-cache --virtual .build-deps gcc=13.2.1_git20240309-r0 libffi-dev=3.4.6-r0 musl-dev=1.2.5-r0 && \ +RUN apk add --no-cache --virtual .build-deps gcc=14.2.0-r4 libffi-dev=3.4.6-r0 musl-dev=1.2.5-r9 && \ pip install --no-cache-dir "poetry==$POETRY_VERSION" "poetry-dynamic-versioning[plugin]" && \ apk del .build-deps gcc libffi-dev musl-dev