-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.server.arm64
36 lines (26 loc) · 1.45 KB
/
Dockerfile.server.arm64
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
FROM --platform=linux/amd64 rust:latest as builder
ARG TARGET="aarch64-unknown-linux-gnu"
ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++
ENV PKG_CONFIG_PATH="/usr/lib/aarch64-linux-gnu/pkgconfig"
ENV PKG_CONFIG_ALLOW_CROSS="true"
RUN dpkg --add-architecture arm64
RUN apt-get update && apt-get install -y bluez bluetooth libdbus-1-dev libdbus-1-dev:arm64 pkg-config
RUN apt-get install -y g++-aarch64-linux-gnu libc6-dev-arm64-cross
# Cross compile
RUN rustup target add $TARGET
RUN rustup toolchain install stable-$TARGET
WORKDIR /tmp
FROM --platform=linux/amd64 builder as build-cache
# Build dependencies first (first iterative builds of app)
RUN cd /tmp && USER=root cargo new --bin gvm_server
COPY gvm_server/Cargo.toml gvm_server/
RUN cargo build --release --target $TARGET --manifest-path=gvm_server/Cargo.toml --features=mqtt
FROM --platform=linux/amd64 build-cache as build-binary
COPY gvm_server/src gvm_server/src
RUN cargo build --release --target $TARGET --manifest-path=gvm_server/Cargo.toml --features=mqtt
FROM debian:stable-slim as final
ARG TARGET="aarch64-unknown-linux-gnu"
RUN apt-get update && apt-get install -y bluez bluetooth libdbus-1-3 && rm -rf /var/lib/apt/lists/*
COPY --from=build-binary /tmp/gvm_server/target/$TARGET/release/gvm_server /
COPY docker-entrypoint-server.sh /
ENTRYPOINT /docker-entrypoint-server.sh