Skip to content

Commit

Permalink
Rename env variable POSTGRES_PORT -> PGPORT
Browse files Browse the repository at this point in the history
  • Loading branch information
aliavni committed Apr 18, 2024
1 parent ebaf9a6 commit f20f69b
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 17 deletions.
7 changes: 7 additions & 0 deletions .env.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
POSTGRES_DB=police_data
POSTGRES_HOST=db
PGPORT=5432
PDT_API_PORT=5000
MIXPANEL_TOKEN=604dcfd426470eedb44ef667963ee2af
12 changes: 1 addition & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,7 @@ This method uses Docker to run the complete application stack.

1. Make sure that [Docker](https://www.docker.com) is installed on your machine.

2. Create a `.env` file in the root of your local project folder, and add your preferred PostgreSQL username and password:

```
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
POSTGRES_DB=police_data
POSTGRES_HOST=db
POSTGRES_PORT=5432
PDT_API_PORT=5000
MIXPANEL_TOKEN=your_mixpanel_token
```
2. Create a `.env` file by running `cp .env.template .env` in the root of your local project folder, and add your preferred PostgreSQL username and password:

> **Note**
> When running locally, you may need to update one of the ports in the `.env` file if it conflicts with another application on your machine.
Expand Down
4 changes: 2 additions & 2 deletions backend/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Config(object):
hours=os.environ.get("TOKEN_EXPIRATION_HOURS", 12)
)
POSTGRES_HOST = os.environ.get("POSTGRES_HOST", "localhost")
POSTGRES_PORT = os.environ.get("POSTGRES_PORT", 5432)
PGPORT = os.environ.get("PGPORT", 5432)
POSTGRES_USER = os.environ.get("POSTGRES_USER", "postgres")
POSTGRES_PASSWORD = os.environ.get("POSTGRES_PASSWORD", "postgres")
POSTGRES_DB = os.environ.get("POSTGRES_DB", "police_data")
Expand Down Expand Up @@ -71,7 +71,7 @@ def SQLALCHEMY_DATABASE_URI(self):
self.POSTGRES_USER,
self.POSTGRES_PASSWORD,
self.POSTGRES_HOST,
self.POSTGRES_PORT,
self.PGPORT,
self.POSTGRES_DB,
)

Expand Down
2 changes: 1 addition & 1 deletion backend/database/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def db_cli(ctx: click.Context):
user=current_app.config["POSTGRES_USER"],
password=current_app.config["POSTGRES_PASSWORD"],
host=current_app.config["POSTGRES_HOST"],
port=current_app.config["POSTGRES_PORT"],
port=current_app.config["PGPORT"],
dbname="postgres",
)
conn.autocommit = True
Expand Down
2 changes: 1 addition & 1 deletion backend/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def database():
janitor = DatabaseJanitor(
cfg.POSTGRES_USER,
cfg.POSTGRES_HOST,
cfg.POSTGRES_PORT,
cfg.PGPORT,
cfg.POSTGRES_DB,
9.6,
cfg.POSTGRES_PASSWORD,
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ services:
volumes:
- postgres:/var/lib/postgresql/data
ports:
- ${POSTGRES_PORT:-5432}:${POSTGRES_PORT:-5432}
- ${PGPORT:-5432}:${PGPORT:-5432}
web:
build:
context: ./frontend
Expand Down Expand Up @@ -36,7 +36,7 @@ services:
PYTHONPATH: app/
POSTGRES_HOST: db
FLASK_ENV: ${FLASK_ENV:-development}
WAIT_HOSTS: db:${POSTGRES_PORT:-5432}
WAIT_HOSTS: db:${PGPORT:-5432}
MIXPANEL_TOKEN: ${MIXPANEL_TOKEN:-notset}
ports:
- ${PDT_API_PORT:-5000}:${PDT_API_PORT:-5000}
Expand Down

0 comments on commit f20f69b

Please sign in to comment.