Refactor Makefile for improved container runtime detection and simplify commands

This commit is contained in:
sHa
2025-07-02 10:20:57 +03:00
parent 745cfb602c
commit ef4f1c31c6
2 changed files with 41 additions and 21 deletions

View File

@@ -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

View File

@@ -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": {