110 lines
No EOL
3.1 KiB
Makefile
110 lines
No EOL
3.1 KiB
Makefile
set dotenv-load := true
|
|
|
|
run: install-dependencies start-database migrate-database seed-database
|
|
mix phx.server
|
|
|
|
install-dependencies:
|
|
mix deps.get
|
|
|
|
migrate-database:
|
|
mix ash.setup
|
|
|
|
reset-database:
|
|
mix ash.reset
|
|
MIX_ENV=test mix ash.reset
|
|
|
|
seed-database:
|
|
mix run priv/repo/seeds.exs
|
|
|
|
start-database:
|
|
docker compose up -d
|
|
|
|
ci-dev: lint audit test
|
|
|
|
gettext:
|
|
mix gettext.extract
|
|
mix gettext.merge priv/gettext --on-obsolete=mark_as_obsolete
|
|
|
|
lint:
|
|
mix format --check-formatted
|
|
mix compile --warnings-as-errors
|
|
mix credo
|
|
mix gettext.extract --check-up-to-date
|
|
|
|
audit:
|
|
mix sobelow --config
|
|
mix deps.audit
|
|
mix hex.audit
|
|
|
|
test *args: install-dependencies start-database
|
|
mix test {{args}}
|
|
|
|
format:
|
|
mix format
|
|
|
|
build-docker-container:
|
|
docker build --tag mitgliederverwaltung .
|
|
|
|
# This is meant for debugging the container build process only.
|
|
run-docker-container: build-docker-container
|
|
docker run -e "SECRET_KEY_BASE=ahK8BeiDaibaige1ahkooS0chie9lo7the7uuzar0eeBeeCh2iereteshee2Oosu" -e='DATABASE_URL=postgres://postgres@localhost:5432/mv_dev' -e='PORT=4040' -e='PHX_HOST=localhost' --network=host mitgliederverwaltung
|
|
|
|
# Usage:
|
|
# just regen-migrations migration_name [commit_hash]
|
|
# If commit_hash is given, rollback & delete the migrations from that commit.
|
|
# Otherwise, rollback & delete all untracked migrations.
|
|
regen-migrations migration_name commit_hash='':
|
|
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
# Pick migrations either from the given commit or untracked files
|
|
if [ -n "{{commit_hash}}" ]; then
|
|
echo "→ Rolling back migrations from commit {{commit_hash}}"
|
|
MIG_FILES=$(git show --name-only --pretty=format: "{{commit_hash}}" \
|
|
| grep -E "^priv/repo/migrations/|^priv/resource_snapshots")
|
|
else
|
|
echo "→ Rolling back all untracked migrations"
|
|
MIG_FILES=$(git ls-files --others priv/repo/migrations)
|
|
fi
|
|
|
|
# Roll back in Ash
|
|
COUNT=$(echo "$MIG_FILES" | wc -l)
|
|
mix ash_postgres.rollback -n "$COUNT"
|
|
|
|
# Remove the migration files
|
|
echo removing $MIG_FILES
|
|
echo "$MIG_FILES" | xargs rm -f
|
|
|
|
# Also clean up any untracked resource snapshots
|
|
git ls-files --others priv/resource_snapshots | xargs rm -f
|
|
|
|
# Generate a fresh migration
|
|
mix ash.codegen --name "{{migration_name}}"
|
|
|
|
# Remove all build artifacts
|
|
clean:
|
|
mix clean
|
|
rm -rf .elixir_ls
|
|
rm -rf _build
|
|
|
|
# Production environment commands
|
|
# ================================
|
|
|
|
# Initialize secrets directory with generated secrets (only if not exists)
|
|
init-secrets:
|
|
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
if [ -d "secrets" ]; then
|
|
echo "Secrets directory already exists. Skipping generation."
|
|
exit 0
|
|
fi
|
|
echo "Creating secrets directory and generating secrets..."
|
|
mkdir -p secrets
|
|
mix phx.gen.secret > secrets/secret_key_base.txt
|
|
mix phx.gen.secret > secrets/token_signing_secret.txt
|
|
openssl rand -base64 32 | tr -d '\n' > secrets/db_password.txt
|
|
touch secrets/oidc_client_secret.txt
|
|
echo "Secrets generated in ./secrets/"
|
|
|
|
# Start production environment with Docker Compose
|
|
start-prod: init-secrets
|
|
docker compose -f docker-compose.prod.yml up -d
|