forked from yuanweize/RouteLens
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
63 lines (42 loc) · 1.45 KB
/
Dockerfile
File metadata and controls
63 lines (42 loc) · 1.45 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
# Frontend Build Stage
FROM --platform=$BUILDPLATFORM node:20-alpine AS web-builder
WORKDIR /web
COPY web/package.json web/package-lock.json ./
RUN npm ci
COPY web/ ./
RUN npm run build
# Build Stage
FROM --platform=$BUILDPLATFORM golang:1.24-alpine AS builder
ARG TARGETOS
ARG TARGETARCH
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . .
# Copy built frontend assets
COPY --from=web-builder /web/dist ./web/dist
# Build with CGO disabled (pure Go sqlite)
RUN CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -ldflags="-s -w" -o routelens ./cmd/server
# Final Stage
FROM alpine:latest
WORKDIR /app
# Install Runtime Dependencies
# iputils (ping), mtr (traceroute), openssh-client (for speed test)
# setcap is needed to run ping/mtr without root (if we run as non-root user, but typically docker runs as root or we set caps)
RUN apk add --no-cache iputils mtr openssh-client libcap ca-certificates tzdata
# Create non-root user
RUN addgroup -S routelens && adduser -S routelens -G routelens
# Copy binary from builder
COPY --from=builder /app/routelens /usr/local/bin/routelens
# Set capabilities for raw socket (Ping/MTR)
RUN setcap cap_net_raw+ep /usr/local/bin/routelens
# Create data directory
RUN mkdir -p /data && chown -R routelens:routelens /data
# Switch to non-root user
USER routelens
# Expose API port
EXPOSE 8080
# Environment Defaults
ENV RS_DB_PATH=/data/routelens.db
ENV RS_HTTP_PORT=:8080
CMD ["/usr/local/bin/routelens"]