* chore: bump actions and pin versions * build: switch to blacksmith * fix: use rust-toolchain stable * build: improve pnpm store caching * chore: remove emoji from workflows * fix: run prepare job on blacksmith * chore: kebab case id * build: add concurrency groups to limit duplicate jobs * build: switch around node setup and pnpm setup task * chore: bump to nodejs 24, fix pnpm caching * fix: enable corepack * fix: concurrency deadlock in frontend preview * fix: approve build scripts * fix: just don't cancel concurrent previews * build: remove pnpm setup action everywhere * build: cache apt packages * build: yet another attempt at fixing concurrency * build: lower runner type for frontend deploy * fix: eslint not existing * build: add sccache to turbo-ci * fix: correct nextest pkg * fix: turbo ignoring sccache * revert me: test labrinth tests * Revert "revert me: test labrinth tests" This reverts commit def5cc19183d5c0fe3b6f3c03635d73bb59bd312. * build: compile app before docker build * build: lower runner types * build: remove docker inline caching * build: try mold on labrinth * build: tweak labrinth prod build profile * fix: app windows builds and caching * fix: tombi format cargo.toml * fix: swap ping test to cubecraft to avoid CI flakiness * typos fix --------- Co-authored-by: aecsocket <aecsocket@tutanota.com>
122 lines
4.6 KiB
YAML
122 lines
4.6 KiB
YAML
name: docker-build
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- '**'
|
|
paths:
|
|
- .github/workflows/labrinth-docker.yml
|
|
- 'apps/labrinth/**'
|
|
- Cargo.toml
|
|
- Cargo.lock
|
|
pull_request:
|
|
types: [opened, synchronize]
|
|
paths:
|
|
- .github/workflows/labrinth-docker.yml
|
|
- 'apps/labrinth/**'
|
|
- Cargo.toml
|
|
- Cargo.lock
|
|
merge_group:
|
|
types: [checks_requested]
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/prod' }}
|
|
|
|
jobs:
|
|
docker:
|
|
runs-on: blacksmith-4vcpu-ubuntu-2404
|
|
env:
|
|
SQLX_OFFLINE: 'true'
|
|
GIT_HASH: ${{ github.sha }}
|
|
SCCACHE_DIR: '/mnt/sccache'
|
|
SCCACHE_CACHE_SIZE: '10G'
|
|
SCCACHE_MULTILEVEL_CHAIN: 'disk,s3'
|
|
SCCACHE_S3_KEY_PREFIX: '${{ github.repository }}/'
|
|
SCCACHE_BUCKET: ${{ secrets.SCCACHE_BUCKET }}
|
|
SCCACHE_REGION: ${{ secrets.SCCACHE_REGION }}
|
|
SCCACHE_ENDPOINT: ${{ secrets.SCCACHE_ENDPOINT }}
|
|
AWS_ACCESS_KEY_ID: ${{ secrets.SCCACHE_S3_ACCESS_KEY_ID }}
|
|
AWS_SECRET_ACCESS_KEY: ${{ secrets.SCCACHE_S3_SECRET_ACCESS_KEY }}
|
|
RUSTC_WRAPPER: 'sccache'
|
|
steps:
|
|
- name: Check out code
|
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
|
|
- name: Setup Rust toolchain
|
|
uses: actions-rust-lang/setup-rust-toolchain@2b1f5e9b395427c92ee4e3331786ca3c37afe2d7 # v1.16.0
|
|
with:
|
|
rustflags: ''
|
|
cache: false
|
|
|
|
- name: Setup mold
|
|
uses: rui314/setup-mold@9c9c13bf4c3f1adef0cc596abc155580bcb04444 # v1 / Mold 2.41.0
|
|
|
|
- name: Cache Cargo registry and index
|
|
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
|
|
with:
|
|
path: |
|
|
~/.cargo/registry
|
|
~/.cargo/git
|
|
~/.cargo/bin
|
|
key: ${{ runner.os }}-${{ runner.arch }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
|
|
|
- name: Mount sccache disk cache
|
|
uses: useblacksmith/stickydisk@13af8883542ca949a717e70fef89d15edbb29d88 # v1.2.0
|
|
with:
|
|
key: ${{ github.repository }}-labrinth-sccache
|
|
path: /mnt/sccache
|
|
|
|
- name: Setup sccache
|
|
uses: mozilla-actions/sccache-action@9e7fa8a12102821edf02ca5dbea1acd0f89a2696 # v0.0.10
|
|
|
|
- name: Build labrinth
|
|
run: cargo build --profile release-labrinth --package labrinth
|
|
|
|
- name: Stage Docker context
|
|
run: |
|
|
mkdir -p apps/labrinth/docker-stage
|
|
cp target/release-labrinth/labrinth apps/labrinth/docker-stage/labrinth
|
|
cp -r apps/labrinth/migrations apps/labrinth/docker-stage/migrations
|
|
cp -r apps/labrinth/assets apps/labrinth/docker-stage/assets
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
|
|
|
|
- name: Generate Docker image metadata
|
|
id: docker-meta
|
|
uses: docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf # v6.0.0
|
|
env:
|
|
# GitHub Packages requires annotations metadata in at least the index descriptor to show them
|
|
# up properly in its UI it seems, but it's not clear about it, because the docs refer to the
|
|
# image manifest only. See:
|
|
# https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry#adding-a-description-to-multi-arch-images
|
|
DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index
|
|
with:
|
|
images: ghcr.io/modrinth/labrinth
|
|
labels: |
|
|
org.opencontainers.image.title=labrinth
|
|
org.opencontainers.image.description=Modrinth API
|
|
org.opencontainers.image.licenses=AGPL-3.0-only
|
|
annotations: |
|
|
org.opencontainers.image.title=labrinth
|
|
org.opencontainers.image.description=Modrinth API
|
|
org.opencontainers.image.licenses=AGPL-3.0-only
|
|
|
|
- name: Login to GitHub Packages
|
|
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Build and push
|
|
uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0
|
|
with:
|
|
context: ./apps/labrinth/docker-stage
|
|
file: ./apps/labrinth/Dockerfile
|
|
push: ${{ github.event_name != 'pull_request' }}
|
|
tags: ${{ steps.docker-meta.outputs.tags }}
|
|
labels: ${{ steps.docker-meta.outputs.labels }}
|
|
annotations: ${{ steps.docker-meta.outputs.annotations }}
|