-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
48 lines (43 loc) 路 1.95 KB
/
Copy pathDockerfile
File metadata and controls
48 lines (43 loc) 路 1.95 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
# syntax=docker/dockerfile:1
# ---- chef base: shared Rust toolchain + cargo-chef ----
FROM rust:1.96-alpine AS chef
RUN apk add --no-cache musl-dev
RUN cargo install cargo-chef --locked
WORKDIR /app
# ---- planner: produce a recipe from the manifests only ----
# cargo-chef inspects the workspace, so COPY . . (kept small by .dockerignore)
FROM chef AS planner
COPY . .
RUN cargo chef prepare --recipe-path recipe.json
# ---- development: cached debug dependencies + hot reload ----
FROM chef AS development
ARG PARSEON_FEATURES=postgres-storage
ENV PARSEON_FEATURES=${PARSEON_FEATURES}
RUN apk add --no-cache watchexec
COPY --from=planner /app/recipe.json recipe.json
RUN cargo chef cook --recipe-path recipe.json --no-default-features --features "${PARSEON_FEATURES}"
COPY . .
EXPOSE 8080
CMD ["sh", "-c", "exec watchexec --restart --stop-signal SIGINT --exts rs,toml,lock,sql -- cargo run --no-default-features --features \"${PARSEON_FEATURES}\""]
# ---- builder: pre-build deps, then the real binary ----
FROM chef AS builder
ARG PARSEON_FEATURES=postgres-storage
COPY --from=planner /app/recipe.json recipe.json
RUN --mount=type=cache,target=/root/.cargo/registry \
--mount=type=cache,target=/app/target \
cargo chef cook --release --recipe-path recipe.json --no-default-features --features "${PARSEON_FEATURES}"
COPY . .
RUN --mount=type=cache,target=/root/.cargo/registry \
--mount=type=cache,target=/app/target \
cargo build --release --no-default-features --features "${PARSEON_FEATURES}" && \
cp /app/target/release/parseon /usr/local/bin/parseon
# ---- runtime: minimal alpine, non-root, healthcheck ----
FROM alpine:3.20 AS runtime
RUN apk add --no-cache ca-certificates wget && \
adduser -D -u 1000 parseon
COPY --from=builder /usr/local/bin/parseon /usr/local/bin/parseon
USER parseon
EXPOSE 8080
HEALTHCHECK --interval=10s --timeout=5s --start-period=10s --retries=5 \
CMD wget -qO- http://127.0.0.1:8080/healthz || exit 1
ENTRYPOINT ["parseon"]