chore: Add initial Justfile and .env.example for environment configuration

This commit is contained in:
2026-03-07 04:04:24 +07:00
parent 0fa29813df
commit ae7d9f9819
3 changed files with 67 additions and 0 deletions

8
.env.example Normal file
View File

@@ -0,0 +1,8 @@
### Setup ###
REGISTRY_URL=''
### Postgres ###
POSTGRES_USER='postgres'
POSTGRES_PASSWORD='postgres'
POSTGRES_DB='postgres'
POSTGRES_PORT='5432'

57
Justfile Normal file
View File

@@ -0,0 +1,57 @@
set shell := ["bash", "-euo", "pipefail", "-c"]
set dotenv-load := true
VARIANT := env("VARIANT", "postgres")
REGISTRY_URL := env("REGISTRY_URL", "")
VERSION := env("VERSION", "latest")
_default:
@echo "Default env variables:"
@echo " VARIANT: {{VARIANT}}"
@echo " REGISTRY_URL: {{REGISTRY_URL}}"
@echo " VERSION: {{VERSION}}"
@just --list
### Build & Publish ###
# Build image locally
build db=VARIANT:
#!/usr/bin/env bash
PREFIX=${REGISTRY_URL:+${REGISTRY_URL}/}
IMAGE="{{db}}:{{VERSION}}"
echo "docker build -f {{db}}/Dockerfile -t ${PREFIX}${IMAGE} ."
docker build -f {{db}}/Dockerfile -t ${PREFIX}${IMAGE} .
# Build and push image to registry - no echo for security
publish db=VARIANT:
#!/usr/bin/env bash
PREFIX=${REGISTRY_URL:+${REGISTRY_URL}/}
IMAGE="{{db}}:{{VERSION}}"
just build {{db}}
docker push ${PREFIX}${IMAGE}
### Tests ###
# Start a database and wait until it's healthy
db-up db=VARIANT:
docker compose -f {{db}}/compose.yml up -d --wait
# Stop a database and remove volumes
db-down db=VARIANT:
docker compose -f {{db}}/compose.yml down -v
# Run tests against a database variant
test db=VARIANT:
@case "{{db}}" in \
postgres) just _test-postgres ;; \
*) echo "Unknown database: {{db}}" >&2; exit 1 ;; \
esac
# Run tests against a Postgres database
_test-postgres:
#!/usr/bin/env bash
trap 'just db-down postgres' EXIT
just db-up postgres
docker compose -f postgres/compose.yml exec postgres pg_isready -U ${POSTGRES_USER}

2
mise.toml Normal file
View File

@@ -0,0 +1,2 @@
[tools]
just = "latest"