Files
sale/backend/Dockerfile
T

35 lines
614 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
ENV GOTOOLCHAIN=auto
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
RUN mkdir -p uploads
COPY --from=builder /app/server .
COPY --from=builder /app/frontend/dist ./static
EXPOSE 8080
CMD ["./server"]