-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update
build.yml
workflow to cross-compile linux binaries for `x86_…
…64` and `aarch64` (#140) * Update the build.yml workflow to cross-compile linux binaries for x86_64 and aarch64. * Change the Dockerfile to multi-stage for use with docker buildx.
- Loading branch information
1 parent
75828ec
commit 04f050e
Showing
2 changed files
with
127 additions
and
26 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
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,4 +1,40 @@ | ||
ARG CRYSTAL_VERSION | ||
FROM crystallang/crystal:${CRYSTAL_VERSION}-alpine | ||
# ARG to specify Crystal version and base image tag | ||
ARG CRYSTAL_VERSION=1.13.1 | ||
ARG BASE_IMAGE_TAG=ubuntu-22.04 | ||
|
||
RUN apk add xz-dev xz-static libxml2-dev libxml2-static sqlite-dev sqlite-static | ||
# Stage 1: Build for x86_64 | ||
FROM 84codes/crystal:${CRYSTAL_VERSION}-${BASE_IMAGE_TAG} AS builder-x86_64 | ||
WORKDIR /app | ||
RUN git clone https://github.com/coverallsapp/coverage-reporter.git . | ||
# Install only the necessary dependencies, skipping ameba and kcov | ||
RUN sed -i '/ameba/d' shard.yml \ | ||
&& sed -i '/crystal-kcov/d' shard.yml \ | ||
&& shards install --ignore-crystal-version \ | ||
&& mkdir -p /app/bin \ | ||
&& crystal build --release src/coverage_reporter.cr -o /app/bin/coveralls-linux-x86_64 | ||
|
||
# Stage 2: Build for aarch64 | ||
FROM 84codes/crystal:${CRYSTAL_VERSION}-${BASE_IMAGE_TAG} AS builder-aarch64 | ||
WORKDIR /app | ||
COPY --from=builder-x86_64 /app /app | ||
|
||
# Install dependencies. Ensure ameba and kcov are not present | ||
RUN sed -i '/ameba/d' shard.yml \ | ||
&& sed -i '/crystal-kcov/d' shard.yml \ | ||
&& rm -rf lib/* \ | ||
&& rm -rf .shards \ | ||
&& shards install --ignore-crystal-version \ | ||
&& mkdir -p /app/bin \ | ||
&& crystal build --release src/coverage_reporter.cr -o /app/bin/coveralls-linux-aarch64 | ||
|
||
# Stage 3a: Export Binary for x86_64 | ||
FROM scratch AS x86_64_binary | ||
COPY --from=builder-x86_64 /app/bin/coveralls-linux-x86_64 / | ||
|
||
# Stage 3b: Export Binary for aarch64 | ||
FROM scratch AS aarch64_binary | ||
COPY --from=builder-aarch64 /app/bin/coveralls-linux-aarch64 / | ||
|
||
# Stage 4: Final stage to create a generic binary for backward compatibility | ||
FROM scratch AS final | ||
COPY --from=x86_64_binary /coveralls-linux-x86_64 /coveralls-linux |