add cargo lock to docker builds for consistent results #245
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: Docker | |
on: | |
push: | |
branches: | |
- main | |
tags: | |
- '*' | |
pull_request: | |
branches: | |
- main | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }} | |
jobs: | |
build: | |
strategy: | |
matrix: | |
variant: | |
- name: 'minimal' | |
suffix: '' | |
description: 'Minimal Production Image (without external cache)' | |
feature: 'default' | |
- name: 'testing' | |
suffix: '-testing' | |
description: 'Static Integration Test Image' | |
feature: 'static-testing' | |
- name: 'redis' | |
suffix: '-redis' | |
description: 'Production Image (with redis cache)' | |
feature: 'redis' | |
fail-fast: false | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
actions: read | |
security-events: write | |
id-token: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login into GitHub Container Registry | |
if: ${{ github.event_name != 'pull_request' }} | |
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 }} | |
tags: | | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
type=semver,pattern={{major}} | |
flavor: | | |
latest=${{ matrix.variant.name == 'minimal' }} | |
suffix=${{ matrix.variant.suffix }} | |
labels: | | |
org.opencontainers.image.title=xenos (${{ matrix.variant.name }}) | |
org.opencontainers.image.description=${{ matrix.variant.description }} | |
org.opencontainers.image.vendor=Scrayos UG (haftungsbeschränkt) | |
org.opencontainers.image.authors=Joshua Dean Küpper <[email protected]>, Paul Wagner <[email protected]> | |
org.opencontainers.image.url=https://github.com/scrayosnet/xenos | |
org.opencontainers.image.documentation=https://github.com/scrayosnet/xenos | |
org.opencontainers.image.source=https://github.com/scrayosnet/xenos | |
org.opencontainers.image.licenses=MIT | |
- name: Build and push Docker image | |
id: build-and-push | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
build-args: | | |
"FEATURES=${{ matrix.variant.feature }}" | |
push: ${{ github.ref_type == 'tag' }} | |
tags: ${{ steps.meta.outputs.tags }} | |
annotations: ${{ steps.meta.outputs.annotations }} | |
labels: ${{ steps.meta.outputs.labels }} | |
provenance: false | |
sbom: false |