26 lines
488 B
Docker
26 lines
488 B
Docker
# 使用纯 Go 的 SQLite 驱动,构建时无需 CGO
|
|
FROM golang:1.25-alpine AS build
|
|
|
|
WORKDIR /src
|
|
|
|
COPY go.mod ./
|
|
RUN go mod download
|
|
|
|
COPY . .
|
|
RUN go mod tidy && CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags="-s -w" -o /out/server ./cmd/server
|
|
|
|
FROM alpine:3.20
|
|
|
|
RUN apk add --no-cache ca-certificates tzdata wget
|
|
|
|
WORKDIR /app
|
|
COPY --from=build /out/server /app/server
|
|
|
|
ENV CANVAS_ADDR=":8080" \
|
|
CANVAS_DATA_DIR="/data"
|
|
|
|
VOLUME ["/data"]
|
|
EXPOSE 8080
|
|
|
|
CMD ["/app/server"]
|