-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
60 lines (45 loc) · 1.69 KB
/
Copy pathDockerfile
File metadata and controls
60 lines (45 loc) · 1.69 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
# ==========================================
# Stage 1: Build the Vite/Vanilla JS Frontend
# ==========================================
FROM node:20-alpine AS frontend-builder
WORKDIR /app/frontend
# Install dependencies and build
COPY frontend/package*.json ./
RUN npm ci
COPY frontend/ ./
RUN npm run build
# ==========================================
# Stage 2: Build the Go Backend
# ==========================================
FROM golang:1.25-alpine AS backend-builder
WORKDIR /app/backend
# go-sqlite3 requires cgo, which requires a C compiler
RUN apk add --no-cache gcc musl-dev
# Download Go modules
COPY backend/go.mod backend/go.sum ./
RUN go mod download
# Copy source and build the binary
COPY backend/ ./
RUN CGO_ENABLED=1 GOOS=linux go build -o shipper cmd/shipper/main.go
# ==========================================
# Stage 3: The Final Minimal Runtime
# ==========================================
FROM alpine:latest
# Install runtime dependencies: Git (for cloning) and Docker CLI (for buildx)
RUN apk add --no-cache git docker-cli docker-cli-buildx tzdata git-lfs && git lfs install
WORKDIR /app
# Copy the compiled Go binary
COPY --from=backend-builder /app/backend/shipper /app/shipper
# Copy the compiled Vite frontend static files
COPY --from=frontend-builder /app/frontend/dist /app/static
# Set default environment variables
ENV SHIPPER_PORT=8080
ENV SHIPPER_STATIC_DIR=/app/static
ENV SHIPPER_DATA_DIR=/app/data
ENV SHIPPER_DB_PATH=/app/data/shipper.db
ENV SHIPPER_REGISTRY=localhost:5000
LABEL org.opencontainers.image.source https://github.com/Sarin-jacob/Shipper
# Create the data directory so SQLite has a place to write
RUN mkdir -p /app/data
EXPOSE 8080
ENTRYPOINT ["/app/shipper"]