Skip to content

Commit

Permalink
Add dockerized build job.
Browse files Browse the repository at this point in the history
  • Loading branch information
sobomax committed Jul 25, 2024
1 parent a635268 commit c68e822
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 2 deletions.
31 changes: 29 additions & 2 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ permissions:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build_and_test:
# The type of runner that the job will run on
runs-on: ubuntu-latest
Expand Down Expand Up @@ -111,7 +110,7 @@ jobs:
shell: bash

publish_wheels:
needs: build_and_test_python
needs: [build_and_test_python, build_in_docker]
if: github.event_name == 'release' && github.event.action == 'created'
runs-on: ubuntu-latest
environment:
Expand All @@ -138,3 +137,31 @@ jobs:

- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

build_in_docker:
needs: build_and_test
runs-on: ubuntu-latest
env:
PLATFORMS: linux/amd64,linux/i386,linux/arm/v7,linux/arm64,linux/riscv64
BASE_IMAGE: debian:sid-slim
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v3
with:
platforms: arm64,arm,riscv64

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build Docker image
uses: docker/build-push-action@v6
with:
context: .
file: ./docker/Dockerfile.build
build-args: |
BASE_IMAGE=${{ env.BASE_IMAGE }}
platforms: ${{ env.PLATFORMS }}
17 changes: 17 additions & 0 deletions docker/Dockerfile.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# syntax=docker/dockerfile:1.7-labs

ARG BASE_IMAGE
FROM ${BASE_IMAGE} AS build
LABEL maintainer="Maksym Sobolyev <sobomax@sippysoft.com>"

ARG BUILD_PKGS="cmake make gcc libc6-dev openssl"
ARG DEBIAN_FRONTEND=noninteractive
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
apt-get update && apt-get install -y --no-install-recommends ${BUILD_PKGS}
WORKDIR /src
RUN --mount=type=bind,target=.,rw cmake -B build && make -C build all test install
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
apt-get remove -y --purge ${BUILD_PKGS} && \
apt-get autoremove -y --purge

0 comments on commit c68e822

Please sign in to comment.