-
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.2 KB
/
Copy pathDockerfile
File metadata and controls
58 lines (41 loc) · 1.2 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
# Multi-stage build for IoTStudio
# Backend builder stage
FROM golang:1.21-alpine AS backend-builder
WORKDIR /app/backend
# Install build dependencies
RUN apk add --no-cache git make gcc musl-dev sqlite-dev
# Copy go mod files
COPY backend/go.mod backend/go.sum ./
RUN go mod download
# Copy backend source
COPY backend/ .
# Build backend
RUN CGO_ENABLED=1 GOOS=linux go build -a -installsuffix cgo -o server ./cmd/server
# Frontend builder stage
FROM node:18-alpine AS frontend-builder
WORKDIR /app/frontend
# Copy package files
COPY frontend/package*.json ./
RUN npm ci
# Copy frontend source
COPY frontend/ .
# Build frontend
RUN npm run build
# Final stage
FROM alpine:latest
WORKDIR /app
# Install runtime dependencies
RUN apk --no-cache add ca-certificates sqlite tzdata
# Copy backend binary
COPY --from=backend-builder /app/backend/server .
# Copy frontend static files
COPY --from=frontend-builder /app/frontend/dist ./static
# Create data directory
RUN mkdir -p /app/data
# Expose ports
EXPOSE 8080
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:8080/health || exit 1
# Run server
CMD ["./server"]