Files
terminal-chart-server/Dockerfile

35 lines
761 B
Docker

FROM golang:1.26-alpine AS builder
WORKDIR /app
# 设置 Alpine 国内镜像源
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories
RUN apk add --no-cache gcc musl-dev
COPY go.mod go.sum ./
# 设置 Go 国内镜像源(多备用源)
RUN go env -w GOPROXY=https://goproxy.cn,https://goproxy.io,direct && \
go env -w GOSUMDB=off && \
go mod download
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o server ./cmd/server
FROM alpine:latest
# 设置 Alpine 国内镜像源
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories
RUN apk --no-cache add ca-certificates
WORKDIR /app
COPY --from=builder /app/server .
EXPOSE 3100
CMD ["./server"]