forked from jmug/stoatchat
chore(pushd/ci): Build image pushd image in-fork.
Some checks failed
Docker / Build pushd image (push) Has been cancelled
Docker / base (push) Has been cancelled
Rust build, test, and generate specification / Rust project (push) Has been cancelled
Docker / base (release) Successful in 21m35s
Docker / Build pushd image (release) Successful in 1m32s
Some checks failed
Docker / Build pushd image (push) Has been cancelled
Docker / base (push) Has been cancelled
Rust build, test, and generate specification / Rust project (push) Has been cancelled
Docker / base (release) Successful in 21m35s
Docker / Build pushd image (release) Successful in 1m32s
This commit is contained in:
236
.github/workflows/docker.yaml
vendored
236
.github/workflows/docker.yaml
vendored
@@ -1,141 +1,115 @@
|
|||||||
name: Docker Test & Publish
|
name: Docker
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
# branches:
|
branches:
|
||||||
# - "main"
|
- "handmade"
|
||||||
tags:
|
|
||||||
- "*"
|
|
||||||
paths-ignore:
|
|
||||||
- ".github/**"
|
|
||||||
- "!.github/workflows/docker.yml"
|
|
||||||
- ".vscode/**"
|
|
||||||
- "doc/**"
|
|
||||||
- ".gitignore"
|
|
||||||
- "LICENSE"
|
|
||||||
- "README"
|
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- "main"
|
- "handmade"
|
||||||
paths:
|
release:
|
||||||
- "Dockerfile"
|
types:
|
||||||
workflow_dispatch:
|
- published
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
packages: write
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
base:
|
# Builds the shared base image: the whole Rust workspace compiled once.
|
||||||
runs-on: ubuntu-latest
|
# Every service image (currently only pushd) is derived from this so the
|
||||||
name: Build base image
|
# workspace is built a single time per release. On non-release events this
|
||||||
steps:
|
# still runs as a compile check, but nothing is pushed.
|
||||||
# Configure build environment
|
base:
|
||||||
- name: Checkout
|
runs-on: ubuntu-latest
|
||||||
uses: actions/checkout@v3
|
steps:
|
||||||
- name: Set up Docker Buildx
|
- name: Checkout
|
||||||
uses: docker/setup-buildx-action@v2
|
uses: actions/checkout@v4
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
- name: Resolve registry host and owner
|
||||||
|
id: registry
|
||||||
|
# Owner is lowercased: Docker repository names must be lowercase.
|
||||||
|
run: |
|
||||||
|
echo "host=${GITHUB_SERVER_URL#*://}" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "owner=$(echo "$GITHUB_REPOSITORY_OWNER" | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_OUTPUT"
|
||||||
|
- name: Base image ref
|
||||||
|
id: base
|
||||||
|
run: echo "image=${{ steps.registry.outputs.host }}/${{ steps.registry.outputs.owner }}/handmade-revolt-base" >> "$GITHUB_OUTPUT"
|
||||||
|
- name: Login to registry
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
if: github.event_name == 'release'
|
||||||
|
with:
|
||||||
|
registry: ${{ steps.registry.outputs.host }}
|
||||||
|
username: ${{ secrets.PACKAGE_PUBLISH_USERNAME }}
|
||||||
|
password: ${{ secrets.PACKAGE_PUBLISH_TOKEN }}
|
||||||
|
- name: Build base image
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
file: Dockerfile
|
||||||
|
push: ${{ github.event_name == 'release' }}
|
||||||
|
platforms: linux/amd64
|
||||||
|
# Pinned to the commit so the publish job below consumes this
|
||||||
|
# exact base.
|
||||||
|
tags: |
|
||||||
|
${{ steps.base.outputs.image }}:latest
|
||||||
|
${{ steps.base.outputs.image }}:${{ github.sha }}
|
||||||
|
|
||||||
# Authenticate with GHCR
|
# Builds individual service images from the base. Only runs on release.
|
||||||
- name: Login to Github Container Registry
|
publish:
|
||||||
if: ${{ github.event_name != 'pull_request' }}
|
needs: [base]
|
||||||
uses: docker/login-action@v2
|
runs-on: ubuntu-latest
|
||||||
with:
|
if: github.event_name == 'release'
|
||||||
registry: ghcr.io
|
strategy:
|
||||||
username: ${{ github.actor }}
|
matrix:
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
# Only pushd is built. To add more services later, add
|
||||||
|
# entries here (paths/images mirror the upstream revolt layout):
|
||||||
- name: Build base image
|
# - { project: delta, path: crates/delta, image: handmade-revolt-server }
|
||||||
uses: docker/build-push-action@v4
|
# - { project: bonfire, path: crates/bonfire, image: handmade-revolt-bonfire }
|
||||||
with:
|
# - { project: autumn, path: crates/services/autumn, image: handmade-revolt-autumn }
|
||||||
context: .
|
# - { project: january, path: crates/services/january, image: handmade-revolt-january }
|
||||||
push: ${{ github.event_name != 'pull_request' }}
|
# - { project: crond, path: crates/daemons/crond, image: handmade-revolt-crond }
|
||||||
platforms: linux/amd64,linux/arm64
|
include:
|
||||||
tags: ghcr.io/${{ github.repository_owner }}/base:latest
|
- { project: pushd, path: crates/daemons/pushd, image: handmade-revolt-pushd }
|
||||||
cache-from: type=gha,scope=buildx-base-multi-arch
|
name: Build ${{ matrix.project }} image
|
||||||
cache-to: type=gha,scope=buildx-base-multi-arch,mode=max
|
steps:
|
||||||
|
- name: Checkout
|
||||||
publish:
|
uses: actions/checkout@v4
|
||||||
needs: [base]
|
- name: Set up Docker Buildx
|
||||||
runs-on: ubuntu-latest
|
uses: docker/setup-buildx-action@v3
|
||||||
if: github.event_name != 'pull_request'
|
- name: Resolve registry host and owner
|
||||||
strategy:
|
id: registry
|
||||||
matrix:
|
# Owner is lowercased: Docker repository names must be lowercase,
|
||||||
project: [delta, bonfire, autumn, january, pushd]
|
# but the org (e.g. HMC) may be uppercase.
|
||||||
name: Build ${{ matrix.project }} image
|
run: |
|
||||||
steps:
|
echo "host=${GITHUB_SERVER_URL#*://}" >> "$GITHUB_OUTPUT"
|
||||||
# Configure build environment
|
echo "owner=$(echo "$GITHUB_REPOSITORY_OWNER" | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_OUTPUT"
|
||||||
- name: Checkout
|
- name: Docker meta
|
||||||
uses: actions/checkout@v3
|
id: meta
|
||||||
- name: Set up Docker Buildx
|
uses: docker/metadata-action@v5
|
||||||
uses: docker/setup-buildx-action@v2
|
with:
|
||||||
|
images: ${{ steps.registry.outputs.host }}/${{ steps.registry.outputs.owner }}/${{ matrix.image }}
|
||||||
# Authenticate with Docker Hub and GHCR
|
tags: |
|
||||||
- name: Login to DockerHub
|
type=semver,pattern={{version}}
|
||||||
uses: docker/login-action@v2
|
type=semver,pattern={{major}}.{{minor}}
|
||||||
with:
|
type=raw,value=latest
|
||||||
registry: docker.io
|
env:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
- name: Login to registry
|
||||||
- name: Login to Github Container Registry
|
uses: docker/login-action@v3
|
||||||
uses: docker/login-action@v2
|
with:
|
||||||
with:
|
registry: ${{ steps.registry.outputs.host }}
|
||||||
registry: ghcr.io
|
username: ${{ secrets.PACKAGE_PUBLISH_USERNAME }}
|
||||||
username: ${{ github.actor }}
|
password: ${{ secrets.PACKAGE_PUBLISH_TOKEN }}
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
- name: Build and publish
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
# Resolve the correct project
|
with:
|
||||||
- uses: kanga333/variable-mapper@master
|
context: .
|
||||||
id: export
|
file: ${{ matrix.path }}/Dockerfile
|
||||||
with:
|
push: true
|
||||||
key: "${{ matrix.project }}"
|
platforms: linux/amd64
|
||||||
map: |
|
build-args: |
|
||||||
{
|
BASE_IMAGE=${{ steps.registry.outputs.host }}/${{ steps.registry.outputs.owner }}/handmade-revolt-base:${{ github.sha }}
|
||||||
"delta": {
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
"path": "crates/delta",
|
annotations: ${{ steps.meta.outputs.annotations }}
|
||||||
"tag": "${{ github.repository_owner }}/server"
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
},
|
|
||||||
"bonfire": {
|
|
||||||
"path": "crates/bonfire",
|
|
||||||
"tag": "${{ github.repository_owner }}/bonfire"
|
|
||||||
},
|
|
||||||
"autumn": {
|
|
||||||
"path": "crates/services/autumn",
|
|
||||||
"tag": "${{ github.repository_owner }}/autumn"
|
|
||||||
},
|
|
||||||
"january": {
|
|
||||||
"path": "crates/services/january",
|
|
||||||
"tag": "${{ github.repository_owner }}/january"
|
|
||||||
},
|
|
||||||
"pushd": {
|
|
||||||
"path": "crates/daemons/pushd",
|
|
||||||
"tag": "${{ github.repository_owner }}/pushd"
|
|
||||||
},
|
|
||||||
"crond": {
|
|
||||||
"path": "crates/daemons/crond",
|
|
||||||
"tag": "${{ github.repository_owner }}/crond"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
export_to: output
|
|
||||||
|
|
||||||
# Configure metadata
|
|
||||||
- name: Docker meta
|
|
||||||
id: meta
|
|
||||||
uses: docker/metadata-action@v4
|
|
||||||
with:
|
|
||||||
images: |
|
|
||||||
docker.io/${{ steps.export.outputs.tag }}
|
|
||||||
ghcr.io/${{ steps.export.outputs.tag }}
|
|
||||||
|
|
||||||
# Build crate image
|
|
||||||
- name: Publish
|
|
||||||
uses: docker/build-push-action@v4
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
push: true
|
|
||||||
platforms: linux/amd64,linux/arm64
|
|
||||||
file: ${{ steps.export.outputs.path }}/Dockerfile
|
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
|
||||||
build-args: |
|
|
||||||
BASE_IMAGE=ghcr.io/${{ github.repository_owner }}/base:latest
|
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
# Build Stage
|
# Build Stage
|
||||||
FROM ghcr.io/revoltchat/base:latest AS builder
|
# BASE_IMAGE is the compiled workspace base image. Defaults to the upstream
|
||||||
|
# revolt base, but CI overrides it with our own base built from repo.
|
||||||
|
ARG BASE_IMAGE=ghcr.io/revoltchat/base:latest
|
||||||
|
FROM ${BASE_IMAGE} AS builder
|
||||||
FROM debian:12 AS debian
|
FROM debian:12 AS debian
|
||||||
|
|
||||||
# Bundle Stage
|
# Bundle Stage
|
||||||
|
|||||||
Reference in New Issue
Block a user