feat: add docker build commands to Makefile
This commit is contained in:
@@ -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
|
BINARY_NAME=openteam
|
||||||
BUILD_DIR=bin
|
BUILD_DIR=bin
|
||||||
@@ -8,6 +8,10 @@ BACKEND_DIR=backend
|
|||||||
build: frontend
|
build: frontend
|
||||||
cd $(BACKEND_DIR) && CGO_ENABLED=0 go build -o ../$(BUILD_DIR)/$(BINARY_NAME) ./cmd/openteam
|
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
|
# Build frontend and copy dist
|
||||||
frontend:
|
frontend:
|
||||||
cd frontend && pnpm install && pnpm build
|
cd frontend && pnpm install && pnpm build
|
||||||
@@ -74,3 +78,18 @@ migrate:
|
|||||||
# Seed data (will be implemented)
|
# Seed data (will be implemented)
|
||||||
seed:
|
seed:
|
||||||
@echo "Seeding will be implemented in future"
|
@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 .
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ ENV GO111MODULE=on \
|
|||||||
CGO_ENABLED=0 \
|
CGO_ENABLED=0 \
|
||||||
GOOS=$TARGETOS \
|
GOOS=$TARGETOS \
|
||||||
GOARCH=$TARGETARCH
|
GOARCH=$TARGETARCH
|
||||||
RUN make build
|
RUN make build-backend
|
||||||
|
|
||||||
FROM alpine:latest AS runner
|
FROM alpine:latest AS runner
|
||||||
# 设置alpine 时间为上海时间
|
# 设置alpine 时间为上海时间
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ ENV GO111MODULE=on \
|
|||||||
CGO_ENABLED=0 \
|
CGO_ENABLED=0 \
|
||||||
GOOS=$TARGETOS \
|
GOOS=$TARGETOS \
|
||||||
GOARCH=$TARGETARCH
|
GOARCH=$TARGETARCH
|
||||||
RUN make build
|
RUN make build-backend
|
||||||
|
|
||||||
FROM alpine:latest AS runner
|
FROM alpine:latest AS runner
|
||||||
# 设置alpine 时间为上海时间
|
# 设置alpine 时间为上海时间
|
||||||
|
|||||||
Reference in New Issue
Block a user