From 5b515ecd91cff5bfdc0d2ec33342b0e654e2d2a1 Mon Sep 17 00:00:00 2001 From: Jef Roosens Date: Thu, 15 Apr 2021 17:21:32 +0200 Subject: [PATCH 1/2] [#23] Build script now starts postgres database as well --- Makefile | 6 ++++++ build | 17 ++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 6ad1f50..820f893 100644 --- a/Makefile +++ b/Makefile @@ -36,6 +36,7 @@ run: # As a workaround, we just have a stop command that stops the container. stop: @ docker stop -t 2 fej + @ docker stop fej_db .PHONY: stop # This attaches to the running container, essentially giving the same result as @@ -44,6 +45,11 @@ logs: @ docker logs -f fej .PHONY: logs +# This just starts up a shell inside the fej container +sh: + @ docker exec -it fej sh +.PHONY: sh + # Builds the debug version, and runs the tests (but doesn't detach). test: @ ./build -m dev -a run -l -- test --no-fail-fast diff --git a/build b/build index d7d86a3..484a8ab 100755 --- a/build +++ b/build @@ -72,7 +72,21 @@ if [[ "$action" = push ]]; then [[ "$tag" != "$tags" ]] && docker rmi "$image:$tag" done - elif [[ "$action" = run ]]; then +elif [[ "$action" = run ]]; then + # Create the network & start the database container + docker network create fej + docker volume create fej_db-data + + docker run --rm \ + --detach \ + --name fej_db \ + --network fej \ + -e "POSTGRES_DB=fej" \ + -e "POSTGRES_USER=fej" \ + -e "POSTGRES_PASSWORD=fej" \ + -v 'fej_db-data:/var/lib/postgresql/data' \ + postgres:13-alpine + if [[ "$mode" = "dev" ]]; then # Create caching volumes if needed (they need to be named) docker volume create fej_build-cache @@ -87,5 +101,6 @@ if [[ "$action" = push ]]; then --tty \ --publish 8000:8000 \ --name fej \ + --network fej \ "$image$([[ "$mode" != "rel" ]] && echo "-dev"):$tags" "$@" fi From 6954921df622bdf5cd456154c407330be7fca837 Mon Sep 17 00:00:00 2001 From: Jef Roosens Date: Thu, 15 Apr 2021 17:31:45 +0200 Subject: [PATCH 2/2] [#23] Added needed env vars --- .env | 1 + build | 1 + 2 files changed, 2 insertions(+) create mode 100644 .env diff --git a/.env b/.env new file mode 100644 index 0000000..880c44c --- /dev/null +++ b/.env @@ -0,0 +1 @@ +DATABASE_URL=postgres://fej:fej@fej_db:5432/fej diff --git a/build b/build index 484a8ab..962d14c 100755 --- a/build +++ b/build @@ -101,6 +101,7 @@ elif [[ "$action" = run ]]; then --tty \ --publish 8000:8000 \ --name fej \ + --env-file .env \ --network fej \ "$image$([[ "$mode" != "rel" ]] && echo "-dev"):$tags" "$@" fi