Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: database container #46

Merged
merged 3 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions backend/utils/docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ file_env DB_DEFAULT_PASSWORD

export DB_DEFAULT="{
\"ENGINE\": \"${DB_DEFAULT_ENGINE:=django.db.backends.postgresql}\",
\"NAME\": \"${DB_DEFAULT_NAME:=kernelci}\",
\"NAME\": \"${DB_DEFAULT_NAME:=playground_kcidb}\",
\"USER\": \"${DB_DEFAULT_USER:=kernelci}\",
\"PASSWORD\": \"$DB_DEFAULT_PASSWORD\",
\"HOST\": \"${DB_DEFAULT_HOST:=db}\",
\"HOST\": \"${DB_DEFAULT_HOST:=cloudsql-proxy}\",
\"PORT\": \"${DB_DEFAULT_PORT:=5432}\",
\"CONN_MAX_AGE\": ${DB_DEAFULT_CONN_MAX_AGE:=null},
\"OPTIONS\": {
\"connect_timeout\": ${DB_DEFAULT_TIMEOUT:=2}
\"connect_timeout\": ${DB_DEFAULT_TIMEOUT:=16}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that is really needed? 🤔

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is just to be sure, sometimes the connection with db can be slow

}
}"

Expand Down
31 changes: 13 additions & 18 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,16 @@ secrets:
file: ./backend/runtime/secrets/postgres_password_secret

services:
db:
image: postgres:16.3-alpine
cloudsql-proxy:
image: gcr.io/cloudsql-docker/gce-proxy:latest
command: /cloud_sql_proxy --dir=/cloudsql -instances=kernelci-production:us-central1:postgresql2=tcp:0.0.0.0:5432 -credential_file=/secrets/cloudsql/application_default_credentials.json
ports:
- 5432:5432
volumes:
- ./application_default_credentials.json:/secrets/cloudsql/application_default_credentials.json
networks:
- private
environment:
- POSTGRES_USER=kernelci
- POSTGRES_PASSWORD_FILE=/run/secrets/postgres_password_secret
- PGDATA=/var/run/postgresql/data
volumes:
- db-data:/var/run/postgresql/data
ports:
- target: 5432
published: 5432
protocol: tcp
mode: host
secrets:
- postgres_password_secret
restart: always

backend:
build: ./backend
Expand All @@ -41,16 +34,17 @@ services:
published: 8000
protocol: tcp
mode: host
depends_on:
- cloudsql-proxy
secrets:
- postgres_password_secret
environment:
- 'ALLOWED_HOSTS=["backend"]'
- 'ALLOWED_HOSTS=["backend", "localhost"]'
- DB_DEFAULT_PASSWORD_FILE=/run/secrets/postgres_password_secret
- DB_DEFAULT_HOST=db
- DB_DEFAULT_HOST=cloudsql-proxy

dashboard:
build: ./dashboard
restart: always
image: dashboard:latest

collect_static:
Expand All @@ -66,6 +60,7 @@ services:
restart: always
depends_on:
- backend
- collect_static
networks:
- public
volumes:
Expand Down