Skip to content

Commit

Permalink
CM-40289 - Publish docker image with Cycode CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
MarshalX committed Sep 26, 2024
1 parent d312c17 commit dafa39d
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 81 deletions.
38 changes: 0 additions & 38 deletions .github/workflows/docker-image-dev.yml

This file was deleted.

66 changes: 29 additions & 37 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -1,46 +1,38 @@
on:
workflow_dispatch:
name: Build and Publish Docker Image

permissions:
# Write permission needed for creating a tag.
contents: write
on:
push:
branches:
- CM-40289-update-docker-image
# tags: [ 'v*.*.*' ]

jobs:
main:
docker:
runs-on: ubuntu-latest

steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: Set up QEMU
uses: docker/setup-qemu-action@v1
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
-
name: Login to DockerHub Registry
env:
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }}
run: echo "$DOCKERHUB_PASSWORD" | docker login -u "$DOCKERHUB_USER" --password-stdin
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Bump version
id: bump_version
uses: anothrNick/github-tag-action@1.36.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DEFAULT_BUMP: minor
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

-
name: Build and push
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Build and push
id: docker_build
uses: docker/build-push-action@v3
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
push: true
tags: cycodehq/cycode_cli:${{ steps.bump_version.outputs.new_tag }}
-
name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
push: false # TEMP FOR TESTS
tags: cycodehq/cycode_cli:${{ github.ref_name }}

- name: Image digest
run: |
echo ${{ github.ref_name }}
echo ${{ steps.docker_build.outputs.imageid }}
echo ${{ steps.docker_build.outputs.digest }}
echo ${{ steps.docker_build.outputs.metadata }}
12 changes: 6 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
FROM python:3.8.16-alpine3.17 as base
FROM python:3.12.6-alpine3.20 AS base
WORKDIR /usr/cycode/app
RUN apk add git=2.38.5-r0
RUN apk add git=2.45.2-r0

FROM base as builder
ENV POETRY_VERSION=1.4.2
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=12.2.1_git20220924-r4 libffi-dev=3.4.4-r0 musl-dev=1.2.3-r4 && \
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 && \
pip install --no-cache-dir "poetry==$POETRY_VERSION" "poetry-dynamic-versioning[plugin]" && \
apk del .build-deps gcc libffi-dev musl-dev

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

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

Expand Down

0 comments on commit dafa39d

Please sign in to comment.