From dc8a019a568c9f08d928b54ba4eb3bfa0cb316d6 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Tue, 21 Apr 2026 19:13:02 +0300 Subject: [PATCH 1/2] Enhance make up and add make open Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- CHANGELOG.md | 2 +- Makefile | 43 ++++++++++++++++++++++++++++++++++++++++++- README.md | 8 +++++++- 3 files changed, 50 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ee0cb46..6888b5e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## 1.4.1 under development -- no changes in this release. +- Enh: Add `make open` and improve `make up` UX (@samdark) ## 1.4.0 April 12, 2026 diff --git a/Makefile b/Makefile index e8e4c33..44b444c 100644 --- a/Makefile +++ b/Makefile @@ -32,7 +32,48 @@ endif ifeq ($(PRIMARY_GOAL),up) up: ## Up the dev environment. - $(DOCKER_COMPOSE_DEV) up -d --remove-orphans + @set -eu; \ + if $(DOCKER_COMPOSE_DEV) up -d --wait --wait-timeout 60 --remove-orphans; then \ + port="$$( $(DOCKER_COMPOSE_DEV) port app 80 )"; \ + host_port="$${port##*:}"; \ + url="http://localhost$$( [ "$$host_port" = '80' ] || printf ':%s' "$$host_port" )"; \ + printf 'Started server at %s\n' "$$url"; \ + else \ + echo 'Failed to start server.' >&2; \ + container_id="$$( $(DOCKER_COMPOSE_DEV) ps -a -q app 2>/dev/null || true )"; \ + if [ -n "$$container_id" ]; then \ + state="$$(docker inspect -f '{{.State.Status}}' "$$container_id" 2>/dev/null || true)"; \ + health="$$(docker inspect -f '{{if .State.Health}}{{.State.Health.Status}}{{end}}' "$$container_id" 2>/dev/null || true)"; \ + exit_code="$$(docker inspect -f '{{.State.ExitCode}}' "$$container_id" 2>/dev/null || true)"; \ + error="$$(docker inspect -f '{{.State.Error}}' "$$container_id" 2>/dev/null || true)"; \ + if [ -n "$$error" ]; then \ + exit 1; \ + fi; \ + [ -n "$$health" ] && echo "Container health: $$health" >&2; \ + [ -n "$$state" ] && echo "Container state: $$state" >&2; \ + [ -n "$$exit_code" ] && echo "Container exit code: $$exit_code" >&2; \ + echo 'Recent logs:' >&2; \ + $(DOCKER_COMPOSE_DEV) logs --tail=50 app >&2 || true; \ + fi; \ + exit 1; \ + fi +endif + +ifeq ($(PRIMARY_GOAL),open) +open: ## Open the running app in the default browser. + @set -eu; \ + if ! port="$$( $(DOCKER_COMPOSE_DEV) port app 80 2>/dev/null )" || [ -z "$$port" ]; then \ + echo 'Start server with `make up` first.' >&2; \ + exit 0; \ + fi; \ + host_port="$${port##*:}"; \ + url="http://localhost$$( [ "$$host_port" = '80' ] || printf ':%s' "$$host_port" )"; \ + opener="$$(command -v xdg-open || command -v open || command -v wslview || true)"; \ + if [ -z "$$opener" ]; then \ + echo "Could not open $$url." >&2; \ + exit 0; \ + fi; \ + "$$opener" "$$url" >/dev/null 2>&1 & endif ifeq ($(PRIMARY_GOAL),down) diff --git a/README.md b/README.md index 4d1d9a6..b049032 100644 --- a/README.md +++ b/README.md @@ -85,13 +85,19 @@ To run the app: make up ``` +To open the running app in your default browser: + +```shell +make open +``` + To stop the app: ```shell make down ``` -The application is available at `https://localhost`. +The application is available at `http://localhost`. Other make commands are available in the `Makefile` and can be listed with: From 78945d04d0277df5d34a73fb8ce56553a4445a5a Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Tue, 21 Apr 2026 19:18:33 +0300 Subject: [PATCH 2/2] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6888b5e..9aa0f65 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## 1.4.1 under development -- Enh: Add `make open` and improve `make up` UX (@samdark) +- Enh #276: Add `make open` and improve `make up` UX (@samdark) ## 1.4.0 April 12, 2026