-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
31 lines (24 loc) · 958 Bytes
/
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
##### Builder
FROM rust:alpine3.18 as builder
# Create fresh workspace
WORKDIR /usr/src
RUN apk add --no-cache musl-dev
RUN USER=root cargo new cloudflare-ddns
# Cache dependencies by themselves
COPY Cargo.toml Cargo.lock /usr/src/cloudflare-ddns/
WORKDIR /usr/src/cloudflare-ddns
RUN rustup target add x86_64-unknown-linux-musl
RUN cargo build --target x86_64-unknown-linux-musl --release
# Build the application
COPY src /usr/src/cloudflare-ddns/src/
RUN touch /usr/src/cloudflare-ddns/src/main.rs
RUN cargo build --target x86_64-unknown-linux-musl --release
##### Runtime
FROM alpine:3.21.2 AS runtime
# Copy generated binary in runtime
COPY --from=builder /usr/src/cloudflare-ddns/target/x86_64-unknown-linux-musl/release/cloudflare-ddns /usr/local/bin
RUN chmod +x /usr/local/bin/cloudflare-ddns
# Run as regular user (not root)
RUN addgroup -S appgroup && adduser -S appuser -u 10001 -G appgroup
USER 10001
CMD ["/usr/local/bin/cloudflare-ddns"]