From 43129905fc7e114746b670e2941d79c97eb92327 Mon Sep 17 00:00:00 2001 From: Firmino Changani Date: Sat, 22 Jul 2023 21:44:25 +0100 Subject: [PATCH 1/4] ignore any *.env file --- .gitignore | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 1fb6b34..d587634 100644 --- a/.gitignore +++ b/.gitignore @@ -5,5 +5,6 @@ venv/ __azurite* ./digger cloud -.env -.docker-compose-env +*.env +*.env.* + From 6cf708219d665c861d9d2204063a88abee45cedf Mon Sep 17 00:00:00 2001 From: Firmino Changani Date: Sat, 22 Jul 2023 21:45:53 +0100 Subject: [PATCH 2/4] improve app startup - link the web container to postgres container and add healthchecks - rename the .env file --- docker-compose.yml | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 905da19..541328b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,5 @@ version: '3.7' - services: postgres: image: postgres:alpine @@ -8,15 +7,20 @@ services: - "5432:5432" environment: - POSTGRES_PASSWORD=23q4RSDFSDFS + healthcheck: + test: [ "CMD-SHELL", "pg_isready -U postgres" ] + interval: 5s + timeout: 5s + retries: 5 web: - depends_on: + links: - postgres - build: - context: . - dockerfile: Dockerfile + depends_on: + postgres: + condition: service_healthy + build: ./ env_file: - - .docker-compose-env - restart: always + - .env.docker-compose ports: - - "3000:3000" \ No newline at end of file + - "3100:3000" \ No newline at end of file From 309042ca5eb2cb26c1f68a06d37b7e34cf6bd660 Mon Sep 17 00:00:00 2001 From: Firmino Changani Date: Sat, 22 Jul 2023 21:46:43 +0100 Subject: [PATCH 3/4] update the guide for initial config & dev --- README.md | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index df25fbc..aeca8a8 100644 --- a/README.md +++ b/README.md @@ -2,10 +2,8 @@ The repository for digger official API. # How to run for development -``` -# run the database -docker-compse up -# create .env file with creds -echo "DATABASE_URL=postgres://postgres:23q4RSDFSDFS@127.0.0.1:5432/postgres" >> .env -make start -``` +1. Create the environment files for local development: + 2. `echo "DATABASE_URL=postgres://postgres:23q4RSDFSDFS@127.0.0.1:5432/postgres" > .env` + 3. `echo "DATABASE_URL=postgres://postgres:23q4RSDFSDFS@postgres:5432/postgres" > .env.docker-compose` +2. Start the Docker containers for the database and the API via `docker-compose up` or `docker-compose up -d` which should make it available from http://localhost:3100 +3. You can also run the API by typing `make start` which should make it available from http://localhost:3000 \ No newline at end of file From 9e857f4e96de125561c9d62ffce6075992eeab7f Mon Sep 17 00:00:00 2001 From: Firmino Changani Date: Sat, 22 Jul 2023 21:47:21 +0100 Subject: [PATCH 4/4] fmt --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 541328b..8328d9d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -23,4 +23,4 @@ services: env_file: - .env.docker-compose ports: - - "3100:3000" \ No newline at end of file + - "3100:3000"