diff --git a/.github/workflows/docker-images.yml b/.github/workflows/docker-images.yml new file mode 100644 index 0000000..24126cf --- /dev/null +++ b/.github/workflows/docker-images.yml @@ -0,0 +1,49 @@ +name: Build and push Docker image + +on: + push: + branches: + pull_request: + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + docker-images: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + strategy: + fail-fast: false + matrix: + debian-versions: [buster, bullseye, bookworm] + rust-versions: [1.72.0] + clang-versions: [15, 16] + steps: + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Checkout repository + uses: actions/checkout@v4 + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: dockerfiles + file: dockerfiles/Dockerfile.amd64 + push: ${{ github.ref == 'refs/heads/main' }} + labels: ${{ steps.meta.outputs.labels }} + tags: "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:debian-${{ matrix.debian-versions }}-rust-${{ matrix.rust-versions }}-clang-${{ matrix.clang-versions }}" diff --git a/dockerfiles/Dockerfile.aarch64 b/dockerfiles/Dockerfile.aarch64 index 1b3d6e1..e172f6a 100644 --- a/dockerfiles/Dockerfile.aarch64 +++ b/dockerfiles/Dockerfile.aarch64 @@ -2,7 +2,7 @@ ARG DEBIAN_VERSION=bullseye FROM debian:$DEBIAN_VERSION-slim -ARG ENV RUST_STABLE_VERSION="1.72.0" +ARG RUST_STABLE_VERSION="1.72.0" # Set environment variables ENV SHELL="/bin/bash" diff --git a/dockerfiles/Dockerfile.amd64 b/dockerfiles/Dockerfile.amd64 index 2e7f1a2..ad69474 100644 --- a/dockerfiles/Dockerfile.amd64 +++ b/dockerfiles/Dockerfile.amd64 @@ -3,7 +3,8 @@ ARG DEBIAN_VERSION=bullseye FROM debian:${DEBIAN_VERSION}-slim ARG DEBIAN_VERSION=bullseye -ARG ENV RUST_STABLE_VERSION="1.72.0" +ARG RUST_STABLE_VERSION="1.72.0" +ARG CLANG_VERSION="15" # Set environment variables ENV SHELL="/bin/bash" @@ -14,8 +15,8 @@ ENV CARGO_HOME="/opt/cargo_home" ENV CARGO_TARGET_DIR="/opt/cargo_target" ENV PATH="$PATH:$CARGO_HOME/bin" -ENV CC="clang-15" -ENV CXX="clang-15" +ENV CC="clang-$CLANG_VERSION" +ENV CXX="clang-$CLANG_VERSION" ENV SKIP_WASM_BUILD=1 ENV RUST_BACKTRACE=1 @@ -31,11 +32,11 @@ RUN set -eux && \ # tools git bash sudo nano \ # compilers - clang-15 lldb-15 lld-15 libclang-15-dev make \ + clang-$CLANG_VERSION lldb-$CLANG_VERSION lld-$CLANG_VERSION libclang-$CLANG_VERSION-dev make \ # dependencies protobuf-compiler && \ - update-alternatives --install /usr/bin/cc cc /usr/bin/clang-15 100 && \ - update-alternatives --install /usr/bin/ld ld /usr/bin/ld.lld-15 100 && \ + update-alternatives --install /usr/bin/cc cc /usr/bin/clang-$CLANG_VERSION 100 && \ + update-alternatives --install /usr/bin/ld ld /usr/bin/ld.lld-$CLANG_VERSION 100 && \ rm -rf /var/lib/apt/lists/* RUN useradd rust --create-home -u 1000 --groups sudo