-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
88 lines (61 loc) · 1.92 KB
/
Dockerfile
File metadata and controls
88 lines (61 loc) · 1.92 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
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# syntax=docker/dockerfile:1.7
# --- Build base ---
FROM alpine:3.23.3 AS chef
ARG RUST_LOG=info
ARG CUSTOM_SETUP=""
ENV RUST_LOG=${RUST_LOG}
ENV CC=clang
ENV CXX=clang++
RUN set -eu; \
if [ -n "$CUSTOM_SETUP" ]; then \
echo "$CUSTOM_SETUP" | base64 -d > /tmp/custom-setup.sh; \
chmod +x /tmp/custom-setup.sh; \
/bin/sh -eu /tmp/custom-setup.sh; \
rm -f /tmp/custom-setup.sh; \
fi
RUN apk update && apk add --no-cache \
build-base \
cargo \
clang \
clang-dev \
linux-headers \
openssl-dev
RUN --mount=type=cache,target=/root/.cargo/registry \
--mount=type=cache,target=/root/.cargo/git \
cargo install cargo-chef --locked
WORKDIR /srv
# --- Dependency planning ---
FROM chef AS planner
COPY . .
RUN cargo chef prepare --recipe-path recipe.json
# --- Dependency build ---
FROM chef AS cacher
COPY --from=planner /srv/recipe.json recipe.json
RUN --mount=type=cache,target=/root/.cargo/registry \
--mount=type=cache,target=/root/.cargo/git \
--mount=type=cache,target=/srv/target \
cargo chef cook --release --recipe-path recipe.json
# --- Application build ---
FROM chef AS builder
COPY . .
RUN --mount=type=cache,target=/root/.cargo/registry \
--mount=type=cache,target=/root/.cargo/git \
--mount=type=cache,target=/srv/target \
cargo build --release && \
cp /srv/target/release/journal-sdk /tmp/journal-sdk
# --- Deploy ---
FROM alpine:3.23.3
WORKDIR /srv
ARG CUSTOM_SETUP=""
RUN set -eu; \
if [ -n "$CUSTOM_SETUP" ]; then \
echo "$CUSTOM_SETUP" | base64 -d > /tmp/custom-setup.sh; \
chmod +x /tmp/custom-setup.sh; \
/bin/sh -eu /tmp/custom-setup.sh; \
rm -f /tmp/custom-setup.sh; \
fi
COPY --from=builder /usr/lib/libgcc_s.so.1 /usr/lib/
COPY --from=builder /usr/lib/libstdc++.so.6* /usr/lib/
COPY --from=builder /tmp/journal-sdk ./journal-sdk
ENTRYPOINT ["./journal-sdk"]
CMD ["--port", "80", "--database", "db"]