feat: use DOCKER_IMAGE from .env in Makefile
- Update Makefile to read DOCKER_IMAGE from .env file with proper precedence - Environment variables override .env file values - Fallback to 'meds-app:latest' if not defined anywhere - Add new Docker targets: docker-run, docker-push, docker-config - Improve help output with environment variable documentation - Update APP_NAME_CONFIGURATION.md to show Makefile usage examples Variable precedence: 1. Environment variable (highest) 2. .env file (medium) 3. Default fallback (lowest)
This commit is contained in:
38
Makefile
38
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..."
|
||||
|
||||
Reference in New Issue
Block a user