62 lines
2.1 KiB
Makefile
62 lines
2.1 KiB
Makefile
# Delivery Tracker - Local Build & Deploy
|
|
REGISTRY = gitea.chedius.ru/chedius
|
|
PLATFORM = linux/amd64
|
|
COMMIT_SHA := $(shell git rev-parse --short=12 HEAD 2>/dev/null || echo dev)
|
|
VERSION_PART ?= patch
|
|
|
|
# Build and push both services
|
|
.PHONY: all build push deploy install-hooks version version-patch version-minor version-major check-release-message release
|
|
|
|
all: build push
|
|
|
|
build:
|
|
docker build --platform $(PLATFORM) -t $(REGISTRY)/delivery-tracker/backend:latest ./backend
|
|
docker build --platform $(PLATFORM) --build-arg GITEA_SHA=$(COMMIT_SHA) -t $(REGISTRY)/delivery-tracker/frontend:latest ./frontend
|
|
|
|
push:
|
|
docker push $(REGISTRY)/delivery-tracker/backend:latest
|
|
docker push $(REGISTRY)/delivery-tracker/frontend:latest
|
|
|
|
# Quick deploy - build, push and trigger watchtower check
|
|
deploy: build push
|
|
@echo "Build and push complete. Watchtower will auto-update within 60 seconds."
|
|
@echo "Or run 'make watchtower-now' to force immediate update"
|
|
|
|
# Force watchtower to check now (run from server)
|
|
watchtower-now:
|
|
docker exec delivery-tracker-watchtower-1 /watchtower --run-once delivery-tracker-backend-1 delivery-tracker-frontend-1
|
|
|
|
# Update specific containers on server (if watchtower fails)
|
|
update-server:
|
|
docker pull $(REGISTRY)/delivery-tracker/backend:latest
|
|
docker pull $(REGISTRY)/delivery-tracker/frontend:latest
|
|
docker-compose up -d --force-recreate backend frontend
|
|
|
|
# Install git hooks for automation
|
|
install-hooks:
|
|
git config core.hooksPath .githooks
|
|
chmod +x .githooks/*
|
|
@echo "✅ Git hooks installed from .githooks/"
|
|
|
|
version:
|
|
@node -p "require('./frontend/package.json').version"
|
|
|
|
version-patch:
|
|
cd frontend && npm version patch --no-git-tag-version
|
|
|
|
version-minor:
|
|
cd frontend && npm version minor --no-git-tag-version
|
|
|
|
version-major:
|
|
cd frontend && npm version major --no-git-tag-version
|
|
|
|
check-release-message:
|
|
@if [ -z "$(MSG)" ]; then echo "Usage: make release MSG='commit message'"; exit 1; fi
|
|
|
|
# Full release: commit, push, and auto-build via hook
|
|
release: check-release-message version-$(VERSION_PART)
|
|
git add -A
|
|
git commit -m "$(MSG)" || true
|
|
git push
|
|
@echo "✅ Released! Watchtower will deploy within 60 seconds."
|