-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
39 lines (27 loc) · 883 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
32
33
34
35
36
37
38
39
FROM rust:1.82.0-alpine3.20 AS builder
RUN apk add --no-cache \
musl-dev \
openssl-dev
# Update package repositories
RUN apk update
WORKDIR /usr/src/dyncloud
COPY . .
RUN cargo build --release --features "mimalloc"
# Final stage: create a minimal runtime image
FROM alpine:3.20.3
# Update package repositories
RUN apk add --no-cache curl
RUN apk update
# Create a non-root user
RUN addgroup -g 1000 -S dyncloud && \
adduser -u 1000 -S -D -G dyncloud -H -h /home/dyncloud -s /bin/sh dyncloud
# Set the working directory
WORKDIR /home/dyncloud
# Copy the binaries from the builder stage
COPY --from=builder --chown=1000:1000 /usr/src/dyncloud/target/release/dyncloud /home/dyncloud/dyncloud
# Set permissions for the binary
RUN chmod +x /home/dyncloud/dyncloud
# Switch to non-root user
USER dyncloud
# Entrypoint command
ENTRYPOINT ["/home/dyncloud/dyncloud"]