docker: add server Dockerfile with multi-stage build
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
.git
|
||||
.gitignore
|
||||
.idea
|
||||
.vscode
|
||||
dist
|
||||
data
|
||||
client
|
||||
server
|
||||
*.exe
|
||||
*.test
|
||||
*.out
|
||||
*.zip
|
||||
Makefile
|
||||
package.bat
|
||||
LICENSE
|
||||
README.md
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
FROM golang:1.26-alpine AS build
|
||||
|
||||
RUN apk add --no-cache git
|
||||
|
||||
WORKDIR /src
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download
|
||||
|
||||
COPY . .
|
||||
|
||||
ARG VERSION=1.0.0
|
||||
ARG BUILD_TIME
|
||||
|
||||
RUN CGO_ENABLED=0 GOOS=linux go build \
|
||||
-ldflags "-s -w -X 'main.Version=${VERSION}' -X 'main.BuildTime=${BUILD_TIME}'" \
|
||||
-o /out/monitor-server ./cmd/server
|
||||
|
||||
# ── Runtime ──
|
||||
FROM alpine:3.20
|
||||
|
||||
RUN apk add --no-cache ca-certificates tzdata
|
||||
|
||||
WORKDIR /app
|
||||
COPY --from=build /out/monitor-server .
|
||||
COPY server.yaml .
|
||||
|
||||
RUN mkdir -p data
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
VOLUME ["/app/data"]
|
||||
|
||||
ENTRYPOINT ["./monitor-server"]
|
||||
Reference in New Issue
Block a user