diff --git a/Makefile b/Makefile index c713762..0d26970 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,15 @@ # Makefile for Medication Reminder App +# Check if DOCKER_IMAGE is set in environment, otherwise use .env or default +ifndef DOCKER_IMAGE + # Include environment variables from .env file if it exists + -include .env + # Set default if still not defined + DOCKER_IMAGE ?= meds-app:latest +endif + +export + .PHONY: help install clean dev build test docker-build docker-clean # Default target @@ -8,6 +18,12 @@ ##@ General help: ## Display available commands + @echo "Medication Reminder App - Make Commands" + @echo "" + @echo "Environment Variables:" + @echo " DOCKER_IMAGE Docker image name (default: meds-app:latest)" + @echo " Can be set in .env file or environment" + @echo "" @awk 'BEGIN {FS = ":.*##"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " %-20s %s\n", $$1, $$2 } /^##@/ { printf "\n%s\n", substr($$0, 5) } ' $(MAKEFILE_LIST) install: ## Install dependencies @@ -41,16 +57,30 @@ test-watch: ## Run unit tests in watch mode ##@ Docker docker-build: ## Build Docker image for multiple architectures - @echo "Building multi-platform Docker image..." + @echo "Building multi-platform Docker image: $(DOCKER_IMAGE)" @docker buildx build --platform linux/amd64,linux/arm64 \ --build-arg NODE_ENV=production \ - -t meds-app:latest . + -t $(DOCKER_IMAGE) . docker-build-local: ## Build Docker image for local platform only - @echo "Building local Docker image..." + @echo "Building local Docker image: $(DOCKER_IMAGE)" @docker buildx build --platform linux/amd64 \ --build-arg NODE_ENV=production \ - -t meds-app:latest --load . + -t $(DOCKER_IMAGE) --load . + +docker-run: ## Run Docker container from built image + @echo "Running Docker container: $(DOCKER_IMAGE)" + @docker run --rm -p 8080:80 $(DOCKER_IMAGE) + +docker-push: ## Push Docker image to registry + @echo "Pushing Docker image: $(DOCKER_IMAGE)" + @docker push $(DOCKER_IMAGE) + +docker-config: ## Show current Docker configuration + @echo "Current Docker configuration:" + @echo " DOCKER_IMAGE: $(DOCKER_IMAGE)" + @echo " Available images:" + @docker images | grep -E "(REPOSITORY|$(shell echo $(DOCKER_IMAGE) | cut -d: -f1))" || true docker-clean: ## Clean Docker resources @echo "Cleaning Docker resources..." diff --git a/docs/setup/APP_NAME_CONFIGURATION.md b/docs/setup/APP_NAME_CONFIGURATION.md index 40e8b25..8911748 100644 --- a/docs/setup/APP_NAME_CONFIGURATION.md +++ b/docs/setup/APP_NAME_CONFIGURATION.md @@ -25,7 +25,10 @@ make deploy export APP_NAME="DevMeds" bun run dev -# For Docker build +# For Docker build with Makefile +DOCKER_IMAGE="myregistry.com/myapp:v1.0" make docker-build + +# For Docker build with manual command APP_NAME="CustomApp" docker build -t myapp . ``` @@ -34,12 +37,15 @@ APP_NAME="CustomApp" docker build -t myapp . ```bash # .env APP_NAME=MyCustomApp +DOCKER_IMAGE=myregistry.com/mycustomapp:dev # .env.production APP_NAME=ProductionApp +DOCKER_IMAGE=myregistry.com/productionapp:latest # .env.staging APP_NAME=StagingApp +DOCKER_IMAGE=myregistry.com/stagingapp:staging ``` ## Where APP_NAME is Used