feat(docker):添加镜像仓库地址,加速构建
This commit is contained in:
1 parent
5796973f0c
commit
1140ba5de8
3 files changed
+31
-4
No files matched your search
@@ -4,6 +4,11 @@ DOCKER_NAME = "team-api"
|
||||
VERSION ?= $(shell cat VERSION 2>/dev/null | tr -d '[:space:]')
|
||||
LDFLAGS = -X github.com/qianfree/team-api/internal/consts.Version=$(VERSION)
|
||||
|
||||
# Mirror acceleration (override for non-China regions)
|
||||
GOPROXY ?= https://goproxy.cn,direct
|
||||
BUN_REGISTRY ?= https://registry.npmmirror.com
|
||||
export GOPROXY
|
||||
|
||||
# Cross-compile: make build GOOS=windows GOARCH=amd64
|
||||
GOOS ?= $(shell go env GOOS)
|
||||
GOARCH ?= $(shell go env GOARCH)
|
||||
@@ -35,8 +40,8 @@ build:
|
||||
|
||||
# Build frontend assets
|
||||
build-web:
|
||||
cd web/admin && bun install && bun run build
|
||||
cd web/tenant && bun install && bun run build
|
||||
cd web/admin && BUN_CONFIG_REGISTRY=$(BUN_REGISTRY) bun install && bun run build
|
||||
cd web/tenant && BUN_CONFIG_REGISTRY=$(BUN_REGISTRY) bun install && bun run build
|
||||
|
||||
# Build all (frontend embedded into backend binary)
|
||||
build-all: build-web
|
||||
|
||||
@@ -1,8 +1,17 @@
|
||||
# Multi-stage build for Team-API
|
||||
#
|
||||
# Mirror acceleration build args (for mainland China users):
|
||||
# GOPROXY - Go module proxy (default: https://goproxy.cn,direct)
|
||||
# BUN_CONFIG_REGISTRY - Bun npm registry (default: https://registry.npmmirror.com)
|
||||
#
|
||||
# Override example: docker compose build --build-arg GOPROXY=https://proxy.golang.org,direct
|
||||
|
||||
# Stage 1: Frontend build
|
||||
FROM oven/bun:1-alpine AS frontend
|
||||
|
||||
ARG BUN_CONFIG_REGISTRY=https://registry.npmmirror.com
|
||||
ENV BUN_CONFIG_REGISTRY=${BUN_CONFIG_REGISTRY}
|
||||
|
||||
WORKDIR /build/web
|
||||
|
||||
COPY web/admin/package.json web/admin/bun.lock* ./admin/
|
||||
@@ -21,6 +30,9 @@ RUN cd admin && bun run build && \
|
||||
# Stage 2: Go build
|
||||
FROM golang:1.25-alpine AS builder
|
||||
|
||||
ARG GOPROXY=https://goproxy.cn,direct
|
||||
ENV GOPROXY=${GOPROXY}
|
||||
|
||||
RUN apk add --no-cache git make gcc musl-dev
|
||||
|
||||
WORKDIR /build
|
||||
|
||||
@@ -6,7 +6,15 @@
|
||||
# 2. 修改下方 "Redis 配置" 中的 --requirepass 密码
|
||||
# 3. 将 manifest/docker/config.yaml 修改为实际配置
|
||||
# (确保数据库密码和 Redis 密码与上方设置一致)
|
||||
# 4. 运行: docker compose up -d
|
||||
# 4. (可选)复制 .env.example 为 .env 并按需调整镜像加速配置
|
||||
# 5. 运行: docker compose up -d
|
||||
#
|
||||
# 镜像加速说明(大陆用户):
|
||||
# 构建时默认使用 goproxy.cn 和 npmmirror 作为 Go/Bun 的下载源。
|
||||
# 拉取基础镜像缓慢时,可配置 Docker daemon 镜像加速器:
|
||||
# 编辑 /etc/docker/daemon.json,添加:
|
||||
# {"registry-mirrors": ["https://mirror.ccs.tencentyun.com", "https://docker.1ms.run"]}
|
||||
# 然后重启 Docker: systemctl restart docker
|
||||
# =============================================================================
|
||||
|
||||
services:
|
||||
@@ -59,7 +67,9 @@ services:
|
||||
context: ../..
|
||||
dockerfile: manifest/docker/Dockerfile
|
||||
args:
|
||||
VERSION: latest
|
||||
VERSION: ${VERSION:-latest}
|
||||
GOPROXY: ${GOPROXY:-https://goproxy.cn,direct}
|
||||
BUN_CONFIG_REGISTRY: ${BUN_CONFIG_REGISTRY:-https://registry.npmmirror.com}
|
||||
container_name: team-api-app
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
|
||||
Reference in new issue
Block a user