40 lines
1.0 KiB
Makefile
40 lines
1.0 KiB
Makefile
.PHONY: help build up up-build down restart logs ps
|
|
|
|
COMPOSE_FILE := docker/docker-compose.yml
|
|
COMPOSE := docker compose -f $(COMPOSE_FILE)
|
|
|
|
help:
|
|
@printf "Available targets:\n"
|
|
@printf " make build Build Docker images (with cache)\n"
|
|
@printf " make up Start services (NO rebuild, reuse existing image)\n"
|
|
@printf " make up-build Rebuild image then start (use after code changes)\n"
|
|
@printf " make down Stop and remove services\n"
|
|
@printf " make restart Restart services without rebuild\n"
|
|
@printf " make logs Follow service logs\n"
|
|
@printf " make ps Show service status\n"
|
|
@printf " Note: do not use 'docker compose down -v' in daily usage (it removes persistent volumes)\n"
|
|
|
|
build:
|
|
$(COMPOSE) build
|
|
|
|
# 日常启动:直接用已有镜像,不重新构建(秒启动)
|
|
up:
|
|
$(COMPOSE) up -d
|
|
|
|
# 代码有改动时使用:重新构建镜像再启动
|
|
up-build:
|
|
$(COMPOSE) build
|
|
$(COMPOSE) up -d
|
|
|
|
down:
|
|
$(COMPOSE) down
|
|
|
|
restart:
|
|
$(COMPOSE) restart
|
|
|
|
logs:
|
|
$(COMPOSE) logs -f
|
|
|
|
ps:
|
|
$(COMPOSE) ps
|