-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
44 lines (40 loc) · 1.54 KB
/
Dockerfile
File metadata and controls
44 lines (40 loc) · 1.54 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
# Stage 1: Build the application
FROM rust:bookworm AS builder
RUN USER=root cargo new --bin app
WORKDIR /app
RUN apt-get update && apt-get install --no-install-recommends -y \
build-essential=12.9 \
cmake=3.25.1-1 \
openssl=3.0.18-1~deb12u2\
libssl-dev=3.0.18-1~deb12u2\
libftdi1=0.20-4+b1 \
libftdi1-dev=1.5-6+b2 \
git=1:2.39.5-0+deb12u3 && \
rm -rf /var/lib/apt/lists/*
COPY . .
# Build the application in release mode
RUN cargo build --release --no-default-features --features=prod && cargo build --no-default-features --features dev
# Stage 2: Create the runtime image
FROM debian:bookworm-slim AS prod
# Required for static linking
RUN apt-get update && apt-get install --no-install-recommends -y \
openssl=3.0.18-1~deb12u2\
libssl-dev=3.0.18-1~deb12u2 &&\
rm -rf /var/lib/apt/lists/*
# Copy the build artifact from the builder stage
COPY --from=builder /app/target/release/presence-detector /usr/local/bin/presence-detector
# Set the startup command to run the binary
CMD ["presence-detector"]
# Stage 3: Create the development image
FROM debian:bookworm-slim AS dev
# Required for static linking
RUN apt-get update && apt-get install --no-install-recommends -y \
openssl=3.0.18-1~deb12u2 \
libssl-dev=3.0.18-1~deb12u2 \
libftdi1=0.20-4+b1 \
libftdi1-dev=1.5-6+b2 &&\
rm -rf /var/lib/apt/lists/*
# Copy the build artifact from the builder stage
COPY --from=builder /app/target/debug/presence-detector /usr/local/bin/presence-detector
# Set the startup command to run the binary
CMD ["presence-detector"]