forked from Varckin/amneziawg-install
-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathDockerfile
More file actions
45 lines (33 loc) · 1.58 KB
/
Copy pathDockerfile
File metadata and controls
45 lines (33 loc) · 1.58 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
# ── Stage 1: build ────────────────────────────────────────────────────────────
FROM rust:1.78-slim AS builder
WORKDIR /build
# Cache dependency compilation separately from application code.
COPY Cargo.toml Cargo.lock ./
RUN mkdir src && echo 'fn main() {}' > src/main.rs
RUN cargo build --release --locked
RUN rm -f target/release/deps/amneziawg_web*
# Build the real application.
COPY . .
RUN cargo build --release --locked
# ── Stage 2: runtime ─────────────────────────────────────────────────────────
FROM debian:bookworm-slim AS runtime
# Create a dedicated non-root user.
RUN useradd --system --no-create-home --shell /usr/sbin/nologin awg-web
# Install CA certificates (needed for outbound TLS if ever added).
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Copy binary.
COPY --from=builder /build/target/release/amneziawg-web /usr/local/bin/amneziawg-web
# Runtime directory for the SQLite database.
RUN mkdir -p /data && chown awg-web:awg-web /data
USER awg-web
WORKDIR /data
# Default environment (override at runtime via -e or --env-file).
ENV AWG_WEB_LISTEN=0.0.0.0:8080 \
AWG_WEB_DB=/data/awg-web.db \
AWG_CONFIG_DIR=/etc/amnezia/amneziawg/clients \
AWG_POLL_INTERVAL=30 \
RUST_LOG=amneziawg_web=info
EXPOSE 8080
ENTRYPOINT ["/usr/local/bin/amneziawg-web"]