-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDockerfile
41 lines (28 loc) · 1.32 KB
/
Dockerfile
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
# syntax=docker/dockerfile:1
########################################################################
## xx Cross-Compilation Helper
########################################################################
FROM --platform=${BUILDPLATFORM} tonistiigi/xx:1.2.1 AS xx
########################################################################
## Rust Builder
########################################################################
FROM --platform=${BUILDPLATFORM} rust:1.68.0-alpine3.17 as builder
# Copy over the xx cross-compilation helpers, then install the required
# compilers, linkers and development libraries.
COPY --from=xx / /
RUN apk update && apk add --no-cache clang lld musl-dev
# Copy the source itself.
WORKDIR /app
COPY ./ .
# Build the Rust binary (for the target platform).
ARG TARGETPLATFORM
RUN CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse \
xx-cargo build --release --target-dir ./build && \
xx-verify ./build/$(xx-cargo --print-target-triple)/release/groundcontrol && \
cp ./build/$(xx-cargo --print-target-triple)/release/groundcontrol /groundcontrol
########################################################################
## Final Image
########################################################################
FROM scratch
COPY --from=builder /groundcontrol /groundcontrol
ENTRYPOINT ["/groundcontrol"]