From 60fcc34b9720fb901a0f5224e48ef16612d6c445 Mon Sep 17 00:00:00 2001 From: Nemuel Wainaina Date: Mon, 11 Nov 2024 12:23:16 +0300 Subject: [PATCH] Add Docker-based multiarch support for amd64 and arm64 --- .github/workflows/cd.yml | 29 +++++++++++++---------------- Dockerfile | 17 +++++++++++++++++ 2 files changed, 30 insertions(+), 16 deletions(-) create mode 100644 Dockerfile diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 9df8973..c85834a 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -7,30 +7,27 @@ on: jobs: build: runs-on: ubuntu-latest + strategy: + matrix: + arch: [amd64, arm64] steps: - name: Checkout repository uses: actions/checkout@v3 - - name: Set up python - uses: actions/setup-python@v4 - with: - python-version: '3.12' - - - name: Install Poetry - run: | - curl -sSL https://install.python-poetry.org | python3 - - - - name: Install dependencies + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Build Docker image run: | - poetry install + docker build --platform linux/${{ matrix.arch }} -t protodesk . - - name: Run Pyinstaller + - name: Run Docker image run: | - poetry run pyinstaller app.spec + docker run --rm -v $(pwd)/dist:/app/dist --name protodesk-container protodesk - name: Create a versioned archive of the build run: | - cd dist && tar -czf protodesk-${{ github.event.release.tag_name }}.tar.gz app/ + cd dist && tar -czf protodesk-${{ github.event.release.tag_name }}_${{ matrix.arch }}.tar.gz app/ - name: Upload release asset uses: actions/upload-release-asset@v1 @@ -38,6 +35,6 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ github.event.release.upload_url}} - asset_path: dist/protodesk-${{ github.event.release.tag_name }}.tar.gz - asset_name: protodesk-${{ github.event.release.tag_name }}.tar.gz + asset_path: dist/protodesk-${{ github.event.release.tag_name }}_${{ matrix.arch }}.tar.gz + asset_name: protodesk-${{ github.event.release.tag_name }}_${{ matrix.arch }}.tar.gz asset_content_type: application/gzip diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d0172d8 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +# base image +FROM python:3.12-slim + +# working directory +WORKDIR /app + +# install poetry +RUN curl -sSL https://install.python-poetry.org | python3 - + +# copy project files +COPY . /app + +# install project dependencies +RUN poetry install --no-root + +# build the application with Pyinstaller +RUN poetry run pyinstaller app.spec