-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
66 lines (45 loc) · 1.41 KB
/
Dockerfile
File metadata and controls
66 lines (45 loc) · 1.41 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# --- Builder Stage -----------------------------------------------------------
FROM golang:1.25-bookworm AS builder
WORKDIR /app
RUN apt-get update && \
apt-get install -y --no-install-recommends \
ca-certificates \
tzdata \
libwebp-dev && \
rm -rf /var/lib/apt/lists/*
RUN useradd \
--uid 10001 \
--no-create-home \
--home-dir /nonexistent \
--shell /usr/sbin/nologin \
appuser
ENV CGO_ENABLED=1 GOOS=linux GOARCH=amd64
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN go build -ldflags="-w -s" -o centra-server ./cmd/centra-server
# --- Runtime Stage -----------------------------------------------------------
FROM debian:sid-slim AS runtime
WORKDIR /app
RUN apt-get update && \
apt-get install -y --no-install-recommends \
git \
openssh-client \
ca-certificates \
tzdata \
libwebp7 && \
rm -rf /var/lib/apt/lists/*
# make friends with github
RUN mkdir -p /etc/ssh && \
ssh-keyscan github.com >> /etc/ssh/ssh_known_hosts
# Prepare a writable keys dir for appuser
RUN mkdir -p /keys && chown 10001:10001 /keys
RUN mkdir -p /content && chown 10001:10001 /content
COPY --from=builder /etc/passwd /etc/passwd
COPY --from=builder /etc/group /etc/group
COPY --from=builder /app/centra-server /app/centra-server
ENV KEYS_DIR=/keys
USER appuser:appuser
VOLUME ["/keys", "/content"]
EXPOSE 3000
ENTRYPOINT ["/app/centra-server"]