89 lines
2.7 KiB
Makefile
Executable File
89 lines
2.7 KiB
Makefile
Executable File
SERVICES=traefik whoami gitea nextcloud devbox docs-site
|
|
SERVICES_DIR=services
|
|
|
|
.PHONY: up down restart backup init-env env-sync docs generate-docs serve-docs logs status up-% down-%
|
|
|
|
up:
|
|
for svc in $(SERVICES); do \
|
|
if [ -f "$(SERVICES_DIR)/$$svc/docker-compose.yml" ]; then \
|
|
echo "Starting $$svc..."; \
|
|
(cd $(SERVICES_DIR)/$$svc && docker compose --env-file ../../.env `if [ -f .env ]; then echo --env-file .env; fi` up -d); \
|
|
fi; \
|
|
done; \
|
|
|
|
up-%:
|
|
@svc=$*; \
|
|
if [ -f "$(SERVICES_DIR)/$$svc/docker-compose.yml" ]; then \
|
|
echo "Starting $$svc..."; \
|
|
(cd $(SERVICES_DIR)/$$svc && docker compose --env-file ../../.env `if [ -f .env ]; then echo --env-file .env; fi` up -d); \
|
|
fi
|
|
|
|
down-%:
|
|
@svc=$*; \
|
|
if [ -f "$(SERVICES_DIR)/$$svc/docker-compose.yml" ]; then \
|
|
echo "Stopping $$svc..."; \
|
|
(cd $(SERVICES_DIR)/$$svc && docker compose down); \
|
|
fi
|
|
|
|
down:
|
|
@for svc in $(SERVICES); do \
|
|
if [ -f "$(SERVICES_DIR)/$$svc/docker-compose.yml" ]; then \
|
|
echo "Stopping $$svc..."; \
|
|
(cd $(SERVICES_DIR)/$$svc && docker compose down); \
|
|
fi; \
|
|
done
|
|
|
|
restart: down up
|
|
|
|
logs:
|
|
@echo "=== Traefik ===" && (cd $(SERVICES_DIR)/traefik && docker compose logs --tail=10)
|
|
@echo "=== Gitea ===" && (cd $(SERVICES_DIR)/gitea && docker compose logs --tail=10)
|
|
@echo "=== Nextcloud ===" && (cd $(SERVICES_DIR)/nextcloud && docker compose logs --tail=10)
|
|
|
|
status:
|
|
@for svc in $(SERVICES); do \
|
|
if [ -f "$(SERVICES_DIR)/$$svc/docker-compose.yml" ]; then \
|
|
echo "--- $$svc ---"; \
|
|
(cd $(SERVICES_DIR)/$$svc && docker compose ps --format "table {{.Name}}\t{{.Status}}\t{{.Ports}}"); \
|
|
fi; \
|
|
done
|
|
|
|
backup:
|
|
./backup.sh
|
|
|
|
init-env:
|
|
@echo "Initializing .env files from .env.example..."
|
|
@find . -path './.git' -prune -o -type f -name '.env.example' -print | while read -r example; do \
|
|
env_file="$${example%.example}"; \
|
|
if [ -f "$$env_file" ]; then \
|
|
echo "Skip (exists): $$env_file"; \
|
|
else \
|
|
cp "$$example" "$$env_file"; \
|
|
echo "Created: $$env_file"; \
|
|
fi; \
|
|
done
|
|
|
|
env-sync:
|
|
python3 scripts/check_env_sync.py --fix
|
|
|
|
generate-docs:
|
|
python3 scripts/generate_docs.py
|
|
|
|
docs: generate-docs
|
|
@command -v uvx >/dev/null 2>&1 || { \
|
|
echo "Error: uvx is not installed or not in PATH."; \
|
|
echo "Install with: curl -LsSf https://astral.sh/uv/install.sh | sh"; \
|
|
echo "Then run: source $$HOME/.local/bin/env"; \
|
|
exit 1; \
|
|
}
|
|
uvx --from mkdocs-material --with mkdocs-include-markdown-plugin mkdocs build
|
|
|
|
serve-docs: generate-docs
|
|
@command -v uvx >/dev/null 2>&1 || { \
|
|
echo "Error: uvx is not installed or not in PATH."; \
|
|
echo "Install with: curl -LsSf https://astral.sh/uv/install.sh | sh"; \
|
|
echo "Then run: source $$HOME/.local/bin/env"; \
|
|
exit 1; \
|
|
}
|
|
uvx --from mkdocs-material --with mkdocs-include-markdown-plugin mkdocs serve --dev-addr 0.0.0.0:8000
|