Merge pull request #98 from junkurihara/native-roots #304
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Publish Docker | |
on: | |
push: | |
branches: | |
- "develop" | |
- "main" | |
pull_request: | |
types: [synchronize, opened] | |
env: | |
GHCR: ghcr.io | |
GHCR_IMAGE_NAME: ${{ github.repository }} | |
DH_REGISTRY_NAME: jqtype/rpxy | |
jobs: | |
build_and_push: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- target: "default" | |
dockerfile: ./docker/Dockerfile | |
platforms: linux/amd64,linux/arm64 | |
# Aliases must be used only for release builds | |
aliases: | | |
jqtype/rpxy:latest | |
ghcr.io/junkurihara/rust-rpxy:latest | |
- target: "default-slim" | |
dockerfile: ./docker/Dockerfile-slim | |
build-contexts: | | |
messense/rust-musl-cross:amd64-musl=docker-image://messense/rust-musl-cross:x86_64-musl | |
messense/rust-musl-cross:arm64-musl=docker-image://messense/rust-musl-cross:aarch64-musl | |
platforms: linux/amd64,linux/arm64 | |
tags-suffix: "-slim" | |
# Aliases must be used only for release builds | |
aliases: | | |
jqtype/rpxy:slim | |
ghcr.io/junkurihara/rust-rpxy:slim | |
- target: "s2n" | |
dockerfile: ./docker/Dockerfile | |
build-args: | | |
"CARGO_FEATURES=--no-default-features --features=http3-s2n,cache" | |
"ADDITIONAL_DEPS=pkg-config libssl-dev cmake libclang1 gcc g++" | |
platforms: linux/amd64,linux/arm64 | |
tags-suffix: "-s2n" | |
# Aliases must be used only for release builds | |
aliases: | | |
jqtype/rpxy:s2n | |
ghcr.io/junkurihara/rust-rpxy:s2n | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.GHCR }}/${{ env.GHCR_IMAGE_NAME }} | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.GHCR }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Nightly build test on amd64 for pull requests | |
if: ${{ github.event_name == 'pull_request' }} | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
build-args: ${{ matrix.build-args }} | |
push: false | |
build-contexts: ${{ matrix.build-contexts }} | |
file: ${{ matrix.dockerfile }} | |
cache-from: type=gha,scope=rpxy-nightly-${{ matrix.target }} | |
cache-to: type=gha,mode=max,scope=rpxy-nightly-${{ matrix.target }} | |
platforms: linux/amd64 | |
labels: ${{ steps.meta.outputs.labels }} | |
- name: Nightly build and push from develop branch | |
if: ${{ (github.ref_name == 'develop') && (github.event_name == 'push') }} | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
build-args: ${{ matrix.build-args }} | |
push: true | |
tags: | | |
${{ env.GHCR }}/${{ env.GHCR_IMAGE_NAME }}:nightly${{ matrix.tags-suffix }} | |
${{ env.DH_REGISTRY_NAME }}:nightly${{ matrix.tags-suffix }} | |
build-contexts: ${{ matrix.build-contexts }} | |
file: ${{ matrix.dockerfile }} | |
cache-from: type=gha,scope=rpxy-nightly-${{ matrix.target }} | |
cache-to: type=gha,mode=max,scope=rpxy-nightly-${{ matrix.target }} | |
platforms: ${{ matrix.platforms }} | |
labels: ${{ steps.meta.outputs.labels }} | |
- name: Release build and push from main branch | |
if: ${{ (github.ref_name == 'main') && (github.event_name == 'push') }} | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
build-args: ${{ matrix.build-args }} | |
push: true | |
tags: | | |
${{ env.GHCR }}/${{ env.GHCR_IMAGE_NAME }}:latest${{ matrix.tags-suffix }} | |
${{ env.DH_REGISTRY_NAME }}:latest${{ matrix.tags-suffix }} | |
${{ matrix.aliases }} | |
build-contexts: ${{ matrix.build-contexts }} | |
file: ${{ matrix.dockerfile }} | |
cache-from: type=gha,scope=rpxy-latest-${{ matrix.target }} | |
cache-to: type=gha,mode=max,scope=rpxy-latest-${{ matrix.target }} | |
platforms: ${{ matrix.platforms }} | |
labels: ${{ steps.meta.outputs.labels }} |