-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Dockerfile
54 lines (39 loc) · 1.34 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
#######################################
# #
# Stage 1: building #
# #
#######################################
FROM docker.io/rust:1.82.0-slim-bookworm AS build
RUN apt-get update && apt-get install -y build-essential pkg-config libssl-dev libsqlite3-dev
ENV CARGO_HOME=/cargo
ENV CARGO_TARGET_DIR=/target
WORKDIR /app
COPY . /app
ARG RELEASE_BUILD=true
RUN --mount=type=cache,target=/cargo,sharing=locked \
--mount=type=cache,target=/target,sharing=locked \
if [ "$RELEASE_BUILD" = "true" ]; then \
cargo build --release; \
else \
cargo build; \
fi
# Move it out of the mounted cache, so we can copy it in the next stage.
RUN --mount=type=cache,target=/target,sharing=locked \
if [ "$RELEASE_BUILD" = "true" ]; then \
cp /target/release/baibot /baibot; \
else \
cp /target/debug/baibot /baibot; \
fi
#######################################
# #
# Stage 2: packaging #
# #
#######################################
FROM docker.io/debian:bookworm-slim
RUN apt-get update && apt-get install -y ca-certificates sqlite3 && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY --from=build /baibot .
ENTRYPOINT ["/bin/sh", "-c"]
CMD ["/app/baibot"]