-
-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathDockerfile.builder
More file actions
38 lines (27 loc) · 839 Bytes
/
Dockerfile.builder
File metadata and controls
38 lines (27 loc) · 839 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
# Stage 1: Frontend build
FROM node:25-alpine AS frontend
WORKDIR /ui
ARG APP_VERSION
COPY ./ui/leafwiki-ui/package.json ./package.json
COPY ./ui/leafwiki-ui/package-lock.json ./package-lock.json
RUN npm install
COPY ./ui/leafwiki-ui/ ./
RUN VITE_API_URL=/ APP_VERSION=${APP_VERSION} npm run build
# Stage 2: Go backend build
FROM golang:1.26-alpine AS builder
ARG GOOS
ARG GOARCH
ARG CGO_ENABLED=0
ARG OUTPUT=leafwiki
ENV GOOS=${GOOS}
ENV GOARCH=${GOARCH}
ENV CGO_ENABLED=${CGO_ENABLED}
WORKDIR /build
COPY go.mod go.sum ./
RUN go mod download
COPY . .
# Copy built frontend
COPY --from=frontend /ui/dist ./internal/http/dist
RUN go build \
-ldflags="-s -w -X github.com/perber/wiki/internal/http.EmbedFrontend=true -X github.com/perber/wiki/internal/http.Environment=production" \
-o /out/${OUTPUT} ./cmd/leafwiki/main.go