-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
55 lines (38 loc) · 1.17 KB
/
Copy pathDockerfile
File metadata and controls
55 lines (38 loc) · 1.17 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
FROM golang:1.24-bookworm AS builder
WORKDIR /go/src/fmd-server
ENV GOPATH=/go
# pre-download and only redownload in subsequent builds if they change
COPY go.mod go.sum ./
RUN go mod download && go mod verify
COPY go.mod .
COPY go.sum .
COPY main.go .
COPY cmd/ cmd/
COPY backend/ backend/
COPY user/ user/
COPY utils/ utils/
COPY web/ web/
RUN go build -o /tmp/fmd main.go
FROM debian:bookworm-slim
RUN apt update && \
apt install --no-install-recommends -y ca-certificates && \
rm -rf /var/lib/apt/lists/*
# Create user
RUN useradd --no-create-home --uid 1000 fmd-server
# Copy files and configure permissions
# Note that the directories must be executable (for file listing, etc.)
ARG BIN_FILE=/opt/fmd-server
ARG DB_DIR=/var/lib/fmd-server/db
COPY --from=builder /tmp/fmd "$BIN_FILE"
RUN chown fmd-server:fmd-server "$BIN_FILE" && \
chmod 0550 "$BIN_FILE"
RUN mkdir -p "$DB_DIR"
RUN chown -R fmd-server:fmd-server "$DB_DIR" && \
chmod -R 0660 "$DB_DIR" && \
chmod 0770 "$DB_DIR"
# Change to user
USER fmd-server
EXPOSE 8080/tcp
EXPOSE 8443/tcp
# XXX: Using $BIN_FILE doesn't work
ENTRYPOINT ["/opt/fmd-server", "serve", "--db-dir", "/var/lib/fmd-server/db"]