diff --git a/Makefile b/Makefile index 55d5fba..c39111f 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,33 @@ -run: stop - docker compose up -d +# === Configuration === +# Default value is 'dev'. Can be overridden with 'make ENV=prod ...' +ENV ?= dev +COMPOSE_FILE = docker-compose$(if $(filter $(ENV),prod),.prod,).yml +COMPOSE = docker compose -f $(COMPOSE_FILE) + +.PHONY: up stop build deploy logs + +# Standard Start (on iMac: 'make run' -> dev | on Pi: 'make ENV=prod run') +run: stop up + +up: + $(COMPOSE) up -d + +# Build command +build: + $(COMPOSE) build + +# The Deployment Routine for your Pi +# You would call this with: make ENV=prod deploy +deploy: stop pull build up clean + +pull: + git pull origin main stop: - docker compose down --remove-orphans \ No newline at end of file + $(COMPOSE) down --remove-orphans + +logs: + $(COMPOSE) logs -f + +clean: + docker image prune -f \ No newline at end of file diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml new file mode 100644 index 0000000..c9a5109 --- /dev/null +++ b/docker-compose.prod.yml @@ -0,0 +1,9 @@ +services: + app: + build: . + image: cgr-next-js-prod + volumes: !reset [] + command: !reset [] + ports: + - "80:3000" + restart: always \ No newline at end of file