-
Notifications
You must be signed in to change notification settings - Fork 247
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
Add gateway to snapshot builds in CI #3256
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
@@ -0,0 +1,109 @@ | ||
# This Dockerfile supports both native building and cross-compilation to x86-64, aarch64 and riscv64 | ||
FROM --platform=$BUILDPLATFORM ubuntu:22.04 | ||
|
||
ARG RUSTC_VERSION=nightly-2024-10-22 | ||
ARG PROFILE=production | ||
ARG RUSTFLAGS | ||
# Incremental compilation here isn't helpful | ||
ENV CARGO_INCREMENTAL=0 | ||
ENV PKG_CONFIG_ALLOW_CROSS=true | ||
|
||
ARG BUILDARCH | ||
ARG TARGETARCH | ||
|
||
WORKDIR /code | ||
|
||
RUN \ | ||
apt-get update && \ | ||
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ | ||
ca-certificates \ | ||
protobuf-compiler \ | ||
curl \ | ||
git \ | ||
llvm \ | ||
clang \ | ||
automake \ | ||
libtool \ | ||
pkg-config \ | ||
make | ||
|
||
RUN \ | ||
if [ $BUILDARCH != "arm64" ] && [ $TARGETARCH = "arm64" ]; then \ | ||
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ | ||
g++-aarch64-linux-gnu \ | ||
gcc-aarch64-linux-gnu \ | ||
libc6-dev-arm64-cross \ | ||
; fi | ||
|
||
RUN \ | ||
if [ $BUILDARCH != "riscv64" ] && [ $TARGETARCH = "riscv64" ]; then \ | ||
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ | ||
g++-riscv64-linux-gnu \ | ||
gcc-riscv64-linux-gnu \ | ||
libc6-dev-riscv64-cross \ | ||
; fi | ||
|
||
RUN \ | ||
if [ $BUILDARCH != "amd64" ] && [ $TARGETARCH = "amd64" ]; then \ | ||
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ | ||
g++-x86-64-linux-gnu \ | ||
gcc-x86-64-linux-gnu \ | ||
libc6-dev-amd64-cross \ | ||
; fi | ||
|
||
RUN \ | ||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain $RUSTC_VERSION && \ | ||
/root/.cargo/bin/rustup target add wasm32-unknown-unknown | ||
|
||
COPY Cargo.lock /code/Cargo.lock | ||
COPY Cargo.toml /code/Cargo.toml | ||
COPY rust-toolchain.toml /code/rust-toolchain.toml | ||
|
||
COPY crates /code/crates | ||
COPY domains /code/domains | ||
COPY shared /code/shared | ||
COPY test /code/test | ||
|
||
# Up until this line all Rust images in this repo should be the same to share the same layers | ||
|
||
ARG TARGETVARIANT | ||
|
||
RUN \ | ||
if [ $BUILDARCH != "arm64" ] && [ $TARGETARCH = "arm64" ]; then \ | ||
export RUSTFLAGS="$RUSTFLAGS -C linker=aarch64-linux-gnu-gcc" \ | ||
; fi && \ | ||
if [ $BUILDARCH != "riscv64" ] && [ $TARGETARCH = "riscv64" ]; then \ | ||
export RUSTFLAGS="$RUSTFLAGS -C linker=riscv64-linux-gnu-gcc" \ | ||
; fi && \ | ||
if [ $TARGETARCH = "amd64" ] && [ "$RUSTFLAGS" = "" ]; then \ | ||
case "$TARGETVARIANT" in \ | ||
# x86-64-v2 with AES-NI | ||
"v2") export RUSTFLAGS="-C target-cpu=x86-64-v2" ;; \ | ||
# x86-64-v3 with AES-NI | ||
"v3") export RUSTFLAGS="-C target-cpu=x86-64-v3 -C target-feature=+aes" ;; \ | ||
# v4 is compiled for Zen 4+ | ||
"v4") export RUSTFLAGS="-C target-cpu=znver4" ;; \ | ||
# Default build is for Skylake | ||
*) export RUSTFLAGS="-C target-cpu=skylake" ;; \ | ||
esac \ | ||
; fi && \ | ||
if [ $BUILDARCH != "amd64" ] && [ $TARGETARCH = "amd64" ]; then \ | ||
export RUSTFLAGS="$RUSTFLAGS -C linker=x86_64-linux-gnu-gcc" \ | ||
; fi && \ | ||
RUSTC_TARGET_ARCH=$(echo $TARGETARCH | sed "s/amd64/x86_64/g" | sed "s/arm64/aarch64/g" | sed "s/riscv64/riscv64gc/g") && \ | ||
/root/.cargo/bin/cargo -Zgitoxide -Zgit build \ | ||
--locked \ | ||
-Z build-std \ | ||
--profile $PROFILE \ | ||
--bin subspace-gateway \ | ||
--target $RUSTC_TARGET_ARCH-unknown-linux-gnu && \ | ||
mv target/*/*/subspace-gateway subspace-gateway && \ | ||
rm -rf target | ||
|
||
FROM ubuntu:22.04 | ||
|
||
COPY --from=0 /code/subspace-gateway /subspace-gateway | ||
|
||
USER nobody:nogroup | ||
|
||
ENTRYPOINT ["/subspace-gateway"] |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
.dockerignore |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
🤔
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 set off my editor's trailing spaces auto-formatting.
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.
Removing trailing spaces is good, but this one got the whole line itself removed. It is fine.