Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjoyo committed Feb 2, 2024
1 parent 1e6195d commit 041d82f
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 34 deletions.
78 changes: 45 additions & 33 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@ jobs:
build-jvm:
strategy:
matrix:
os: [ {name: ubuntu-latest, arch: amd64}, {name: macos-14, arch: arm64} ]
runs-on: ${{ matrix.os.name }}
include:
- runner: ubuntu-latest
arch: amd64
- runner: buildjet-4vcpu-ubuntu-2204-arm
arch: arm64
runs-on: ${{ matrix.runner }}
defaults:
run:
working-directory: ./feel-engine-wrapper
Expand All @@ -38,8 +42,8 @@ jobs:
name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: feel-engine-wrapper-${{ matrix.os.name }}-${{ matrix.os.arch }}
path: /target/*-runner
name: feel-engine-wrapper-${{ matrix.arch }}-runner
path: feel-engine-wrapper/target/*-runner # action does not respect working-directory...
if-no-files-found: error

build-python:
Expand All @@ -48,7 +52,9 @@ jobs:
run:
working-directory: ./bpm-ai-connectors-c8
steps:
- uses: actions/checkout@v3
-
name: Checkout code
uses: actions/checkout@v3
-
name: Set up Python 3.12
uses: actions/setup-python@v4
Expand All @@ -74,13 +80,28 @@ jobs:
path: bpm-ai-connectors-c8/dist/ # action does not respect working-directory...
if-no-files-found: error

build-push-amd64:
#needs: [build-jvm, build-python]
build-push:
needs: [build-jvm]
strategy:
matrix:
include:
- arch: amd64
- arch: arm64
runs-on: ubuntu-latest
steps:
-
name: Checkout
name: Checkout code
uses: actions/checkout@v3
-
uses: actions/download-artifact@v4
with:
name: feel-engine-wrapper-${{ matrix.arch }}-runner
path: feel-engine-wrapper/target
-
run: ls -la feel-engine-wrapper/target
-
name: Set up QEMU
uses: docker/setup-qemu-action@v3
-
run: docker context create builders
-
Expand All @@ -103,32 +124,24 @@ jobs:
name: Build and push
uses: docker/build-push-action@v5
with:
platforms: linux/amd64
build-args: |
TARGETARCH=amd64
platforms: linux/${{ matrix.arch }}
file: ./Dockerfile.prebuilt
push: true
tags: |
${{ env.REGISTRY_IMAGE }}:${{ steps.vars.outputs.tag }}-amd64
${{ env.REGISTRY_IMAGE }}:latest-amd64
${{ env.REGISTRY_IMAGE }}:${{ steps.vars.outputs.tag }}-${{ matrix.arch }}
${{ env.REGISTRY_IMAGE }}:latest-${{ matrix.arch }}
build-push-arm64:
if: ${{ false }} # disable for now
#needs: [build-jvm, build-python]
runs-on: macos-14
steps:
-
name: Checkout
name: Checkout code
uses: actions/checkout@v3
-
name: Setup docker (missing on MacOS)
if: runner.os == 'macos'
run: |
brew config
brew install docker colima
colima delete
colima start debug --arch aarch64 --ssh-agent
# For testcontainers to find the Colima socket
# https://github.com/abiosoft/colima/blob/main/docs/FAQ.md#cannot-connect-to-the-docker-daemon-at-unixvarrundockersock-is-the-docker-daemon-running
sudo ln -sf $HOME/.colima/default/docker.sock /var/run/docker.sock
name: Set up QEMU
uses: docker/setup-qemu-action@v3
-
run: docker context create builders
-
Expand Down Expand Up @@ -164,9 +177,11 @@ jobs:
defaults:
run:
working-directory: ./bpm-ai-connectors-c8/tests
needs: [build-push-amd64]
needs: [build-push]
steps:
- uses: actions/checkout@v4
-
name: Checkout code
uses: actions/checkout@v4
-
name: Set up Python 3.12
uses: actions/setup-python@v4
Expand All @@ -186,31 +201,28 @@ jobs:

create-push-manifest:
runs-on: ubuntu-latest
needs: [build-push-amd64, build-push-arm64, pytest-docker]
needs: [build-push, pytest-docker]
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
-
name: Get the version
name: Get version
id: vars
run: echo ::set-output name=tag::$(echo ${GITHUB_REF:10})
-
name: Create version manifest and push
name: Create version-manifest and push
run: |
docker manifest create \
${{ env.REGISTRY_IMAGE }}:${{ steps.vars.outputs.tag }} \
--amend ${{ env.REGISTRY_IMAGE }}:${{ steps.vars.outputs.tag }}-amd64 \
--amend ${{ env.REGISTRY_IMAGE }}:${{ steps.vars.outputs.tag }}-arm64
docker manifest push ${{ env.REGISTRY_IMAGE }}:${{ steps.vars.outputs.tag }}
-
name: Create latest manifest and push
name: Create latest-manifest and push
run: |
docker manifest create \
${{ env.REGISTRY_IMAGE }}:latest \
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ COPY feel-engine-wrapper/src /code/src
RUN ./mvnw package -Dnative-compress

###############################################################################
# 2. build python connectors as native executable using nuitka
# 2. install python connector dependencies
###############################################################################
# poetry setup code copied from https://github.com/thehale/docker-python-poetry, due to missing multiarch images
# POETRY BASE IMAGE - Provides environment variables for poetry
Expand Down
44 changes: 44 additions & 0 deletions Dockerfile.prebuilt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
ARG PYTHON_VERSION="3.12"

###############################################################################
# 1. install python connector dependencies
###############################################################################
# poetry setup code copied from https://github.com/thehale/docker-python-poetry, due to missing multiarch images
# POETRY BASE IMAGE - Provides environment variables for poetry
FROM python:${PYTHON_VERSION}-slim AS python-poetry-base
ARG POETRY_VERSION="1.6.1"
ENV POETRY_VERSION=${POETRY_VERSION}
ENV POETRY_HOME="/opt/poetry"
ENV POETRY_VIRTUALENVS_IN_PROJECT=true
ENV POETRY_NO_INTERACTION=1
ENV PATH="$POETRY_HOME/bin:$PATH"
# POETRY BUILDER IMAGE - Installs Poetry and dependencies
FROM python-poetry-base AS python-poetry-builder
RUN apt-get update && apt-get install -y --no-install-recommends curl
# Install Poetry via the official installer: https://python-poetry.org/docs/master/#installing-with-the-official-installer
# This script respects $POETRY_VERSION & $POETRY_HOME
RUN curl -sSL https://install.python-poetry.org | python3 -
# POETRY RUNTIME IMAGE - Copies the poetry installation into a smaller image and builds target app
FROM python-poetry-base AS build-python
COPY --from=python-poetry-builder $POETRY_HOME $POETRY_HOME
# only install dependencies into project virtualenv
COPY bpm-ai-connectors-c8/pyproject.toml bpm-ai-connectors-c8/poetry.lock ./app/
WORKDIR /app
RUN poetry install --without dev,test --no-root --no-cache

###############################################################################
# 3. Final, minimal image
###############################################################################
FROM cgr.dev/chainguard/python:latest

ARG PYTHON_VERSION
ENV PYTHONUNBUFFERED=1

WORKDIR /app
COPY ./feel-engine-wrapper/target/*-runner feel-wrapper
COPY ./bpm-ai-connectors-c8/bpm_ai_connectors_c8/ ./bpm_ai_connectors_c8/
COPY --from=build-python /app/.venv/lib/python${PYTHON_VERSION}/site-packages /home/nonroot/.local/lib/python${PYTHON_VERSION}/site-packages

# Run two processes: connector runtime + feel engine wrapper
COPY docker/init.py .
CMD ["init.py", "./feel-wrapper", "python -m bpm_ai_connectors_c8.main"]

0 comments on commit 041d82f

Please sign in to comment.