Skip to content

Commit

Permalink
Add docker-build.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
liuchengxu committed Nov 14, 2023
1 parent c56d286 commit 059cb88
Showing 1 changed file with 78 additions and 0 deletions.
78 changes: 78 additions & 0 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# This action enables building container images for farmer and node, can be triggered manually or by release creation.
#
# Container images are only pushed to GitHub Container Registry.
name: Docker build

on:
workflow_dispatch:
push:
branches:
- '**'
tags:
- '**'

# Incremental compilation here isn't helpful
env:
CARGO_INCREMENTAL: 0

jobs:
container-linux:
runs-on: ubuntu-22.04
permissions:
contents: write
packages: write
strategy:
matrix:
image:
- farmer
- node
platform:
- arch: linux/amd64
profile: production
suffix: ubuntu-x86_64-${{ github.ref_name }}
image-suffix: ''

steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Log into registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}

- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v3
with:
images: |
# The final created images will be `ghcr.io/subspace/{node, farmer}` under subspace organization,
# hence adding a prefix `subspace-` for a fork repo, the final image will be:
# - ghcr.io/liuchengxu/subspace-node:tag
# - ghcr.io/liuchengxu/subspace-farmer:tag
ghcr.io/${{ github.repository_owner }}/subspace-${{ matrix.image }}
tags: |
type=ref,event=tag
type=ref,event=branch
type=sha
flavor: |
latest=false
suffix=${{ matrix.platform.image-suffix }}
- name: Build and push ${{ matrix.image }} image
id: build
uses: docker/build-push-action@v2
with:
file: Dockerfile-${{ matrix.image }}
platforms: ${{ matrix.platform.arch }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
SUBSTRATE_CLI_GIT_COMMIT_HASH=${{ github.sha }}
PROFILE=${{ matrix.platform.profile }}
RUSTFLAGS=-C strip=debuginfo

0 comments on commit 059cb88

Please sign in to comment.