-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathDockerfile
More file actions
73 lines (55 loc) · 1.58 KB
/
Copy pathDockerfile
File metadata and controls
73 lines (55 loc) · 1.58 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
70
71
72
73
# Web UI build stage
FROM node:22-alpine AS web-builder
WORKDIR /build
# Copy all web UI files
COPY web ./
# Install dependencies and build
RUN npm ci --prefer-offline
RUN npm run build
# Go build stage
FROM golang:1.26-alpine AS builder
# Install build dependencies
RUN apk add --no-cache \
git \
gcc \
musl-dev
WORKDIR /build
# Copy go mod files
COPY go.mod go.sum ./
RUN go mod download
# Copy source code
COPY . .
# Copy built web UI from web-builder stage
COPY --from=web-builder /build/dist ./web/dist
# Prepare web files for embedding
RUN mkdir -p internal/app/web && \
cp -r web/dist internal/app/web/ && \
{ \
echo 'package app'; \
echo ''; \
echo 'import "embed"'; \
echo ''; \
echo '//go:embed all:web/dist'; \
echo 'var webFSEmbed embed.FS'; \
echo ''; \
echo 'func init() {'; \
printf '\tWebFS = webFSEmbed\n'; \
echo '}'; \
} > internal/app/webfs_embed.go
# Build the application with version
ARG VERSION=dev
RUN CGO_ENABLED=1 GOOS=linux go build -ldflags="-w -s -X main.version=${VERSION}" -trimpath -tags netgo -o server ./cmd/server
# Runtime stage
FROM alpine:3.23
# Install CA certificates for HTTPS/TLS connections (Discord OAuth, etc.)
RUN apk add --no-cache ca-certificates
WORKDIR /app
# Copy binary from builder
COPY --from=builder /build/server .
# Expose port
EXPOSE 5000
# Health check
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
CMD wget -qO- http://localhost:5000/health || exit 1
# Run the application
ENTRYPOINT ["/app/server"]