This repository has been archived by the owner on Dec 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update Dockerfile to use cargo-zigbuild for easier cross compilation.…
… Update CI workflows
- Loading branch information
Showing
2 changed files
with
66 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,37 @@ | ||
# name: CI | ||
# | ||
# on: | ||
# push: | ||
# branches: ["main"] | ||
# pull_request: | ||
# branches: ["main"] | ||
# | ||
# env: | ||
# PROJECT_ID: develop-for-good | ||
# REGION: us-central1 | ||
# GAR_LOCATION: us-central1-docker.pkg.dev/developforgood/dfg/ | ||
# | ||
# jobs: | ||
# build-push-artifact: | ||
# runs-on: ubuntu-latest | ||
# steps: | ||
# - name: "Checkout" | ||
# uses: "actions/checkout@v3" | ||
# - id: "auth" | ||
# uses: "google-github-actions/auth@v1" | ||
# with: | ||
# credentials_json: "${{ secrets.SERVICE_ACCOUNT_KEY }}" | ||
# | ||
# - name: "Set up Cloud SDK" | ||
# uses: "google-github-actions/setup-gcloud@v1" | ||
# | ||
# - name: "Use gcloud CLI" | ||
# run: "gcloud info" | ||
# - name: "Docker auth" | ||
# run: |- | ||
# gcloud auth configure-docker ${{ env.REGION }}-docker.pkg.dev --quiet | ||
# - name: Build image | ||
# run: docker build . --file Dockerfile --tag alpha | ||
# working-directory: . | ||
# - name: Push image | ||
# run: docker push ${{ env.GAR_LOCATION }} | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: ["main"] | ||
pull_request: | ||
branches: ["main"] | ||
|
||
env: | ||
PROJECT_ID: develop-for-good | ||
REGION: us-central1 | ||
GAR_LOCATION: us-central1-docker.pkg.dev/develop-for-good/dfg/ | ||
|
||
jobs: | ||
build-push-artifact: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: "Checkout" | ||
uses: "actions/checkout@v3" | ||
- id: "auth" | ||
uses: "google-github-actions/auth@v1" | ||
with: | ||
credentials_json: "${{ secrets.SERVICE_ACCOUNT_KEY }}" | ||
|
||
- name: "Set up Cloud SDK" | ||
uses: "google-github-actions/setup-gcloud@v1" | ||
|
||
- name: "Use gcloud CLI" | ||
run: "gcloud info" | ||
- name: "Docker auth" | ||
run: |- | ||
gcloud auth configure-docker ${{ env.REGION }}-docker.pkg.dev --quiet | ||
- name: Build image | ||
run: docker build . --file Dockerfile --tag scipio:alpha | ||
working-directory: . | ||
- name: Push image | ||
run: docker push ${{ env.GAR_LOCATION }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,38 @@ | ||
FROM clux/muslrust:stable AS chef | ||
RUN cargo install cargo-chef | ||
WORKDIR /app | ||
FROM messense/cargo-zigbuild:sha-4e5d0f9 as builder | ||
|
||
RUN rustup target add aarch64-unknown-linux-musl && rustup target add x86_64-unknown-linux-musl | ||
WORKDIR /app | ||
|
||
FROM chef AS planner | ||
COPY . . | ||
RUN cargo chef prepare --recipe-path recipe.json | ||
|
||
FROM chef AS builder | ||
COPY --from=planner /app/recipe.json recipe.json | ||
RUN cargo chef cook --release --target aarch64-unknown-linux-musl --recipe-path recipe.json | ||
COPY . . | ||
RUN cargo build --release --target aarch64-unknown-linux-musl --bin scipio | ||
RUN cargo zigbuild --release --target x86_64-unknown-linux-musl | ||
# RUN cargo zigbuild --release --target aarch64-unknown-linux-musl | ||
|
||
FROM scratch AS runtime | ||
COPY --from=builder /app/target/aarch64-unknown-linux-musl/release/scipio /usr/local/bin/ | ||
COPY --from=builder /app/target/x86_64-unknown-linux-musl/release/scipio /usr/local/bin/ | ||
# COPY --from=builder /app/target/aarch64-unknown-linux-musl/release/scipio /usr/local/bin/ | ||
|
||
CMD ["/usr/local/bin/scipio"] | ||
|
||
# NOTE: The following is a multi-stage build that works for aarch64-unknown-linux-musl but doesn't cross | ||
# compile correctly. If you can fix this, please submit a PR. | ||
|
||
# FROM clux/muslrust:stable AS chef | ||
# RUN cargo install cargo-chef | ||
# WORKDIR /app | ||
# | ||
# RUN rustup target add aarch64-unknown-linux-musl && rustup target add x86_64-unknown-linux-musl | ||
# | ||
# FROM chef AS planner | ||
# COPY . . | ||
# RUN cargo chef prepare --recipe-path recipe.json | ||
# | ||
# FROM chef AS builder | ||
# COPY --from=planner /app/recipe.json recipe.json | ||
# RUN cargo chef cook --release --target aarch64-unknown-linux-musl --recipe-path recipe.json | ||
# COPY . . | ||
# RUN cargo build --release --target aarch64-unknown-linux-musl --bin scipio | ||
# | ||
# FROM scratch AS runtime | ||
# COPY --from=builder /app/target/aarch64-unknown-linux-musl/release/scipio /usr/local/bin/ | ||
# CMD ["/usr/local/bin/scipio"] | ||
|