38 lines
1.3 KiB
Docker
38 lines
1.3 KiB
Docker
FROM node:22-alpine AS frontend-builder
|
|
RUN apk add --no-cache git
|
|
WORKDIR /frontend
|
|
COPY frontend/package*.json ./
|
|
RUN --mount=type=bind,source=SharedCode.git,target=/tmp/SharedCode.git,readonly \
|
|
git config --global url."file:///tmp/SharedCode.git".insteadOf "https://repos.gfranz.ch/Gabriel20xx/shared" && \
|
|
for attempt in 1 2 3 4 5; do \
|
|
npm ci && break; \
|
|
if [ "$attempt" -eq 5 ]; then exit 1; fi; \
|
|
delay=$((attempt * 5)); \
|
|
echo "SharedCode npm install failed (attempt ${attempt}/5); retrying in ${delay}s..." >&2; \
|
|
sleep "$delay"; \
|
|
done
|
|
COPY frontend/ ./
|
|
RUN npm run build
|
|
|
|
FROM golang:1.26-alpine AS builder
|
|
WORKDIR /app
|
|
COPY backend/go.mod backend/go.sum ./
|
|
RUN --mount=type=secret,id=gitea_go_netrc,target=/root/.netrc,required \
|
|
GOPROXY="https://repos.gfranz.ch/api/packages/Gabriel20xx/go,https://proxy.golang.org" \
|
|
GONOSUMDB="repos.gfranz.ch/Gabriel20xx/shared/*" \
|
|
GOAUTH=netrc \
|
|
go mod download
|
|
COPY backend/*.go ./
|
|
COPY --from=frontend-builder /frontend/build ./web
|
|
RUN apk add --no-cache ca-certificates && \
|
|
CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o server .
|
|
|
|
FROM scratch
|
|
COPY --from=builder /app/server /server
|
|
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
|
|
USER 65534:65534
|
|
EXPOSE 3000
|
|
VOLUME ["/data"]
|
|
ENV PORT=3000
|
|
ENTRYPOINT ["/server"]
|