Skip to content

Commit 56c0396

Browse files
authored
CM-45223 - Build docker image on pull requests (#281)
1 parent f893e08 commit 56c0396

File tree

2 files changed

+47
-5
lines changed

2 files changed

+47
-5
lines changed

.github/workflows/docker-image.yml

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
name: Build and Publish Docker Image. On dispatch event build the latest tag and push to Docker Hub
1+
name: Build Docker Image. On tag creation push to Docker Hub. On dispatch event build the latest tag and push to Docker Hub
22

33
on:
44
workflow_dispatch:
5+
pull_request:
56
push:
67
tags: [ 'v*.*.*' ]
78

@@ -11,7 +12,7 @@ jobs:
1112

1213
steps:
1314
- name: Checkout repository
14-
uses: actions/checkout@v3
15+
uses: actions/checkout@v4
1516
with:
1617
fetch-depth: 0
1718

@@ -26,6 +27,36 @@ jobs:
2627
run: |
2728
git checkout ${{ steps.latest_tag.outputs.LATEST_TAG }}
2829
30+
- name: Set up Python 3.8
31+
uses: actions/setup-python@v5
32+
with:
33+
python-version: '3.8'
34+
35+
- name: Load cached Poetry setup
36+
id: cached_poetry
37+
uses: actions/cache@v4
38+
with:
39+
path: ~/.local
40+
key: poetry-ubuntu-0 # increment to reset cache
41+
42+
- name: Setup Poetry
43+
if: steps.cached_poetry.outputs.cache-hit != 'true'
44+
uses: snok/install-poetry@v1
45+
with:
46+
version: 1.8.3
47+
48+
- name: Add Poetry to PATH
49+
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
50+
51+
- name: Install Poetry Plugin
52+
run: poetry self add "poetry-dynamic-versioning[plugin]"
53+
54+
- name: Get CLI Version
55+
id: cli_version
56+
run: |
57+
echo "::debug::Package version: $(poetry version --short)"
58+
echo "CLI_VERSION=$(poetry version --short)" >> $GITHUB_OUTPUT
59+
2960
- name: Set up QEMU
3061
uses: docker/setup-qemu-action@v3
3162

@@ -40,9 +71,20 @@ jobs:
4071

4172
- name: Build and push
4273
id: docker_build
74+
if: ${{ github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/v') }}
4375
uses: docker/build-push-action@v6
4476
with:
4577
context: .
4678
platforms: linux/amd64,linux/arm64
4779
push: true
4880
tags: cycodehq/cycode_cli:${{ steps.latest_tag.outputs.LATEST_TAG }},cycodehq/cycode_cli:latest
81+
82+
- name: Verify build
83+
id: docker_verify_build
84+
if: ${{ github.event_name != 'workflow_dispatch' && !startsWith(github.ref, 'refs/tags/v') }}
85+
uses: docker/build-push-action@v6
86+
with:
87+
context: .
88+
platforms: linux/amd64,linux/arm64
89+
push: false
90+
tags: cycodehq/cycode_cli:${{ steps.cli_version.outputs.CLI_VERSION }}

Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
FROM python:3.12.6-alpine3.20 AS base
1+
FROM python:3.12.9-alpine3.21 AS base
22
WORKDIR /usr/cycode/app
3-
RUN apk add git=2.45.2-r0
3+
RUN apk add git=2.47.2-r0
44

55
FROM base AS builder
66
ENV POETRY_VERSION=1.8.3
77

88
# deps are required to build cffi
9-
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 && \
9+
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 && \
1010
pip install --no-cache-dir "poetry==$POETRY_VERSION" "poetry-dynamic-versioning[plugin]" && \
1111
apk del .build-deps gcc libffi-dev musl-dev
1212

0 commit comments

Comments
 (0)