All checks were successful
Build and Push Docker Image / build (push) Successful in 2m7s
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
38 lines
701 B
Docker
38 lines
701 B
Docker
# 构建阶段
|
|
FROM golang:1.23-alpine AS builder
|
|
|
|
WORKDIR /app
|
|
|
|
# 安装必要的构建工具
|
|
RUN apk add --no-cache git
|
|
|
|
# 复制go.mod和go.sum
|
|
COPY go.mod go.sum ./
|
|
RUN go mod download
|
|
|
|
# 复制源代码
|
|
COPY . .
|
|
|
|
# 构建
|
|
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o /app/server ./cmd/server
|
|
|
|
# 运行阶段
|
|
FROM alpine:3.18
|
|
|
|
LABEL org.opencontainers.image.source="https://gitea.likegears.com/likegears/material_texture"
|
|
|
|
WORKDIR /app
|
|
|
|
# 安装必要的运行时依赖
|
|
RUN apk add --no-cache ca-certificates tzdata
|
|
|
|
# 从构建阶段复制二进制文件
|
|
COPY --from=builder /app/server /app/server
|
|
|
|
# 设置时区
|
|
ENV TZ=Asia/Shanghai
|
|
|
|
EXPOSE 8080
|
|
|
|
CMD ["/app/server"]
|