forked from gameap/gameap
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
69 lines (48 loc) · 1.84 KB
/
Dockerfile
File metadata and controls
69 lines (48 loc) · 1.84 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
67
68
69
# ui builder image
FROM node:24-alpine AS uibuilder
WORKDIR /app
COPY web/frontend/package*.json ./web/frontend/
RUN --mount=type=cache,target=/root/.npm \
cd /app/web/frontend && npm ci
COPY web ./web
RUN cd /app/web/frontend && npm run build --if-present
# builder image
FROM golang:1.25-alpine AS builder
WORKDIR /app
COPY go.mod go.sum ./
RUN --mount=type=cache,target=/go/pkg/mod \
go mod download
COPY . .
COPY --from=uibuilder /app/web/static/dist /app/web/static/dist
ARG VERSION=dev
ARG BUILD_DATE=unknown
ARG TARGETOS
ARG TARGETARCH
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build \
-ldflags="-w -s -X 'github.com/gameap/gameap/internal/application/defaults.Version=${VERSION}' -X 'github.com/gameap/gameap/internal/application/defaults.BuildDate=${BUILD_DATE}'" \
-o gameap \
./cmd/gameap
# production image
FROM alpine:3.21
LABEL org.opencontainers.image.title="GameAP" \
org.opencontainers.image.description="Game server control panel API" \
org.opencontainers.image.vendor="GameAP" \
org.opencontainers.image.url="https://gameap.com" \
org.opencontainers.image.source="https://github.com/gameap/gameap" \
org.opencontainers.image.licenses="MIT"
RUN apk add --no-cache ca-certificates tzdata && \
addgroup -g 1000 gameap && \
adduser -D -u 1000 -G gameap gameap
COPY --from=builder --chown=gameap:gameap /app/gameap /usr/bin/gameap
USER gameap
WORKDIR /var/lib/gameap
ENV DATABASE_DRIVER=sqlite \
DATABASE_URL=file:/db.sqlite \
HTTP_HOST=0.0.0.0 \
HTTP_PORT=8025
EXPOSE 8025
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:8025/api/health || exit 1
ENTRYPOINT ["/usr/bin/gameap"]