From af967cab2e1975946b3ab7d2967d08fc400e8344 Mon Sep 17 00:00:00 2001 From: tbphp Date: Sun, 13 Jul 2025 02:39:20 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20docker=20=E6=9E=84=E5=BB=BA=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 28 ++++++++++++++++------------ docker-compose.yml | 9 +++++---- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/Dockerfile b/Dockerfile index 152beb4..568a645 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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"] diff --git a/docker-compose.yml b/docker-compose.yml index b1d8af8..ed0655d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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: