-
Notifications
You must be signed in to change notification settings - Fork 46
Expand file tree
/
Copy pathDockerfile.riscv64.binary
More file actions
65 lines (53 loc) · 2.37 KB
/
Copy pathDockerfile.riscv64.binary
File metadata and controls
65 lines (53 loc) · 2.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# syntax=docker/dockerfile:1.7-labs
FROM rust:bookworm AS builder
ARG BUILD_PROFILE=release
# Fast local/test release override. Buildroot still uses Cargo.toml release profile.
# Set FAST_RELEASE=false to use the full release profile from Cargo.toml.
ARG FAST_RELEASE=true
ARG FAST_RELEASE_LTO=false
ARG FAST_RELEASE_CODEGEN_UNITS=16
RUN apt-get update && apt-get install -y --no-install-recommends \
git \
pkg-config \
gcc-riscv64-linux-gnu \
g++-riscv64-linux-gnu \
libc6-dev-riscv64-cross \
&& rm -rf /var/lib/apt/lists/*
RUN rustup target add riscv64gc-unknown-linux-gnu
WORKDIR /usr/src/app
COPY Cargo.toml Cargo.lock build.rs ./
COPY src/protos ./src/protos
RUN mkdir -p src && printf 'fn main() {}\n' > src/main.rs
RUN --mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=/usr/local/cargo/git \
if [ "${BUILD_PROFILE}" = "release" ]; then \
if [ "${FAST_RELEASE}" = "true" ]; then \
CARGO_PROFILE_RELEASE_LTO="${FAST_RELEASE_LTO}" \
CARGO_PROFILE_RELEASE_CODEGEN_UNITS="${FAST_RELEASE_CODEGEN_UNITS}" \
cargo build --release --target riscv64gc-unknown-linux-gnu || true; \
else \
cargo build --release --target riscv64gc-unknown-linux-gnu || true; \
fi; \
else \
cargo build --target riscv64gc-unknown-linux-gnu || true; \
fi
COPY . .
RUN --mount=type=cache,target=/usr/local/cargo/registry \
--mount=type=cache,target=/usr/local/cargo/git \
mkdir -p /out && \
if [ "${BUILD_PROFILE}" = "release" ]; then \
if [ "${FAST_RELEASE}" = "true" ]; then \
CARGO_PROFILE_RELEASE_LTO="${FAST_RELEASE_LTO}" \
CARGO_PROFILE_RELEASE_CODEGEN_UNITS="${FAST_RELEASE_CODEGEN_UNITS}" \
cargo build --release --target riscv64gc-unknown-linux-gnu; \
else \
cargo build --release --target riscv64gc-unknown-linux-gnu; \
fi && \
cp target/riscv64gc-unknown-linux-gnu/release/aa-proxy-rs /out/aa-proxy-rs; \
else \
cargo build --target riscv64gc-unknown-linux-gnu && \
cp target/riscv64gc-unknown-linux-gnu/debug/aa-proxy-rs /out/aa-proxy-rs; \
fi
FROM scratch AS export
COPY --from=builder /out/aa-proxy-rs /aa-proxy-rs
# DOCKER_BUILDKIT=1 docker build -f Dockerfile.riscv64.binary --target export --output type=local,dest=./output --build-arg BUILD_PROFILE=release .