refactor(taskfiles): extract start logic out of taskfile

This commit is contained in:
Marc 2023-12-16 21:32:05 -05:00
parent 6b49313e3f
commit 0582f9877e
Signed by: marc
GPG key ID: 048E042F22B5DC79
4 changed files with 22 additions and 7 deletions

View file

@ -46,8 +46,10 @@ tasks:
start:
desc: "Starts the backend application."
deps: [docker-build]
cmd: docker run -d -p 8000:8000 --name {{ .APP_CONTAINER_NAME }} {{ .CLI_ARGS }} --add-host docker.host.internal:host-gateway --env-file ../../backend.env rotini:dev
dir: backend/rotini
env:
APP_CONTAINER_NAME: "{{ .APP_CONTAINER_NAME }}"
cmd: . script/start.sh
dir: backend
stop:
desc: "Stops the backend application."
cmd: docker rm -f {{ .APP_CONTAINER_NAME }}

View file

@ -1,2 +1,7 @@
DJANGO_SECRET_KEY="notakey"
JWT_SIGNING_SECRET="notasecret"
DB_HOST="rotini_db"
DB_USER="postgres"
DB_PASSWORD="postgres"
DB_PORT=5432
DB_NAME="postgres"

View file

@ -64,11 +64,11 @@ WSGI_APPLICATION = "base.wsgi.application"
DATABASES = {
"default": {
"ENGINE": "django.db.backends.postgresql_psycopg2",
"NAME": "postgres",
"USER": "postgres",
"PASSWORD": "test",
"HOST": "docker.host.internal",
"PORT": "5432",
"NAME": os.environ["DB_NAME"],
"USER": os.environ["DB_USER"],
"PASSWORD": os.environ["DB_PASSWORD"],
"HOST": os.environ["DB_HOST"],
"PORT": os.environ["DB_PORT"],
}
}

8
backend/script/start.sh Normal file
View file

@ -0,0 +1,8 @@
#!/bin/bash
docker run \
--detach \
--publish 8000:8000 \
--name $APP_CONTAINER_NAME \
--env-file ../backend.env \
rotini:dev