-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
58 lines (41 loc) · 1.31 KB
/
Dockerfile
File metadata and controls
58 lines (41 loc) · 1.31 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
# ── Stage 1: Build React console ──
FROM node:22-alpine AS frontend
WORKDIR /app/web/console
COPY web/console/package.json web/console/package-lock.json* ./
RUN npm ci
COPY web/console/ .
RUN npm run build
# ── Stage 2: Build Go binary ──
FROM golang:1.25-alpine AS builder
# Install dependencies
RUN apk add --no-cache git
# Set working directory
WORKDIR /app
# Copy Go module files and download dependencies
COPY go.mod go.sum ./
RUN go mod download
# Copy the rest of the code
COPY . .
# Copy built frontend into the source tree so go:embed picks it up
COPY --from=frontend /app/web/console/dist ./web/console/dist
# Run tests (the build will fail if tests fail)
RUN go test -v ./...
# Build the application
RUN CGO_ENABLED=0 GOOS=linux go build -o /app/pipimink ./main.go
# ── Stage 3: Final image ──
FROM alpine:latest
# Install ca-certificates for secure connections
RUN apk --no-cache add ca-certificates
# Set working directory
WORKDIR /app
# Copy the binary from the builder stage
COPY --from=builder /app/pipimink .
# Copy any required configuration files
COPY --from=builder /app/.env* ./
COPY --from=builder /app/providers.json* ./
# Copy static assets for serving
COPY --from=builder /app/assets ./assets
# Expose the port the app runs on
EXPOSE 8080
# Command to run
CMD ["./pipimink"]