Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 44 additions & 2 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
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:
pull_request:
push:
tags: [ 'v*.*.*' ]

Expand All @@ -11,7 +12,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand All @@ -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

Expand All @@ -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 }}
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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

Expand Down
Loading