-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: build F3 sidecar FFI in Dockerfile #4763
Changes from all commits
cde9fb1
931b6cf
9e6d416
af480b7
8eaa6c6
e03063c
e492a1b
75fa790
82f6047
973c96a
6f99246
64137d9
7faadc1
9850d89
599917c
b077661
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,28 +17,128 @@ on: | |
types: [opened, synchronize, reopened, ready_for_review] | ||
|
||
env: | ||
FOREST_TEST_IMAGE: forest-image | ||
FOREST_TEST_ARCHIVE: forest-image.tar | ||
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-and-push-docker-image: | ||
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For troubleshooting, e.g. set up sccache storage region and analyze sccache cache performance |
||
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 | ||
Comment on lines
+71
to
+76
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd imagine such builds to fail seldom. Can we do it only on main? Alternatively, only in the merge queue? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure. I plan to disable it for PR in a subsequent PR so that it's proved to be working in this PR. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Only There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @LesnyRumcajs should I just update this PR since the arm64 build has been verified at 9850d89 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, please. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
steps: | ||
- name: Configure SCCache variables | ||
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') | ||
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 | ||
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we do it on the level of the entire job? |
||
- name: Setup sccache | ||
uses: mozilla-actions/[email protected] | ||
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') | ||
timeout-minutes: '${{ fromJSON(env.CACHE_TIMEOUT_MINUTES) }}' | ||
continue-on-error: true | ||
- uses: actions/setup-go@v5 | ||
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') | ||
with: | ||
go-version-file: "go.work" | ||
- name: Cargo Install | ||
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') | ||
run: make install | ||
- uses: actions/upload-artifact@v4 | ||
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') | ||
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 | ||
# Change to `buildjet-8vcpu-ubuntu-2204` if `fuzzy` is down. | ||
# runs-on: fuzzy | ||
runs-on: buildjet-8vcpu-ubuntu-2204 | ||
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 | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
|
||
- uses: actions/download-artifact@v4 | ||
with: | ||
name: 'forest-linux-amd64' | ||
path: /tmp/forest/forest-linux-amd64 | ||
|
||
- uses: actions/download-artifact@v4 | ||
# Compile Docker image only for AMD64 for a regular PR to save some CI time. | ||
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') | ||
with: | ||
name: 'forest-linux-arm64' | ||
path: /tmp/forest/forest-linux-arm64 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
@@ -78,7 +178,8 @@ jobs: | |
- name: Build fat image and push to GitHub Container Registry | ||
uses: docker/build-push-action@v6 | ||
with: | ||
context: . | ||
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') }} | ||
|
@@ -104,7 +205,8 @@ jobs: | |
- name: Build slim image and push to GitHub Container Registry | ||
uses: docker/build-push-action@v6 | ||
with: | ||
context: . | ||
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') }} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# This Dockerfile is for building official Forest docker multiplatform images on CI, | ||
# linux/amd64 and linux/arm64 are currently supported. | ||
# | ||
# This Dockerfile composes Forest binaries that are prebuilt in other CI steps, to take | ||
# better advantage of build cache and reduce build time and cost. | ||
# | ||
# Build and manually push to Github Container Registry (see https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry) | ||
# ``` | ||
# docker build -t ghcr.io/chainsafe/forest:latest . | ||
# docker push ghcr.io/chainsafe/forest:latest | ||
# ``` | ||
|
||
## | ||
# Prod image for forest binary | ||
# Use github action runner cached images to avoid being rate limited | ||
# https://github.com/actions/runner-images/blob/main/images/linux/Ubuntu2004-Readme.md#cached-docker-images | ||
## | ||
# A slim image contains only forest binaries | ||
FROM ubuntu:22.04 AS slim-image | ||
|
||
# export TARGETPLATFORM TARGETOS and TARGETARCH | ||
ARG TARGETPLATFORM | ||
ARG TARGETOS | ||
ARG TARGETARCH | ||
|
||
ENV DEBIAN_FRONTEND="noninteractive" | ||
# Install binary dependencies | ||
RUN apt-get update && \ | ||
apt-get install --no-install-recommends -y ca-certificates && \ | ||
rm -rf /var/lib/apt/lists/* | ||
RUN update-ca-certificates | ||
|
||
# Assuming prebuilt Forest binaries are under `forest-linux-[amd64|arm64]` | ||
COPY --chmod=555 ./forest-${TARGETOS}-${TARGETARCH}/* /usr/local/bin | ||
|
||
# Basic verification of dynamically linked dependencies | ||
RUN forest -V && forest-cli -V && forest-tool -V && forest-wallet -V | ||
|
||
ENTRYPOINT ["forest"] | ||
|
||
# A fat image contains forest binaries and fil proof parameter files under $FIL_PROOFS_PARAMETER_CACHE | ||
FROM slim-image AS fat-image | ||
|
||
# Move FIL_PROOFS_PARAMETER_CACHE out of forest data dir since users always need to mount the data dir | ||
ENV FIL_PROOFS_PARAMETER_CACHE="/var/tmp/filecoin-proof-parameters" | ||
|
||
# Populate $FIL_PROOFS_PARAMETER_CACHE | ||
RUN forest-tool fetch-params --keys | ||
|
||
# Cache actor bundle in the image | ||
ENV FOREST_ACTOR_BUNDLE_PATH="/var/tmp/forest_actor_bundle.car.zst" | ||
|
||
# Populate $FOREST_ACTOR_BUNDLE_PATH | ||
RUN forest-tool state-migration actor-bundle $FOREST_ACTOR_BUNDLE_PATH | ||
|
||
ENTRYPOINT ["forest"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any specific reason to do this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does not hurt to know more info about the buildjet host and it can be used for troubleshooting build errors. e.g. #2859