-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
57 lines (39 loc) · 1.28 KB
/
Dockerfile
File metadata and controls
57 lines (39 loc) · 1.28 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
# Frontend build stage
FROM node:24-alpine AS frontend-builder
WORKDIR /app/frontend
# Copy frontend package files
COPY frontend/package.json frontend/pnpm-lock.yaml ./
# Install pnpm and dependencies
RUN npm install -g pnpm && pnpm install
# Copy frontend source
COPY frontend/ ./
# Build frontend
RUN pnpm run build
# Backend build stage
FROM golang:1.25.0-alpine AS backend-builder
# Define build arguments for version, commit, and date.
ARG VERSION="unknown"
ARG COMMIT_HASH="unknown"
ARG BUILD_DATE="unknown"
# Install dependencies
RUN apk add --no-cache ca-certificates
# Set working directory
WORKDIR /app
# Copy go mod files
COPY go.mod go.sum ./
RUN go mod download
# Copy source code
COPY . .
# Copy built frontend from previous stage
COPY --from=frontend-builder /app/frontend/dist ./frontend/dist
# Build the application with embedded frontend
RUN go build -trimpath -ldflags="-w -s -X 'main.version=${VERSION}' -X 'main.commitHash=${COMMIT_HASH}' -X 'main.buildDate=${BUILD_DATE}'" -o bin/sentinel ./cmd/sentinel
# Final stage
FROM alpine:latest
# Install ca-certificates for HTTPS requests
RUN apk --no-cache add ca-certificates tzdata curl
WORKDIR /root/
# Copy binary from builder stage
COPY --from=backend-builder /app/bin/sentinel .
# Run the binary
CMD ["./sentinel", "start"]