33 lines
622 B
Docker
33 lines
622 B
Docker
FROM golang:1.22-alpine AS builder
|
|
|
|
WORKDIR /app
|
|
|
|
RUN apk add --no-cache git nodejs npm
|
|
|
|
ENV GOPROXY=https://goproxy.cn,direct
|
|
|
|
COPY backend/go.mod backend/go.sum ./
|
|
RUN go mod download
|
|
|
|
COPY backend ./backend
|
|
COPY frontend ./frontend
|
|
|
|
RUN npm ci --prefix frontend
|
|
RUN npm run build --prefix frontend
|
|
|
|
RUN CGO_ENABLED=0 GOOS=linux go build -o /app/server ./backend/cmd/server
|
|
|
|
FROM alpine:latest
|
|
|
|
WORKDIR /app
|
|
|
|
RUN apk add --no-cache ca-certificates tzdata
|
|
|
|
COPY --from=builder /app/server .
|
|
COPY --from=builder /app/frontend/dist ./static
|
|
COPY --from=builder /app/backend/uploads ./uploads
|
|
|
|
EXPOSE 8080
|
|
|
|
CMD ["./server"]
|