2026-06-27 02:26:33 +00:00
|
|
|
# Website service — operational commands
|
|
|
|
|
# --- Configuration ------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
# Load configuration from .env (the same file Compose reads).
|
|
|
|
|
ENV_FILE := $(if $(wildcard .env),.env,.env.local)
|
|
|
|
|
include $(ENV_FILE)
|
|
|
|
|
export
|
|
|
|
|
|
|
|
|
|
# Variables
|
|
|
|
|
IMAGE_URL := $(HOST_CONTAINER)/$(HOST_OWNER)/$(IMAGE_NAME)
|
|
|
|
|
|
|
|
|
|
# Arguments
|
|
|
|
|
override version ?= $(IMAGE_TAG)
|
|
|
|
|
|
|
|
|
|
# Show help if no target is specified.
|
|
|
|
|
.DEFAULT_GOAL := help
|
|
|
|
|
|
|
|
|
|
# --- Swift package ------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
.PHONY: pkg-build
|
|
|
|
|
pkg-build: ## Build the Swift package
|
|
|
|
|
@swift build
|
|
|
|
|
|
|
|
|
|
.PHONY: pkg-release
|
|
|
|
|
pkg-release: ## Release the Swift package
|
|
|
|
|
@swift build -c release
|
|
|
|
|
|
|
|
|
|
.PHONY: pkg-test
|
|
|
|
|
pkg-test: ## Run the Swift package tests
|
|
|
|
|
@swift test \
|
|
|
|
|
--disable-xctest \
|
|
|
|
|
--enable-code-coverage \
|
|
|
|
|
--enable-swift-testing \
|
|
|
|
|
--parallel
|
|
|
|
|
|
|
|
|
|
.PHONY: pkg-clean
|
|
|
|
|
pkg-clean: ## Remove the Swift build artifacts
|
|
|
|
|
@swift package clean
|
|
|
|
|
|
|
|
|
|
.PHONY: pkg-reset
|
2026-07-11 09:15:58 +00:00
|
|
|
pkg-reset: ## Reset the SPM cache and build folder
|
2026-06-27 02:26:33 +00:00
|
|
|
@swift package reset
|
|
|
|
|
|
|
|
|
|
.PHONY: pkg-outdated
|
2026-07-11 09:15:58 +00:00
|
|
|
pkg-outdated: ## List the SPM dependencies that can be updated
|
2026-06-27 02:26:33 +00:00
|
|
|
@swift package update --dry-run
|
|
|
|
|
|
|
|
|
|
.PHONY: pkg-update
|
2026-07-11 09:15:58 +00:00
|
|
|
pkg-update: ## Update the SPM dependencies
|
2026-06-27 02:26:33 +00:00
|
|
|
@swift package update
|
|
|
|
|
|
|
|
|
|
# --- Local development --------------------------------------------------------
|
|
|
|
|
|
2026-07-11 09:15:58 +00:00
|
|
|
.PHONY: site-run
|
|
|
|
|
site-run: ## Run the website locally, rebuilding on source changes
|
|
|
|
|
@hb watch
|
2026-06-27 02:26:33 +00:00
|
|
|
|
2026-07-11 09:15:58 +00:00
|
|
|
.PHONY: site-mount
|
|
|
|
|
site-mount: ## Mount the website locally
|
|
|
|
|
@docker compose up \
|
|
|
|
|
--build \
|
|
|
|
|
--detach
|
2026-06-27 02:26:33 +00:00
|
|
|
|
2026-07-11 09:15:58 +00:00
|
|
|
.PHONY: site-unmount
|
|
|
|
|
site-unmount: ## Unmount and remove the local website
|
2026-06-27 02:26:33 +00:00
|
|
|
@docker compose down
|
|
|
|
|
@$(MAKE) img-remove
|
|
|
|
|
|
2026-07-11 09:15:58 +00:00
|
|
|
# --- Local database -----------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
.PHONY: db-mount
|
|
|
|
|
db-mount: ## Start the local database instance
|
|
|
|
|
@docker compose \
|
|
|
|
|
--profile database up \
|
|
|
|
|
--detach \
|
|
|
|
|
--wait mariadb
|
|
|
|
|
|
|
|
|
|
.PHONY: db-migrate
|
|
|
|
|
db-migrate: ## Run the migrations against the local database instance
|
|
|
|
|
@DATABASE_DRIVER=mysql \
|
|
|
|
|
DATABASE_HOST=127.0.0.1 \
|
|
|
|
|
DATABASE_TLS=off \
|
|
|
|
|
swift run \
|
|
|
|
|
Website \
|
|
|
|
|
--database-migrate
|
|
|
|
|
|
|
|
|
|
.PHONY: db-shell
|
|
|
|
|
db-shell: ## Open a SQL shell on the local database instance
|
|
|
|
|
@docker compose \
|
|
|
|
|
--profile database \
|
|
|
|
|
exec mariadb \
|
|
|
|
|
mariadb \
|
|
|
|
|
--user=$(or $(DATABASE_USERNAME),loud) \
|
|
|
|
|
--password=$(or $(DATABASE_PASSWORD),loud) \
|
|
|
|
|
$(or $(DATABASE_NAME),loud)
|
|
|
|
|
|
|
|
|
|
.PHONY: db-unmount
|
|
|
|
|
db-unmount: ## Stop and remove the local database instance (keeps the data volume)
|
|
|
|
|
@docker compose \
|
|
|
|
|
--profile database down mariadb
|
|
|
|
|
|
|
|
|
|
.PHONY: db-reset
|
|
|
|
|
db-reset: ## Stop and remove the local database instance and delete its data volume
|
|
|
|
|
@docker compose \
|
|
|
|
|
--profile database down mariadb \
|
|
|
|
|
--volumes
|
|
|
|
|
|
2026-07-19 03:02:17 +00:00
|
|
|
# --- Assets minification ------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
.PHONY: ast-minify
|
|
|
|
|
ast-minify: ## Preview the minified JS/CSS assets in .build/minified
|
|
|
|
|
@docker build \
|
|
|
|
|
--target assets-export \
|
|
|
|
|
--output .build/minified \
|
|
|
|
|
--file Dockerfile \
|
|
|
|
|
../..
|
|
|
|
|
@echo "Minified assets written to .build/minified"
|
|
|
|
|
|
2026-06-27 02:26:33 +00:00
|
|
|
# --- Registry deployment ------------------------------------------------------
|
|
|
|
|
|
2026-07-11 09:15:58 +00:00
|
|
|
.PHONY: img-check
|
|
|
|
|
img-check: ## Check the production image builds
|
|
|
|
|
@docker build \
|
|
|
|
|
--platform linux/amd64 \
|
|
|
|
|
--file Dockerfile \
|
|
|
|
|
../..
|
|
|
|
|
|
2026-06-27 02:26:33 +00:00
|
|
|
.PHONY: img-release
|
2026-07-11 09:15:58 +00:00
|
|
|
img-release: ## Build and push the production image into the container registry
|
2026-06-27 02:26:33 +00:00
|
|
|
@if [ -z "$(version)" ] || [ "$(version)" = "latest" ]; then \
|
|
|
|
|
echo "Error: 'version' must be an explicit tag — e.g. make img-release version=1.2.3"; \
|
|
|
|
|
exit 1; \
|
|
|
|
|
fi
|
|
|
|
|
@docker build \
|
|
|
|
|
--platform $(IMAGE_PLATFORM) \
|
|
|
|
|
--tag $(IMAGE_URL):$(version) \
|
|
|
|
|
--tag $(IMAGE_URL):latest \
|
2026-07-09 23:00:55 +00:00
|
|
|
--file Dockerfile \
|
|
|
|
|
../..
|
2026-06-27 02:26:33 +00:00
|
|
|
@echo "${HOST_PASSWORD}" \
|
|
|
|
|
| docker login $(HOST_CONTAINER) \
|
|
|
|
|
--username $(HOST_USER) \
|
|
|
|
|
--password-stdin
|
|
|
|
|
@docker push $(IMAGE_URL):$(version)
|
|
|
|
|
@docker push $(IMAGE_URL):latest
|
|
|
|
|
@docker logout $(HOST_CONTAINER)
|
|
|
|
|
@$(MAKE) img-remove
|
|
|
|
|
|
|
|
|
|
.PHONY: img-remove
|
|
|
|
|
img-remove: # Removes the generated Docker images
|
|
|
|
|
@images="$$(docker image ls --format '{{.Repository}}:{{.Tag}}' | grep '$(IMAGE_NAME)' | awk '{print $$1}')"; \
|
|
|
|
|
if [ -n "$$images" ]; then \
|
|
|
|
|
docker image rm --force $$images; \
|
|
|
|
|
else \
|
|
|
|
|
echo "No '$(IMAGE_NAME)' images to remove."; \
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# --- Meta ---------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
.PHONY: help
|
|
|
|
|
help: ## Show available commands
|
|
|
|
|
@grep -hE '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) \
|
|
|
|
|
| awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-12s\033[0m %s\n", $$1, $$2}'
|