-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContainerfile
More file actions
43 lines (30 loc) · 1.1 KB
/
Containerfile
File metadata and controls
43 lines (30 loc) · 1.1 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
# --- Build Stage ---
FROM docker.io/rust:1.92-slim-bookworm as builder
# Optimization: install dependencies separately to cache layers
RUN apt-get update && apt-get install -y \
pkg-config \
libssl-dev \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /usr/src/app
COPY . .
# Build the release binary with optimized settings
RUN cargo build --release --bin clear_urls_bot
# --- Runtime Stage ---
FROM docker.io/debian:bookworm-slim
# Create a non-root user for security (Podman compatible)
RUN groupadd -r clearurls && useradd -r -g clearurls clearurls
RUN apt-get update && apt-get install -y \
libssl3 \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy assets and binary
COPY --from=builder /usr/src/app/target/release/clear_urls_bot /usr/local/bin/clear_urls_bot
COPY --from=builder /usr/src/app/templates ./templates
# Ensure the database file can be written if using SQLite
RUN touch bot.db && chown clearurls:clearurls bot.db && chown -R clearurls:clearurls /app
USER clearurls
EXPOSE 3000
ENV APP_ENV=production
ENV RUST_LOG=clear_urls_bot=info
CMD ["clear_urls_bot"]