refactor(taskfiles): consolidate start+stop, add namespace for docker tasks

This commit is contained in:
Marc 2023-12-18 00:00:36 -05:00
parent b5b8213be3
commit 35ca5ed377
Signed by: marc
GPG key ID: 048E042F22B5DC79
2 changed files with 23 additions and 13 deletions

View file

@ -34,28 +34,23 @@ tasks:
cmd: . script/test
dotenv:
- ../backend-test.env
start:
lock-deps:
desc: "Locks production and development dependencies"
deps: [bootstrap]
cmd: . script/requirements-lock
docker:start:
desc: "Starts the backend application."
deps: [build]
cmd: . script/start.sh
dotenv:
- ../backend.env
stop:
docker:stop:
desc: "Stops the backend application."
cmd: docker rm -f {{ .APP_CONTAINER_NAME }} {{ .DB_CONTAINER_NAME }}
logs:
docker:logs:
desc: "Shortcut to Docker container logs"
cmd: docker logs {{ .APP_CONTAINER_NAME }} -f
start-db:
desc: "Provisions a local Postgres database."
dotenv:
- ../backend.env
cmd: . script/provision-db
lock-deps:
desc: "Locks production and development dependencies"
deps: [bootstrap]
cmd: . script/requirements-lock
build:
docker:build:
desc: "Builds a docker image from /backend"
cmd: . script/build.sh

View file

@ -1,5 +1,20 @@
#!/bin/bash
docker run \
--name $DB_CONTAINER_NAME \
-e POSTGRES_PASSWORD=$DATABASE_PASSWORD \
-e POSTGRES_USER=$DATABASE_USER \
-e POSTGRES_DB=$DATABASE_NAME \
-v $DATABASE_STORAGE_PATH:/var/lib/postgresql/data \
-p 5432:5432 \
-d \
postgres:15.4
until [ -n "$(docker exec $DB_CONTAINER_NAME pg_isready | grep accepting)" ]; do
echo "Waiting for DB to come alive..."
sleep 0.1;
done;
docker run \
--detach \
--publish 8000:8000 \