|
| 1 | +### |
| 2 | +##: Set up native compile |
| 3 | +### |
| 4 | +FROM rust:bookworm AS build-native |
| 5 | +RUN apt-get update && apt-get install -y ca-certificates openssl sqlite3 |
| 6 | +RUN echo $(arch)-unknown-linux-gnu > /tmp/rust-target |
| 7 | + |
| 8 | +### |
| 9 | +##: Set up arm64 cross compile |
| 10 | +### |
| 11 | +FROM --platform=$BUILDPLATFORM rust:bookworm AS build-cross-arm64 |
| 12 | + |
| 13 | +ARG CC=aarch64-linux-gnu-gcc |
| 14 | +ARG CXX=aarch64-linux-gnu-g++ |
| 15 | +ARG PKG_CONFIG_SYSROOT_DIR=/usr/lib/aarch64-linux-gnu/ |
| 16 | +ARG CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc |
| 17 | + |
| 18 | +RUN dpkg --add-architecture arm64 |
| 19 | +RUN apt-get update |
| 20 | +RUN apt-get install -y g++-aarch64-linux-gnu |
| 21 | +RUN apt-get install -y libsqlite3-dev:arm64 libssl-dev:arm64 |
| 22 | + |
| 23 | +RUN rustup target add aarch64-unknown-linux-gnu |
| 24 | +RUN echo aarch64-unknown-linux-gnu > /tmp/rust-target |
| 25 | + |
| 26 | +### |
| 27 | +##: Build targets |
| 28 | +### |
| 29 | +FROM build-native AS build-arm64-on-arm64 |
| 30 | +FROM build-native AS build-amd64-on-amd64 |
| 31 | +FROM build-cross-arm64 AS build-arm64-on-amd64 |
| 32 | + |
| 33 | +##### |
| 34 | + |
| 35 | +### |
| 36 | +##: Build stage |
| 37 | +### |
| 38 | +FROM build-$TARGETARCH-on-$BUILDARCH as builder |
| 39 | + |
| 40 | +WORKDIR /opt/helipad |
| 41 | + |
| 42 | +COPY . /opt/helipad |
| 43 | +RUN cargo build --release --target=$(cat /tmp/rust-target) |
| 44 | +RUN cp ./target/$(cat /tmp/rust-target)/release/helipad . |
| 45 | + |
| 46 | +### |
| 47 | +##: Bundle stage |
| 48 | +### |
| 49 | +FROM --platform=$TARGETPLATFORM debian:bookworm-slim AS runner |
| 50 | + |
| 51 | +RUN apt-get update && \ |
| 52 | + apt-get install -y ca-certificates openssl sqlite3 && \ |
| 53 | + rm -fr /var/lib/apt/lists/* |
| 54 | + |
| 55 | +WORKDIR /opt/helipad |
| 56 | + |
| 57 | +COPY --from=builder /opt/helipad/helipad . |
| 58 | +COPY --from=builder /opt/helipad/webroot ./webroot |
| 59 | +COPY --from=builder /opt/helipad/helipad.conf . |
| 60 | + |
| 61 | +RUN useradd -u 1000 helipad |
| 62 | +RUN mkdir /data && chown -R 1000:1000 /data |
| 63 | + |
| 64 | +USER helipad |
| 65 | + |
| 66 | +EXPOSE 2112/tcp |
| 67 | + |
| 68 | +ENTRYPOINT ["/opt/helipad/helipad"] |
0 commit comments