Skip to content

feat: build F3 sidecar FFI in Dockerfile #17556

feat: build F3 sidecar FFI in Dockerfile

feat: build F3 sidecar FFI in Dockerfile #17556

Workflow file for this run

name: Forest Docker
# Cancel workflow if there is a new change to the branch.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
on:
push:
branches: [main]
tags:
- "*"
merge_group:
pull_request:
# This needs to be declared explicitly so that the job is actually
# run when moved out of draft.
types: [opened, synchronize, reopened, ready_for_review]
env:
CI: 1
CARGO_INCREMENTAL: 0
CACHE_TIMEOUT_MINUTES: 5
SCRIPT_TIMEOUT_MINUTES: 30
AWS_ACCESS_KEY_ID: '${{ secrets.AWS_ACCESS_KEY_ID }}'
AWS_SECRET_ACCESS_KEY: '${{ secrets.AWS_SECRET_ACCESS_KEY }}'
RUSTC_WRAPPER: sccache
CC: sccache clang
CXX: sccache clang++
jobs:
build-ubuntu-2204-amd64:
name: Build forest binaries on Ubuntu-22.04-amd64
runs-on: ubuntu-22.04
# Run the job only if the PR is not a draft.
# This is done to limit the runner cost.
if: github.event.pull_request.draft == false
steps:
- name: Configure SCCache variables
run: |
# External PRs do not have access to 'vars' or 'secrets'.
if [[ "${{secrets.AWS_ACCESS_KEY_ID}}" != "" ]]; then
echo "SCCACHE_ENDPOINT=${{ vars.SCCACHE_ENDPOINT}}" >> $GITHUB_ENV
echo "SCCACHE_BUCKET=${{ vars.SCCACHE_BUCKET}}" >> $GITHUB_ENV
echo "SCCACHE_REGION=${{ vars.SCCACHE_REGION}}" >> $GITHUB_ENV
fi
- run: lscpu
- name: Show IP
run: curl ifconfig.me
continue-on-error: true
- name: Checkout Sources
uses: actions/checkout@v4
- name: Setup sccache
uses: mozilla-actions/[email protected]
timeout-minutes: '${{ fromJSON(env.CACHE_TIMEOUT_MINUTES) }}'
continue-on-error: true
- uses: actions/setup-go@v5
with:
go-version-file: "go.work"
- name: Cargo Install
env:
# To minimize compile times: https://nnethercote.github.io/perf-book/build-configuration.html#minimizing-compile-times
RUSTFLAGS: "-C linker=clang -C link-arg=-fuse-ld=lld"
run: make install
- uses: actions/upload-artifact@v4
with:
name: 'forest-linux-amd64'
path: |
~/.cargo/bin/forest*
if-no-files-found: error
build-ubuntu-2204-arm64:
name: Build forest binaries on Ubuntu-22.04-arm64
runs-on: buildjet-4vcpu-ubuntu-2204-arm
# Run the job only if the PR is not a draft.
# This is done to limit the runner cost.
if: github.event.pull_request.draft == false
steps:
- name: Configure SCCache variables
run: |
# External PRs do not have access to 'vars' or 'secrets'.
if [[ "${{secrets.AWS_ACCESS_KEY_ID}}" != "" ]]; then
echo "SCCACHE_ENDPOINT=${{ vars.SCCACHE_ENDPOINT}}" >> $GITHUB_ENV
echo "SCCACHE_BUCKET=${{ vars.SCCACHE_BUCKET}}" >> $GITHUB_ENV
echo "SCCACHE_REGION=${{ vars.SCCACHE_REGION}}" >> $GITHUB_ENV
fi
- run: lscpu
- name: Show IP
run: curl ifconfig.me
continue-on-error: true
- name: Checkout Sources
uses: actions/checkout@v4
- name: Setup sccache
uses: mozilla-actions/[email protected]
timeout-minutes: '${{ fromJSON(env.CACHE_TIMEOUT_MINUTES) }}'
continue-on-error: true
- uses: actions/setup-go@v5
with:
go-version-file: "go.work"
- name: Cargo Install
run: make install
- uses: actions/upload-artifact@v4
with:
name: 'forest-linux-arm64'
path: |
~/.cargo/bin/forest*
if-no-files-found: error
build-and-push-docker-image:
name: Build images and push to GHCR
runs-on: ubuntu-22.04
# Run the job only if the PR is not a draft.
# This is done to limit the runner cost.
if: github.event.pull_request.draft == false
timeout-minutes: 30
needs:
- build-ubuntu-2204-amd64
- build-ubuntu-2204-arm64
steps:
- name: List cached docker images
run: docker image ls
- name: Checkout code
uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: 'forest-linux-amd64'
path: /tmp/forest/forest-linux-amd64
- uses: actions/download-artifact@v4
with:
name: 'forest-linux-arm64'
path: /tmp/forest/forest-linux-arm64
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Github Packages
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to Docker Hub
continue-on-error: true
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# Build the fat image first, for details see <https://github.com/ChainSafe/forest/pull/3912>
# This step yields the following labels
# - {date}-{sha}-fat, e.g. 2023-01-19-da4692d-fat,
# - edge-fat
# - tag-fat (if pushed).
- name: Docker Meta fat
id: metafat
uses: docker/metadata-action@v5
with:
images: ghcr.io/chainsafe/forest
flavor: |
latest=false
suffix=-fat
tags: |
type=raw,value={{date 'YYYY-MM-DD'}}-{{sha}}
type=ref,event=tag
type=edge
- name: Build fat image and push to GitHub Container Registry
uses: docker/build-push-action@v6
with:
context: /tmp/forest
file: ./Dockerfile-ci
tags: ${{ steps.metafat.outputs.tags }}
labels: ${{ steps.metafat.outputs.labels }}
push: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') }}
platforms: 'linux/amd64,linux/arm64'
target: fat-image
# This step yields the following labels
# - date+sha, e.g. 2023-01-19-da4692d,
# - tag (if pushed).
- name: Docker Meta
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/chainsafe/forest
flavor: |
latest=false
tags: |
type=raw,value={{date 'YYYY-MM-DD'}}-{{sha}}
type=ref,event=tag
type=edge
- name: Build slim image and push to GitHub Container Registry
uses: docker/build-push-action@v6
with:
context: /tmp/forest
file: ./Dockerfile-ci
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
push: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') }}
platforms: 'linux/amd64,linux/arm64'
target: slim-image