-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
53 lines (38 loc) · 1.41 KB
/
Dockerfile
File metadata and controls
53 lines (38 loc) · 1.41 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
# Optimized single-stage build for vertex
FROM golang:1.23-bullseye AS builder
# Install build dependencies in one layer
RUN apt-get update && apt-get install -y \
gcc \
libc6-dev \
libsqlite3-dev \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy go mod files first for better caching
COPY go.mod go.sum ./
RUN go mod download
# Copy source code (frontend should be pre-built by CI)
COPY . .
# Verify frontend dist exists (required for go:embed)
RUN ls -la web/dist/ || (echo "ERROR: web/dist directory missing! Frontend must be built before Docker build." && exit 1)
# Build the binary with optimizations
RUN CGO_ENABLED=1 go build -ldflags="-s -w" -o vertex
FROM alpine:latest
# Install runtime dependencies
# Use --no-scripts to avoid trigger issues in QEMU ARM64 builds
RUN apk --no-cache --no-scripts add ca-certificates sqlite && \
update-ca-certificates 2>/dev/null || true
WORKDIR /app
# Copy the binary
COPY --from=builder /app/vertex .
# Create directory for database
RUN mkdir -p /app/data
# Expose port (default 54321, configurable via PORT env var)
EXPOSE 54321
# Set environment variables
ENV DB_PATH=/app/data/vertex.db
ENV PORT=54321
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:${PORT}/ || exit 1
# Run the application with port from environment
CMD ["sh", "-c", "./vertex --port $PORT"]