redsunlib/Dockerfile.armv7

44 lines
1.5 KiB
Docker
Raw Normal View History

####################################################################################################
## Builder
####################################################################################################
FROM --platform=$BUILDPLATFORM rust:slim AS builder
ENV CARGO_TARGET_ARMV7_UNKNOWN_LINUX_MUSLEABIHF_LINKER=arm-linux-gnueabihf-gcc
ENV CC_armv7_unknown_linux_musleabihf=arm-linux-gnueabihf-gcc
RUN apt-get update && apt-get -y install gcc-arm-linux-gnueabihf \
binutils-arm-linux-gnueabihf \
musl-tools
RUN rustup target add armv7-unknown-linux-musleabihf
2023-12-27 12:25:52 +13:00
WORKDIR /redlib
COPY . .
RUN cargo build --target armv7-unknown-linux-musleabihf --release
####################################################################################################
## Final image
####################################################################################################
FROM alpine:latest
# Import ca-certificates from builder
COPY --from=builder /usr/share/ca-certificates /usr/share/ca-certificates
COPY --from=builder /etc/ssl/certs /etc/ssl/certs
# Copy our build
2023-12-27 12:25:52 +13:00
COPY --from=builder /redlib/target/armv7-unknown-linux-musleabihf/release/redlib /usr/local/bin/redlib
# Use an unprivileged user.
2023-12-27 12:25:52 +13:00
RUN adduser --home /nonexistent --no-create-home --disabled-password redlib
USER redlib
# Tell Docker to expose port 8080
EXPOSE 8080
2023-12-27 12:25:52 +13:00
# Run a healthcheck every minute to make sure redlib is functional
HEALTHCHECK --interval=1m --timeout=3s CMD wget --spider --q http://localhost:8080/settings || exit 1
2023-12-27 12:25:52 +13:00
CMD ["redlib"]