31 lines
980 B
Docker
31 lines
980 B
Docker
# syntax=docker/dockerfile:1
|
|||
|
|
#
|
||
|
|
# Build from the repository root:
|
||
|
|
# docker build -f services/worker/Dockerfile -t sorsfonalak/worker .
|
||
|
|
|
||
|
|
ARG RUST_VERSION=1.99
|
||
|
|
|
||
|
|
# --- 1. static (musl) build ----------------------------------------------------
|
||
|
|
FROM rust:${RUST_VERSION}-alpine AS build
|
||
|
|
RUN apk add --no-cache musl-dev
|
||
|
|
WORKDIR /app
|
||
|
|
COPY Cargo.toml Cargo.lock ./
|
||
|
|
COPY crates crates
|
||
|
|
COPY services services
|
||
|
|
RUN --mount=type=cache,target=/usr/local/cargo/registry,sharing=locked \
|
||
|
|
--mount=type=cache,target=/app/target,sharing=locked \
|
||
|
|
cargo build --release --locked -p worker \
|
||
|
|
&& cp target/release/worker /worker
|
||
|
|
|
||
|
|
# --- 2. runtime: the binary only (TLS roots are compiled in via webpki-roots) ---
|
||
|
|
FROM scratch
|
||
|
|
COPY --from=build /worker /worker
|
||
|
|
ENV BIND_ADDR=0.0.0.0:8082 \
|
||
|
|
LOG_FORMAT=json \
|
||
|
|
RUST_LOG=info
|
||
|
|
USER 65532:65532
|
||
|
|
EXPOSE 8082
|
||
|
|
HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \
|
||
|
|
CMD ["/worker", "healthcheck"]
|
||
|
|
ENTRYPOINT ["/worker"]
|