From c65d497551fbd8d42c6ca1d5ac6bcaa73ce90db6 Mon Sep 17 00:00:00 2001 From: Sakurasan <26715255+Sakurasan@users.noreply.github.com> Date: Tue, 1 Sep 2026 15:22:37 +0800 Subject: [PATCH] feat: add docker build commands to Makefile --- Makefile | 21 ++++++++++++++++++++- deploy/docker/Dockerfile | 2 +- deploy/docker/Dockerfile.cn | 2 +- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index a51c83f..4d7fdcd 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: build run test clean fmt lint frontend dev dev-backend dev-frontend +.PHONY: build run test clean fmt lint frontend dev dev-backend dev-frontend docker docker-cn docker-multi BINARY_NAME=openteam BUILD_DIR=bin @@ -8,6 +8,10 @@ BACKEND_DIR=backend build: frontend cd $(BACKEND_DIR) && CGO_ENABLED=0 go build -o ../$(BUILD_DIR)/$(BINARY_NAME) ./cmd/openteam +# Build backend only (frontend dist must exist) +build-backend: + cd $(BACKEND_DIR) && CGO_ENABLED=0 go build -o ../$(BUILD_DIR)/$(BINARY_NAME) ./cmd/openteam + # Build frontend and copy dist frontend: cd frontend && pnpm install && pnpm build @@ -74,3 +78,18 @@ migrate: # Seed data (will be implemented) seed: @echo "Seeding will be implemented in future" + +# Docker build (default platform) +docker: + docker build -f deploy/docker/Dockerfile -t $(BINARY_NAME):latest . + +# Docker build (China mirror accelerated) +docker-cn: + docker build -f deploy/docker/Dockerfile.cn -t $(BINARY_NAME):latest . + +# Docker build multi-platform (requires: docker buildx) +docker-multi: + docker buildx build -f deploy/docker/Dockerfile \ + --platform linux/amd64,linux/arm64 \ + -t $(BINARY_NAME):latest --push . + diff --git a/deploy/docker/Dockerfile b/deploy/docker/Dockerfile index 66b5f16..cf6810c 100644 --- a/deploy/docker/Dockerfile +++ b/deploy/docker/Dockerfile @@ -23,7 +23,7 @@ ENV GO111MODULE=on \ CGO_ENABLED=0 \ GOOS=$TARGETOS \ GOARCH=$TARGETARCH -RUN make build +RUN make build-backend FROM alpine:latest AS runner # 设置alpine 时间为上海时间 diff --git a/deploy/docker/Dockerfile.cn b/deploy/docker/Dockerfile.cn index 66e489a..0b08767 100644 --- a/deploy/docker/Dockerfile.cn +++ b/deploy/docker/Dockerfile.cn @@ -27,7 +27,7 @@ ENV GO111MODULE=on \ CGO_ENABLED=0 \ GOOS=$TARGETOS \ GOARCH=$TARGETARCH -RUN make build +RUN make build-backend FROM alpine:latest AS runner # 设置alpine 时间为上海时间