-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
38 lines (28 loc) · 866 Bytes
/
Dockerfile
File metadata and controls
38 lines (28 loc) · 866 Bytes
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
# Build stage (Frontend)
FROM node:18-alpine AS frontend-builder
WORKDIR /app/frontend
COPY frontend/package*.json ./
RUN npm ci
COPY frontend ./
RUN npm run build
# Build stage (Backend)
FROM golang:1.22-alpine AS backend-builder
WORKDIR /app
# Install dependencies first (better caching)
COPY go.mod go.sum* ./
RUN go mod download
# Copy source and build
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -o /api ./cmd/api
RUN CGO_ENABLED=0 GOOS=linux go build -o /migrate ./cmd/migrate
# Runtime stage
FROM alpine:3.19
RUN apk --no-cache add ca-certificates
WORKDIR /
COPY --from=backend-builder /api /api
COPY --from=backend-builder /migrate /migrate
COPY --from=backend-builder /app/migrations /migrations
# Copy frontend build as static files
COPY --from=frontend-builder /app/frontend/dist /static
EXPOSE 8080
CMD ["/bin/sh", "-c", "/migrate && /api"]