From 39a0e2befe68499676d948cf723f1b9af98847fd Mon Sep 17 00:00:00 2001 From: Cesar Flores Date: Mon, 9 Mar 2026 05:23:55 +0700 Subject: [PATCH] fix: replace Justfile with new container management and testing commands --- Justfile | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ justfile | 23 --------------- 2 files changed, 85 insertions(+), 23 deletions(-) create mode 100644 Justfile delete mode 100644 justfile diff --git a/Justfile b/Justfile new file mode 100644 index 0000000..f885d07 --- /dev/null +++ b/Justfile @@ -0,0 +1,85 @@ +set shell := ["bash", "-euo", "pipefail", "-c"] +set dotenv-load := true + +SERVICE := env("SERVICE", "dev-tools") +VARIANT := env("VARIANT", "base") + +_default: + @echo "Default env variables:" + @echo " SERVICE: {{SERVICE}}" + @echo " VARIANT: {{VARIANT}}" + @just --list + +### Container Management ### + +# Start the service and wait until it's healthy +up service=SERVICE variant=VARIANT: + just build {{service}} {{variant}} + docker compose -f {{service}}/{{variant}}/compose.yml up -d --wait + +# Stop the service container but preserve data volumes +down service=SERVICE variant=VARIANT: + docker compose -f {{service}}/{{variant}}/compose.yml down + +# Remove containers and data volumes but preserve images +down-volumes service=SERVICE variant=VARIANT: + docker compose -f {{service}}/{{variant}}/compose.yml down -v + +# Remove containers, volumes, and images +down-all service=SERVICE variant=VARIANT: + docker compose -f {{service}}/{{variant}}/compose.yml down -v --rmi all + +### Shell Access ### + +# Access a bash shell inside the running container +bash service=SERVICE variant=VARIANT: + docker compose -f {{service}}/{{variant}}/compose.yml exec {{service}} bash + +# Access a sh shell inside the running container +sh service=SERVICE variant=VARIANT: + docker compose -f {{service}}/{{variant}}/compose.yml exec {{service}} sh + +### Build & Publish ### + +# Build image locally +build service=SERVICE variant=VARIANT: + #!/usr/bin/env bash + IMAGE="{{service}}" + VERSION="{{variant}}" + + echo "docker build -f {{service}}/{{variant}}/Dockerfile -t ${IMAGE}:${VERSION} {{service}}/{{variant}}" + docker build -f {{service}}/{{variant}}/Dockerfile -t ${IMAGE}:${VERSION} {{service}}/{{variant}} + +# Build and push image to registry +push service=SERVICE variant=VARIANT: + #!/usr/bin/env bash + PREFIX=${REGISTRY_URL:+${REGISTRY_URL}/} + IMAGE="{{service}}" + VERSION="{{variant}}" + + just build {{service}} {{variant}} + + echo "docker tag ${IMAGE}:${VERSION} ${PREFIX}${IMAGE}:${VERSION}" + docker tag ${IMAGE}:${VERSION} ${PREFIX}${IMAGE}:${VERSION} + + echo "docker push ${PREFIX}${IMAGE}:${VERSION}" + docker push ${PREFIX}${IMAGE}:${VERSION} + +### Tests ### + +# Run tests against a service +test service=SERVICE variant=VARIANT: + #!/usr/bin/env bash + just up {{service}} {{variant}} + trap "just down {{service}} {{variant}}" EXIT + case "{{service}}:{{variant}}" in + dev:base) just _test-dev base ;; + *) echo "Unknown service: {{service}} {{variant}}" >&2; exit 1 ;; + esac + +_test-dev variant=VARIANT: + #!/usr/bin/env bash + docker compose -f dev/{{variant}}/compose.yml exec bash -c " + mise --version + mise ls + " diff --git a/justfile b/justfile deleted file mode 100644 index a0aec49..0000000 --- a/justfile +++ /dev/null @@ -1,23 +0,0 @@ -set shell := ["bash", "-c"] - -IMAGE := env("IMAGE", "dev-tools") -VERSION := env("VERSION", "latest") - -# Setup environment -setup: - mise install - -# Build the Docker image -build: - docker build -t {{IMAGE}}:{{VERSION}} . - -# Tests inside the docker image -test: - docker build -t {{IMAGE}}:test . - docker run --rm {{IMAGE}}:test sh -c "\ - mise --version \ - && python --version \ - && node --version" - -push: - docker push {{IMAGE}}:{{VERSION}}