mirror of
https://gitee.com/mirrors/AllinSSL.git
synced 2026-03-07 23:31:10 +08:00
【调整】优化Dockerfile,使用构建阶段构建应用程序,简化运行时依赖安装
This commit is contained in:
28
Dockerfile
28
Dockerfile
@@ -1,10 +1,32 @@
|
||||
# Build stage
|
||||
FROM golang:1.24-alpine AS builder
|
||||
|
||||
WORKDIR /build
|
||||
|
||||
# Install build dependencies
|
||||
RUN apk add --no-cache git make gcc musl-dev
|
||||
|
||||
# Copy go mod files
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download
|
||||
|
||||
# Copy source code
|
||||
COPY . .
|
||||
|
||||
# Build the application
|
||||
RUN CGO_ENABLED=1 GOOS=linux go build -ldflags="-s -w" -o allinssl ./cmd/main.go
|
||||
|
||||
# Final stage
|
||||
FROM frolvlad/alpine-glibc
|
||||
|
||||
WORKDIR /www/allinssl/
|
||||
|
||||
RUN apk add --no-cache curl tzdata\
|
||||
&& curl https://node1.allinssl.com/bin/allinssl-$(uname -s)-$(uname -m).tar.gz | tar -xz -C /www/allinssl/ \
|
||||
&& apk del curl
|
||||
# Install runtime dependencies
|
||||
RUN apk add --no-cache tzdata
|
||||
|
||||
# Copy binary from builder
|
||||
COPY --from=builder /build/allinssl /www/allinssl/allinssl
|
||||
|
||||
ENV TZ=Asia/Shanghai
|
||||
RUN cat > /entrypoint.sh <<'EOF'
|
||||
#!/bin/sh
|
||||
|
||||
Reference in New Issue
Block a user