update build

This commit is contained in:
ayaka 2024-04-09 22:19:40 +12:00
parent 6684db5e82
commit 5f67eacf93

View File

@ -1,32 +1,34 @@
FROM rust:1.77.1-buster AS builder
## Builder
WORKDIR /app
FROM rust:alpine AS builder
COPY ./ ./
RUN apk add --no-cache musl-dev
RUN cargo build --release
WORKDIR /redlib
FROM debian:stable
COPY . .
ARG TARGET
RUN cargo build --target x86_64-unknown-linux-musl --release
RUN apt-get update
RUN apt-get install -y ca-certificates wget
## Final image
RUN apt-get clean -y; \
rm -rf /var/lib/apt/lists/* /var/cache/apt/*
FROM alpine:latest
COPY --from=builder /app/target/release/ /usr/local/bin
# 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
COPY --from=builder /redlib/target/x86_64-unknown-linux-musl/release/redlib /usr/local/bin/redlib
# Use an unprivileged user.
RUN adduser --home /nonexistent --no-create-home --disabled-password redlib
USER redlib
# Tell Docker to expose port 808
# Tell Docker to expose port 8080
EXPOSE 8080
# 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
CMD ["redlib"]
CMD ["redlib"]