From ef4f1c31c661e9726af690981005078517e10a8d Mon Sep 17 00:00:00 2001 From: sHa Date: Wed, 2 Jul 2025 10:20:57 +0300 Subject: [PATCH] Refactor Makefile for improved container runtime detection and simplify commands --- Makefile | 52 +++++++++++++++++++++++++++++------------- public/data/logos.json | 10 ++++---- 2 files changed, 41 insertions(+), 21 deletions(-) diff --git a/Makefile b/Makefile index f4e9c05..188bc00 100644 --- a/Makefile +++ b/Makefile @@ -1,32 +1,52 @@ # Logo Gallery Project Makefile # Configuration -DOCKER_COMPOSE = docker compose CONTAINER_NAME = slogos-dev DEV_PORT = 5006 +# Auto-detect container runtime (docker or podman) +CONTAINER_RUNTIME := $(shell \ + if command -v docker >/dev/null 2>&1 && docker info >/dev/null 2>&1; then \ + echo "docker"; \ + elif command -v podman >/dev/null 2>&1; then \ + echo "podman"; \ + else \ + echo "none"; \ + fi) + +COMPOSEFILE = compose.dev.yml +# Set compose command based on runtime +ifeq ($(CONTAINER_RUNTIME),docker) + DOCKER_COMPOSE ?= docker compose -f $(COMPOSEFILE) +else ifeq ($(CONTAINER_RUNTIME),podman) + DOCKER_COMPOSE ?= podman-compose -f $(COMPOSEFILE) +else + $(error No container runtime found. Please install docker or podman) +endif + + # Main targets .PHONY: all build start stop restart logs clean update-data dev rebuild favicon build-with-favicons generate-svg-variants pwa-cache-list run update-lock all: build start dev: pwa-cache-list - $(DOCKER_COMPOSE) -f compose.dev.yml up --build + $(DOCKER_COMPOSE) up --build build: @echo "Building the Logo Gallery container..." - $(DOCKER_COMPOSE) -f compose.dev.yml build + $(DOCKER_COMPOSE) build # Start the application in the background start: pwa-cache-list @echo "Starting Logo Gallery application on port $(DEV_PORT)..." - $(DOCKER_COMPOSE) -f compose.dev.yml up -d + $(DOCKER_COMPOSE) up -d @echo "Application is running at http://localhost:$(DEV_PORT)" # Stop the application stop: @echo "Stopping Logo Gallery application..." - $(DOCKER_COMPOSE) -f compose.dev.yml down + $(DOCKER_COMPOSE) down # Restart the application restart: stop start @@ -34,37 +54,37 @@ restart: stop start # View the application logs logs: @echo "Showing application logs (press Ctrl+C to exit)..." - $(DOCKER_COMPOSE) -f compose.dev.yml logs -f + $(DOCKER_COMPOSE) logs -f # Run a command inside the container # Usage: make run CMD="npm run build" run: @echo "Running command in container: $(CMD)" - $(DOCKER_COMPOSE) -f compose.dev.yml run --rm $(CONTAINER_NAME) $(CMD) + $(DOCKER_COMPOSE) run --rm $(CONTAINER_NAME) $(CMD) exec: - $(DOCKER_COMPOSE) -f compose.dev.yml run --rm $(CONTAINER_NAME) $(CMD) + $(DOCKER_COMPOSE) run --rm $(CONTAINER_NAME) $(CMD) update-data: @echo "Scanning logos directory and updating logos.json for development..." - $(DOCKER_COMPOSE) -f compose.dev.yml run --rm $(CONTAINER_NAME) npm run update-data + $(DOCKER_COMPOSE) run --rm $(CONTAINER_NAME) npm run update-data @echo "Logos and Flags have been updated - refresh the browser to see changes" # Clean up build artifacts and temporary files clean: @echo "Cleaning up build artifacts and temporary files..." - $(DOCKER_COMPOSE) -f compose.dev.yml down + $(DOCKER_COMPOSE) down docker builder prune -f # Complete rebuild from scratch rebuild: - $(DOCKER_COMPOSE) -f compose.dev.yml down -v - $(DOCKER_COMPOSE) -f compose.dev.yml build --no-cache + $(DOCKER_COMPOSE) down -v + $(DOCKER_COMPOSE) build --no-cache # Generate favicons favicon: @echo "Generating favicons..." - $(DOCKER_COMPOSE) -f compose.dev.yml run --rm $(CONTAINER_NAME) npm run generate-favicons + $(DOCKER_COMPOSE) run --rm $(CONTAINER_NAME) npm run generate-favicons @echo "Favicons have been generated" # Build with favicons @@ -73,16 +93,16 @@ build-with-favicons: favicon build # Update package-lock.json by running npm install in Docker update-lock: @echo "Updating package-lock.json to match package.json..." - $(DOCKER_COMPOSE) -f compose.dev.yml run --rm $(CONTAINER_NAME) npm install + $(DOCKER_COMPOSE) run --rm $(CONTAINER_NAME) npm install @echo "Package lock file has been updated" # Generate SVG variants with color sets generate-svg-variants: @echo "Generating SVG variants with color sets..." - $(DOCKER_COMPOSE) -f compose.dev.yml run --rm $(CONTAINER_NAME) node scripts/generate-svg-variants.js + $(DOCKER_COMPOSE) run --rm $(CONTAINER_NAME) node scripts/generate-svg-variants.js @echo "SVG variants have been generated" # Generate PWA cache list generate-pwa-cache-list: @echo "Generating PWA cache list..." - $(DOCKER_COMPOSE) -f compose.dev.yml run --rm $(CONTAINER_NAME) npm run pwa-cache-list + $(DOCKER_COMPOSE) run --rm $(CONTAINER_NAME) npm run pwa-cache-list diff --git a/public/data/logos.json b/public/data/logos.json index c173d7e..6e7b801 100644 --- a/public/data/logos.json +++ b/public/data/logos.json @@ -2956,10 +2956,10 @@ "ua_yellow": "#FFDD00" }, "targets": { - "part_s": "#s", - "part_s_stroke": "#s&stroke", - "part_l": "#l", - "part_l_stroke": "#l&stroke" + "part_s": "#shadoll_s", + "part_s_stroke": "#shadoll_s&stroke", + "part_l": "#shadoll_l", + "part_l_stroke": "#shadoll_l&stroke" }, "sets": { "light": { @@ -3874,4 +3874,4 @@ } } } -] \ No newline at end of file +]