Files

36 lines
648 B
Docker

FROM golang:1.24-alpine AS builder
WORKDIR /app
RUN apk add --no-cache git nodejs npm
ENV GOPROXY=https://goproxy.cn,direct
ENV GOFLAGS=-buildvcs=false
COPY backend/go.mod backend/go.sum ./
RUN go mod tidy
RUN go mod download
COPY backend ./backend
COPY frontend ./frontend
RUN npm ci --prefix frontend
RUN npm run build --prefix frontend
RUN cd backend && CGO_ENABLED=0 GOOS=linux go build -o /app/server ./cmd/server
FROM alpine:latest
WORKDIR /app
RUN apk add --no-cache ca-certificates tzdata
RUN mkdir -p uploads data
COPY --from=builder /app/server .
COPY --from=builder /app/frontend/dist ./static
EXPOSE 8080
CMD ["./server"]