-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathDockerfile
73 lines (48 loc) · 1.87 KB
/
Dockerfile
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
ARG target=""
# Setup chef
# NOTE: See /rust-toolchain.toml when updating.
FROM --platform=$BUILDPLATFORM rust:1.82.0-slim-bookworm AS base
RUN apt-get update && apt-get install pkg-config libssl-dev git -y
# TODO: Try and get https://github.com/cross-rs/cross working to simplify this.
ARG arch
RUN if [ "${arch}" = "aarch64-unknown-linux-gnu" ]; then \
dpkg --add-architecture arm64 && \
apt-get update && apt-get install libssl-dev:arm64 gcc-aarch64-linux-gnu zlib1g-dev:arm64 -y && \
rustup target add ${arch}; \
fi
RUN cargo install cargo-chef --locked
# Setup recipe
FROM base AS planner
WORKDIR /app
COPY . .
RUN cargo chef prepare --bin boilmaster --recipe-path recipe.json
# Build Boilmaster
FROM base AS builder
WORKDIR /app
COPY --from=planner /app/recipe.json recipe.json
RUN cargo chef cook --bin boilmaster --release --recipe-path recipe.json
COPY . .
ARG arch
ARG pkg-config-path
ARG pkg-config-sysroot-dir
ENV PKG_CONFIG_PATH=${pkg-config-path}
ENV PKG_CONFIG_SYSROOT_DIR=${pkg-config-sysroot-dir}
RUN cargo build --release --target ${arch} --bin boilmaster
# Create runtime image
FROM --platform=${target} debian:bookworm-slim AS runtime
# Redirect persistent data into one shared volume
ENV BM_VERSION_PATCH_DIRECTORY="/app/persist/patches"
ENV BM_SCHEMA_EXDSCHEMA_DIRECTORY="/app/persist/exdschema"
ENV BM_VERSION_DIRECTORY="/app/persist/versions"
ENV BM_SEARCH_SQLITE_DIRECTORY="/app/persist/search"
WORKDIR /app
RUN apt-get update && apt-get install -y git curl
ARG zlib
ARG arch
COPY --from=builder /lib/${zlib}/libz.so.1 /lib/${zlib}/libz.so.1
COPY --from=builder /app/boilmaster.toml /app/
COPY --from=builder /app/target/${arch}/release/boilmaster /app/
VOLUME /app/persist
HEALTHCHECK --start-period=45s --interval=15s --retries=3 --timeout=5s CMD curl -sf http://localhost:8080/health/live || exit 1
EXPOSE 8080
ENTRYPOINT ["/app/boilmaster"]