-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathDockerfile
More file actions
104 lines (78 loc) · 3.76 KB
/
Dockerfile
File metadata and controls
104 lines (78 loc) · 3.76 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# ==============================================================================
# Traceway All-in-One Docker Image
# Includes: Frontend (embedded), Backend (Go), ClickHouse, PostgreSQL
# Managed by supervisord
# ==============================================================================
# ==============================================================================
# Stage 1: Build Frontend
# ==============================================================================
FROM node:22-alpine AS frontend-builder
WORKDIR /app/frontend
COPY frontend/package.json frontend/package-lock.json ./
RUN npm ci
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
RUN apk add --no-cache git
COPY backend/ ./
COPY --from=frontend-builder /app/frontend/build ./static/frontend/
RUN go mod edit -dropreplace=go.tracewayapp.com -dropreplace=go.tracewayapp.com/tracewaygin
RUN go mod tidy
RUN go mod download
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -tags "pgch" -ldflags="-s -w" -o /traceway ./cmd/traceway
# ==============================================================================
# Stage 3: ClickHouse binary source
# ==============================================================================
FROM clickhouse/clickhouse-server:24.8-alpine AS clickhouse-source
# ==============================================================================
# Stage 4: Runtime image
# ==============================================================================
FROM debian:bookworm-slim
RUN apt-get update && apt-get install -y --no-install-recommends \
supervisor \
ca-certificates \
curl \
musl \
postgresql \
postgresql-client \
&& rm -rf /var/lib/apt/lists/* \
&& mkdir -p /var/log/supervisor \
&& mkdir -p /var/lib/clickhouse \
&& mkdir -p /var/log/clickhouse-server \
&& mkdir -p /etc/clickhouse-server/config.d \
&& mkdir -p /etc/clickhouse-server/users.d
# ClickHouse binary + symlinks
COPY --from=clickhouse-source /usr/bin/clickhouse /usr/bin/clickhouse
COPY --from=clickhouse-source /etc/clickhouse-server/config.xml /etc/clickhouse-server/config.xml
COPY --from=clickhouse-source /etc/clickhouse-server/users.xml /etc/clickhouse-server/users.xml
RUN ln -s /usr/bin/clickhouse /usr/bin/clickhouse-server \
&& ln -s /usr/bin/clickhouse /usr/bin/clickhouse-client
# Go backend binary
COPY --from=backend-builder /traceway /usr/local/bin/traceway
# Configuration files
COPY docker/supervisord.conf /etc/supervisor/supervisord.conf
COPY docker/clickhouse-config.xml /etc/clickhouse-server/config.d/docker.xml
COPY docker/clickhouse-users.xml /etc/clickhouse-server/users.d/docker.xml
COPY docker/wait-for-clickhouse.sh /usr/local/bin/wait-for-clickhouse.sh
COPY docker/start-backend.sh /usr/local/bin/start-backend.sh
COPY docker/init-postgres.sh /usr/local/bin/init-postgres.sh
RUN chmod +x /usr/local/bin/wait-for-clickhouse.sh \
&& chmod +x /usr/local/bin/start-backend.sh \
&& chmod +x /usr/local/bin/init-postgres.sh
# Create clickhouse user and set permissions
RUN useradd -r -s /bin/false clickhouse \
&& chown -R clickhouse:clickhouse /var/lib/clickhouse \
&& chown -R clickhouse:clickhouse /var/log/clickhouse-server
WORKDIR /app
COPY backend/.env.docker /app/.env
ENV GIN_MODE=release
VOLUME ["/var/lib/clickhouse", "/var/lib/postgresql/data"]
EXPOSE 80 8082
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
CMD curl -f http://localhost/health || exit 1
CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/supervisord.conf"]