26 lines
614 B
Docker
26 lines
614 B
Docker
# Stage 1: Build frontend
|
|
FROM node:22-alpine AS frontend
|
|
WORKDIR /app/frontend
|
|
COPY frontend/package.json frontend/package-lock.json* ./
|
|
RUN npm install
|
|
COPY frontend/ ./
|
|
RUN npm run build
|
|
|
|
# Stage 2: Build Go binary
|
|
FROM golang:1.24-alpine AS backend
|
|
WORKDIR /app
|
|
COPY go.mod go.sum ./
|
|
RUN go mod download
|
|
COPY . .
|
|
COPY --from=frontend /app/dist ./dist
|
|
RUN CGO_ENABLED=0 go build -o energy-frontend .
|
|
|
|
# Stage 3: Minimal runtime
|
|
FROM alpine:3.21
|
|
RUN apk add --no-cache ca-certificates tzdata
|
|
WORKDIR /app
|
|
COPY --from=backend /app/energy-frontend .
|
|
EXPOSE 8080
|
|
USER nobody:nobody
|
|
ENTRYPOINT ["./energy-frontend"]
|