-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
63 lines (44 loc) · 1.39 KB
/
Dockerfile
File metadata and controls
63 lines (44 loc) · 1.39 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
# Multi-stage Dockerfile for MVG Observer
# Stage 1: Build the frontend
FROM node:24-alpine AS frontend-builder
WORKDIR /app
# Copy package files
COPY frontend/package.json frontend/pnpm-lock.yaml ./
# Install dependencies
RUN npm install -g pnpm && pnpm install --frozen-lockfile
# Copy frontend source
COPY frontend/app ./app
COPY frontend/public ./public
COPY frontend/vite.config.ts ./
COPY frontend/tsconfig.json ./
COPY frontend/tailwind.config.ts ./
COPY frontend/postcss.config.js ./
# Build the frontend
RUN pnpm build
# Stage 2: Build the backend
FROM golang:1.24-alpine AS backend-builder
WORKDIR /app
# Install build dependencies
RUN apk add --no-cache git
# Copy go mod files
COPY backend/go.mod backend/go.sum ./
# Download dependencies
RUN go mod download
# Copy backend source
COPY backend/ ./
# Copy the built frontend from the previous stage
COPY --from=frontend-builder /app/build ./build
# Build the Go binary with embedded static files
RUN GOOS=linux go build -ldflags="-w -s" -o mvg-observer .
# Stage 3: Final runtime image
FROM scratch
#WORKDIR /root/
# Copy the binary from builder stage
COPY --from=backend-builder /app/mvg-observer .
# Expose port
EXPOSE 8080
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:8080/api/health || exit 1
# Run the binary
CMD ["./mvg-observer"]