Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Add just targets for simple stack handling #2985

Merged
merged 9 commits into from
Jan 10, 2024
54 changes: 50 additions & 4 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,55 @@ openapiDir := "./docs/03-endpoints/generated-openapi"
default:
@just --list

# Update the OpenApi yml files by generating these from the tAPIr specs
alias dog := docs-openapi-generate
alias ssl := stack-start-latest
alias stop := stack-stop

# Generate the OpenApi in {{openapiDir}} yml from the tapir endpoints
docs-openapi-generate:
mkdir -p {{openapiDir}}
rm {{openapiDir}}/*.yml >> /dev/null 2>&1 || true
sbt "webapi/runMain org.knora.webapi.slice.common.api.DocsGenerator {{openapiDir}}"
# The generated files are stored in the docs/03-endpoints/generated-openapi directory
# You can specify the directory where the files are stored by setting the openapiDir variable
# e.g. `just openapiDir=/tmp/openapi docs-openapi-generate`
mkdir -p {{ openapiDir }}
rm {{ openapiDir }}/*.yml >> /dev/null 2>&1 || true
./sbtx "webapi/runMain org.knora.webapi.slice.common.api.DocsGenerator {{ openapiDir }}"

# Start stack
stack-start:
@echo "Starting Stack"
docker compose up -d
./webapi/scripts/wait-for-db.sh
@echo "Stack started"

# Start stack and pull latest images before starting
stack-start-latest: && stack-start
@echo "Pulling latest"
docker compose pull

# Stop stack
stack-stop:
@echo "Stopping Stack"
docker compose stop
@echo "Stack stopped"

# Restart stack
stack-restart: stack-stop && stack-start

# Stops and removes all containers and stack related volumes and network
[confirm]
stack-destroy:
@echo "Destroying Stack"
@echo "\nStopping and removing containers"
docker stop $(docker ps -aq)
docker rm $(docker ps -aq)
@echo "\nPruning Network"
docker network rm knora-net
@echo "\nPruning Volumes"
docker volume rm dsp-api_db-home -f
docker volume rm dsp-api_db-import -f
@echo "Stack destroyed"

# Initialize the db with a set of test data
[confirm]
stack-init-test: && stack-start
make init-db-test
Loading