- 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)
89 lines
2.6 KiB
Makefile
89 lines
2.6 KiB
Makefile
# 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
|
|
.DEFAULT_GOAL := help
|
|
|
|
##@ 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
|
|
@echo "Installing dependencies..."
|
|
@bun install
|
|
|
|
clean: ## Clean build artifacts and dependencies
|
|
@echo "Cleaning up..."
|
|
@rm -rf node_modules dist build .cache
|
|
|
|
##@ Development
|
|
|
|
dev: ## Start development server
|
|
@echo "Starting development server..."
|
|
@bun run dev
|
|
|
|
build: ## Build the application
|
|
@echo "Building application..."
|
|
@bun run build
|
|
|
|
##@ Testing
|
|
|
|
test: ## Run unit tests
|
|
@echo "Running unit tests..."
|
|
@bun run test
|
|
|
|
test-watch: ## Run unit tests in watch mode
|
|
@echo "Running tests in watch mode..."
|
|
@bun run test:watch
|
|
|
|
##@ Docker
|
|
|
|
docker-build: ## Build Docker image for multiple architectures
|
|
@echo "Building multi-platform Docker image: $(DOCKER_IMAGE)"
|
|
@docker buildx build --platform linux/amd64,linux/arm64 \
|
|
--build-arg NODE_ENV=production \
|
|
-t $(DOCKER_IMAGE) .
|
|
|
|
docker-build-local: ## Build Docker image for local platform only
|
|
@echo "Building local Docker image: $(DOCKER_IMAGE)"
|
|
@docker buildx build --platform linux/amd64 \
|
|
--build-arg NODE_ENV=production \
|
|
-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..."
|
|
@docker image prune -f --filter "until=24h" 2>/dev/null || true
|
|
@docker volume prune -f 2>/dev/null || true
|