Skip to content

Commit 7e528ea

Browse files
authored
CM-40289 - Publish docker image with Cycode CLI (#250)
1 parent d312c17 commit 7e528ea

File tree

3 files changed

+44
-80
lines changed

3 files changed

+44
-80
lines changed

.github/workflows/docker-image-dev.yml

Lines changed: 0 additions & 38 deletions
This file was deleted.

.github/workflows/docker-image.yml

Lines changed: 38 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,48 @@
1+
name: Build and Publish Docker Image. On dispatch event build the latest tag and push to Docker Hub
2+
13
on:
24
workflow_dispatch:
3-
4-
permissions:
5-
# Write permission needed for creating a tag.
6-
contents: write
5+
push:
6+
tags: [ 'v*.*.*' ]
77

88
jobs:
9-
main:
9+
docker:
1010
runs-on: ubuntu-latest
11+
1112
steps:
12-
-
13-
name: Checkout
14-
uses: actions/checkout@v2
15-
-
16-
name: Set up QEMU
17-
uses: docker/setup-qemu-action@v1
18-
-
19-
name: Set up Docker Buildx
20-
uses: docker/setup-buildx-action@v1
21-
-
22-
name: Login to DockerHub Registry
23-
env:
24-
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
25-
DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }}
26-
run: echo "$DOCKERHUB_PASSWORD" | docker login -u "$DOCKERHUB_USER" --password-stdin
27-
28-
- name: Bump version
29-
id: bump_version
30-
uses: anothrNick/[email protected]
31-
env:
32-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33-
DEFAULT_BUMP: minor
34-
35-
-
36-
name: Build and push
13+
- name: Checkout repository
14+
uses: actions/checkout@v3
15+
with:
16+
fetch-depth: 0
17+
18+
- name: Get latest release tag
19+
id: latest_tag
20+
run: |
21+
LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1`)
22+
echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_OUTPUT
23+
24+
- name: Check out latest release tag
25+
if: ${{ github.event_name == 'workflow_dispatch' }}
26+
run: |
27+
git checkout ${{ steps.latest_tag.outputs.LATEST_TAG }}
28+
29+
- name: Set up QEMU
30+
uses: docker/setup-qemu-action@v3
31+
32+
- name: Set up Docker Buildx
33+
uses: docker/setup-buildx-action@v3
34+
35+
- name: Login to Docker Hub
36+
uses: docker/login-action@v3
37+
with:
38+
username: ${{ secrets.DOCKERHUB_USER }}
39+
password: ${{ secrets.DOCKERHUB_PASSWORD }}
40+
41+
- name: Build and push
3742
id: docker_build
38-
uses: docker/build-push-action@v3
43+
uses: docker/build-push-action@v6
3944
with:
4045
context: .
41-
file: ./Dockerfile
46+
platforms: linux/amd64,linux/arm64
4247
push: true
43-
tags: cycodehq/cycode_cli:${{ steps.bump_version.outputs.new_tag }}
44-
-
45-
name: Image digest
46-
run: echo ${{ steps.docker_build.outputs.digest }}
48+
tags: cycodehq/cycode_cli:${{ steps.latest_tag.outputs.LATEST_TAG }},cycodehq/cycode_cli:latest

Dockerfile

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

5-
FROM base as builder
6-
ENV POETRY_VERSION=1.4.2
5+
FROM base AS builder
6+
ENV POETRY_VERSION=1.8.3
77

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

@@ -19,7 +19,7 @@ RUN poetry config virtualenvs.in-project true && \
1919
poetry --no-cache install --only=main --no-root && \
2020
poetry build
2121

22-
FROM base as final
22+
FROM base AS final
2323
COPY --from=builder /usr/cycode/app/dist ./
2424
RUN pip install --no-cache-dir cycode*.whl
2525

0 commit comments

Comments
 (0)