-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathDockerfile.minimal
More file actions
80 lines (59 loc) · 2.5 KB
/
Dockerfile.minimal
File metadata and controls
80 lines (59 loc) · 2.5 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
74
75
76
77
78
79
80
# ==============================================================================
# Traceway Minimal Docker Image
# Single binary serving both API and Frontend
# Designed for small instances with external ClickHouse
# Target image size: ~20-30MB
# ==============================================================================
# ==============================================================================
# Stage 1: Build Frontend
# ==============================================================================
FROM node:22-alpine AS frontend-builder
WORKDIR /app/frontend
# Copy package files first for better caching
COPY frontend/package.json frontend/package-lock.json ./
# Install dependencies
RUN npm ci
# Copy source and build
COPY frontend/ ./
ENV CLOUD_MODE=false
RUN npm run build
# ==============================================================================
# Stage 2: Build Backend with embedded frontend
# ==============================================================================
FROM golang:1.25-alpine AS backend-builder
WORKDIR /app/backend
# Install build dependencies
RUN apk add --no-cache git
# Copy all backend source
COPY backend/ ./
# Copy built frontend for embedding
COPY --from=frontend-builder /app/frontend/build ./static/frontend/
# Strip local replace directives and download dependencies
RUN go mod edit -dropreplace=go.tracewayapp.com -dropreplace=go.tracewayapp.com/tracewaygin
RUN go mod tidy
RUN go mod download
# Build with embedded static files
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -tags "pgch" -ldflags="-s -w" -o /traceway ./cmd/traceway
# ==============================================================================
# Stage 3: Minimal runtime image
# ==============================================================================
FROM alpine:3.20
# Install minimal runtime dependencies
# - ca-certificates: for HTTPS connections to external ClickHouse
# - tzdata: for timezone support
RUN apk add --no-cache ca-certificates tzdata
# Copy the binary
COPY --from=backend-builder /traceway /usr/local/bin/traceway
# Create app directory
WORKDIR /app
# Environment variables (can be overridden at runtime)
ENV GIN_MODE=release
# Expose ports
# 80: Frontend + API
# 8082: Direct API access
EXPOSE 80 8082
# Health check using wget (alpine-native, no curl needed)
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD wget -qO- http://localhost/health || exit 1
# Run the binary directly (no systemd needed)
ENTRYPOINT ["/usr/local/bin/traceway"]