-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
64 lines (48 loc) · 1.68 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
####################################################################################################
## Builder
####################################################################################################
FROM docker.io/library/rust:1.78-slim-bookworm AS builder
RUN apt-get update && \
apt-get install -y \
pkg-config \
libssl-dev && \
rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Create a dummy project to cache dependencies
RUN cargo new --bin dummy
WORKDIR /app/dummy
# Copy only the dependency files first
COPY Cargo.toml Cargo.lock ./
# Update the dummy main.rs to use our actual dependencies
RUN sed -i 's/name = "dummy"/name = "ghost-resend-mailer"/' Cargo.toml
# Build dependencies only
RUN cargo build --release
RUN rm src/*.rs
# Copy the actual source code
COPY ./src ./src
# Build the application
RUN touch src/main.rs && cargo build --release
# Move the built binary to a known location
RUN cp target/release/ghost-resend-mailer /app/ghost-resend-mailer
####################################################################################################
## Final image
####################################################################################################
FROM docker.io/library/debian:bookworm-slim
# Install required packages
RUN apt-get update && \
apt-get install -y \
ca-certificates \
openssl \
curl \
libc6 && \
rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy our build
COPY --from=builder /app/ghost-resend-mailer /app/ghost-resend-mailer
RUN chmod +x /app/ghost-resend-mailer
# Environment variables
ENV RUST_LOG_STYLE=never
ENV RUST_LOG=info
# Expose the port the app runs on
EXPOSE 3000
CMD ["/app/ghost-resend-mailer"]