-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathDockerfile.sqlite
More file actions
75 lines (52 loc) · 2.54 KB
/
Dockerfile.sqlite
File metadata and controls
75 lines (52 loc) · 2.54 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
# ==============================================================================
# Traceway SQLite Docker Image
# Single binary serving API and Frontend with embedded SQLite.
# No external databases required. Optional S3 for blob storage.
# ==============================================================================
# ==============================================================================
# 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 (no pgch tag = SQLite mode)
# ==============================================================================
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
# Build WITHOUT the pgch tag so the SQLite codepath in app/db/db_sqlite.go
# is selected. modernc.org/sqlite is pure Go, so CGO_ENABLED=0 is fine.
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o /traceway ./cmd/traceway
# ==============================================================================
# Stage 3: Minimal runtime image
# ==============================================================================
FROM alpine:3.20
RUN apk add --no-cache ca-certificates tzdata
COPY --from=backend-builder /traceway /usr/local/bin/traceway
RUN mkdir -p /data && chmod 755 /data
WORKDIR /app
# SQLite databases and local blob storage both live under /data so a single
# bind-mount or named volume covers all persistent state.
ENV GIN_MODE=release \
DB_TYPE=sqlite \
SQLITE_PATH=/data/traceway.db \
STORAGE_TYPE=local \
STORAGE_PATH=/data/storage
# /data holds both SQLite files and local blob storage. Mount a host folder
# or named volume there to persist state across restarts. We deliberately do
# NOT declare a VOLUME here so the image stays compatible with platforms that
# require platform-managed volumes (e.g. Railway).
EXPOSE 80 8082
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD wget -qO- http://localhost/health || exit 1
ENTRYPOINT ["/usr/local/bin/traceway"]