Skip to content

Commit 34990d7

Browse files
authored
Merge pull request #58 from bmbouter/update-some-docs
Fix docs and align default db name to container
2 parents 8bbc91b + 14be6fc commit 34990d7

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

README.md

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ provide the database locally with the commands below (taken from
100100
Fetch the container with: `podman pull docker.io/library/postgres`. Afterwards you can see it listed
101101
with `podman images`.
102102

103-
Start the container with: `podman run -dt --name my-postgres -e POSTGRES_PASSWORD=1234 -p 5432:5432 postgres`
103+
Start the container with: `podman run -dt --name my-postgres -e POSTGRES_PASSWORD=postgres -p 5432:5432 postgres`
104104

105105
Connect to the db with `psql` using `podman exec -it my-postgres bash`. Then connect with user
106106
`postgres` which is the default of the postgres container. Here's a full example:
@@ -116,21 +116,28 @@ Did not find any relations.
116116
postgres=#
117117
```
118118

119-
4. Configure the Python App to Use Postgresql
119+
4. Set the `APP_KEY`
120120

121-
By default, the app uses environment variable for [database settings](https://github.com/pulp/analytics.pulpproject.org/blob/01c491eee833c8dc3513e3b56c2f349511bb162e/app/settings.py#L86-L90)
122-
and [`SECRET_KEY`](https://github.com/pulp/analytics.pulpproject.org/blob/01c491eee833c8dc3513e3b56c2f349511bb162e/app/settings.py#L24).
123-
Set these environment variables like this:
121+
The app uses an environment variable `APP_KEY` to specify the Django `SECRET_KEY` [here](https://github.com/pulp/analytics.pulpproject.org/blob/dev/app/settings.py#L25).
122+
You need to set a random string as the `APP_KEY`.
124123

124+
```shell
125+
export APP_KEY="ceb0c58c-5789-499a-881f-410aec5e1003"
125126
```
127+
128+
Note: The `APP_KEY` is just a random string here.
129+
130+
If using the default values of the postgresql image this isn't needed, but optionally, if you want
131+
to specify db connection info that also happens as environment variables [here](https://github.com/pulp/analytics.pulpproject.org/blob/dev/app/settings.py#L104-L107).
132+
If you did want to set them you could do it like:
133+
134+
```shell
126135
export DB_DATABASE="postgres"
127136
export DB_USERNAME="postgres"
128-
export DB_PASSWORD="1234"
137+
export DB_PASSWORD="postgres"
129138
export DB_HOST="localhost"
130-
export APP_KEY="ceb0c58c-5789-499a-881f-410aec5e1003"
131139
```
132140

133-
The APP_KEY is just a random string here.
134141

135142
5. Apply Migrations
136143

app/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
DATABASES = {
102102
"default": {
103103
"ENGINE": "django.db.backends.postgresql",
104-
"NAME": os.environ.get("DB_DATABASE", "pulpanalytics"),
104+
"NAME": os.environ.get("DB_DATABASE", "postgres"),
105105
"USER": os.environ.get("DB_USERNAME", "postgres"),
106106
"PASSWORD": os.environ.get("DB_PASSWORD", "postgres"),
107107
"HOST": os.environ.get("DB_HOST", "localhost"),

0 commit comments

Comments
 (0)