-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
58 lines (38 loc) · 1.05 KB
/
Dockerfile
File metadata and controls
58 lines (38 loc) · 1.05 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 Vite React + Go application
# Stage 1: Build React app
FROM node:18-alpine AS react-builder
WORKDIR /app
# Copy package files
COPY frontend/package*.json ./
# Install dependencies
RUN npm ci
# Copy source code
COPY frontend/ .
# Build the React app
RUN npm run build
# Stage 2: Build Go binary
FROM golang:1.21-alpine AS go-builder
WORKDIR /app
# Copy Go files
COPY backend/go.mod backend/main.go ./
# Download dependencies
RUN go mod download
# Build the Go binary
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o main .
# Stage 3: Final image
FROM alpine:latest
# Install ca-certificates for HTTPS requests
RUN apk --no-cache add ca-certificates
WORKDIR /root/
# Copy the React build from react-builder stage
COPY --from=react-builder /app/dist ./dist
# Copy the Go binary from go-builder stage
COPY --from=go-builder /app/main .
# Copy the pricing data JSON file
COPY backend/pricing_data.json .
# Expose port 8081
EXPOSE 8081
# Set environment variable for port
ENV PORT=8081
# Run the Go application
CMD ["./main"]