feat: docker 构建调整

This commit is contained in:
tbphp
2025-07-13 02:39:20 +08:00
parent 705a38920e
commit af967cab2e
2 changed files with 21 additions and 16 deletions

View File

@@ -1,4 +1,4 @@
FROM node:20-alpine AS frontend-builder
FROM node:20-alpine AS builder
WORKDIR /build
COPY ./web .
@@ -6,25 +6,29 @@ RUN npm install
RUN npm run build
FROM golang:1.24-alpine AS backend-builder
FROM golang:alpine AS builder2
ENV GO111MODULE=on \
CGO_ENABLED=0 \
GOOS=linux
WORKDIR /build
RUN apk add --no-cache git build-base
COPY go.mod go.sum ./
ADD go.mod go.sum ./
RUN go mod download
COPY . .
COPY --from=frontend-builder /build/dist ./web/dist
RUN CGO_ENABLED=0 GOOS=linux go build \
-ldflags="-w -s" \
-o gpt-load
COPY --from=builder /build/dist ./web/dist
RUN go build -ldflags "-s -w " -o gpt-load
FROM alpine:latest
FROM alpine
WORKDIR /app
RUN apk --no-cache add ca-certificates tzdata
COPY --from=backend-builder /build/gpt-load .
RUN apk upgrade --no-cache \
&& apk add --no-cache ca-certificates tzdata \
&& update-ca-certificates
COPY --from=builder2 /build/gpt-load .
EXPOSE 3000
ENTRYPOINT ["/app/gpt-load"]

View File

@@ -35,8 +35,9 @@ services:
- mysql_data:/var/lib/mysql
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
timeout: 10s
retries: 5
interval: 5s
timeout: 5s
retries: 10
redis:
image: redis:latest
@@ -46,8 +47,8 @@ services:
# - "6379:6379"
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
interval: 5s
timeout: 3s
retries: 3
volumes: