Skip to content

Commit 0db2de7

Browse files
committed
Add gateway to snapshot builds in CI
1 parent 8dfa716 commit 0db2de7

File tree

3 files changed

+121
-1
lines changed

3 files changed

+121
-1
lines changed

.github/workflows/snapshot-build.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ jobs:
3333
- image: node
3434
base-artifact: subspace-node
3535
upload-executables: true
36+
- image: gateway
37+
base-artifact: subspace-gateway
38+
upload-executables: false
3639
- image: bootstrap-node
3740
base-artifact: subspace-bootstrap-node
3841
upload-executables: false
@@ -104,7 +107,6 @@ jobs:
104107
cd executables
105108
IMAGE="${{ fromJSON(steps.meta.outputs.json).tags[0] }}"
106109
ARTIFACT="${{ matrix.build.base-artifact }}"
107-
108110
docker run --rm --platform linux/amd64 --entrypoint /bin/cat $IMAGE /$ARTIFACT > $ARTIFACT-ubuntu-x86_64-skylake-${{ github.ref_name }}
109111
# TODO: Pull is a workaround for https://github.com/moby/moby/issues/48197#issuecomment-2472265028
110112
docker pull --platform linux/amd64/v2 $IMAGE

docker/gateway.Dockerfile

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# This Dockerfile supports both native building and cross-compilation to x86-64, aarch64 and riscv64
2+
FROM --platform=$BUILDPLATFORM ubuntu:22.04
3+
4+
ARG RUSTC_VERSION=nightly-2024-10-22
5+
ARG PROFILE=production
6+
ARG RUSTFLAGS
7+
# Incremental compilation here isn't helpful
8+
ENV CARGO_INCREMENTAL=0
9+
ENV PKG_CONFIG_ALLOW_CROSS=true
10+
11+
ARG BUILDARCH
12+
ARG TARGETARCH
13+
14+
WORKDIR /code
15+
16+
RUN \
17+
apt-get update && \
18+
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
19+
ca-certificates \
20+
protobuf-compiler \
21+
curl \
22+
git \
23+
llvm \
24+
clang \
25+
automake \
26+
libtool \
27+
pkg-config \
28+
make
29+
30+
RUN \
31+
if [ $BUILDARCH != "arm64" ] && [ $TARGETARCH = "arm64" ]; then \
32+
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
33+
g++-aarch64-linux-gnu \
34+
gcc-aarch64-linux-gnu \
35+
libc6-dev-arm64-cross \
36+
; fi
37+
38+
RUN \
39+
if [ $BUILDARCH != "riscv64" ] && [ $TARGETARCH = "riscv64" ]; then \
40+
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
41+
g++-riscv64-linux-gnu \
42+
gcc-riscv64-linux-gnu \
43+
libc6-dev-riscv64-cross \
44+
; fi
45+
46+
RUN \
47+
if [ $BUILDARCH != "amd64" ] && [ $TARGETARCH = "amd64" ]; then \
48+
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
49+
g++-x86-64-linux-gnu \
50+
gcc-x86-64-linux-gnu \
51+
libc6-dev-amd64-cross \
52+
; fi
53+
54+
RUN \
55+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain $RUSTC_VERSION && \
56+
/root/.cargo/bin/rustup target add wasm32-unknown-unknown
57+
58+
COPY Cargo.lock /code/Cargo.lock
59+
COPY Cargo.toml /code/Cargo.toml
60+
COPY rust-toolchain.toml /code/rust-toolchain.toml
61+
62+
COPY crates /code/crates
63+
COPY domains /code/domains
64+
COPY shared /code/shared
65+
COPY test /code/test
66+
67+
# Up until this line all Rust images in this repo should be the same to share the same layers
68+
69+
ARG TARGETVARIANT
70+
71+
RUN \
72+
if [ $BUILDARCH != "arm64" ] && [ $TARGETARCH = "arm64" ]; then \
73+
export RUSTFLAGS="$RUSTFLAGS -C linker=aarch64-linux-gnu-gcc" \
74+
; fi && \
75+
if [ $BUILDARCH != "riscv64" ] && [ $TARGETARCH = "riscv64" ]; then \
76+
export RUSTFLAGS="$RUSTFLAGS -C linker=riscv64-linux-gnu-gcc" \
77+
; fi && \
78+
if [ $TARGETARCH = "amd64" ] && [ "$RUSTFLAGS" = "" ]; then \
79+
case "$TARGETVARIANT" in \
80+
# x86-64-v2 with AES-NI
81+
"v2") export RUSTFLAGS="-C target-cpu=x86-64-v2" ;; \
82+
# x86-64-v3 with AES-NI
83+
"v3") export RUSTFLAGS="-C target-cpu=x86-64-v3 -C target-feature=+aes" ;; \
84+
# v4 is compiled for Zen 4+
85+
"v4") export RUSTFLAGS="-C target-cpu=znver4" ;; \
86+
# Default build is for Skylake
87+
*) export RUSTFLAGS="-C target-cpu=skylake" ;; \
88+
esac \
89+
; fi && \
90+
if [ $BUILDARCH != "amd64" ] && [ $TARGETARCH = "amd64" ]; then \
91+
export RUSTFLAGS="$RUSTFLAGS -C linker=x86_64-linux-gnu-gcc" \
92+
; fi && \
93+
RUSTC_TARGET_ARCH=$(echo $TARGETARCH | sed "s/amd64/x86_64/g" | sed "s/arm64/aarch64/g" | sed "s/riscv64/riscv64gc/g") && \
94+
/root/.cargo/bin/cargo -Zgitoxide -Zgit build \
95+
--locked \
96+
-Z build-std \
97+
--profile $PROFILE \
98+
--bin subspace-gateway \
99+
--target $RUSTC_TARGET_ARCH-unknown-linux-gnu && \
100+
mv target/*/*/subspace-gateway subspace-gateway && \
101+
rm -rf target
102+
103+
FROM ubuntu:22.04
104+
105+
COPY --from=0 /code/subspace-gateway /subspace-gateway
106+
107+
USER nobody:nogroup
108+
109+
ENTRYPOINT ["/subspace-gateway"]
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
*
2+
!/crates
3+
!/domains
4+
!/orml
5+
!/shared
6+
!/test
7+
!/Cargo.lock
8+
!/Cargo.toml
9+
!/rust-toolchain.toml

0 commit comments

Comments
 (0)