Skip to content

Commit

Permalink
fix(docker-compose): rename database -> postgres
Browse files Browse the repository at this point in the history
  • Loading branch information
mohamad-liyaghi committed Jul 25, 2024
1 parent 5220b55 commit 2d81ccf
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 51 deletions.
17 changes: 6 additions & 11 deletions backend/.env.local
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,13 @@ SECRET_KEY='django-insecure-4$97jqsglkh1@q3a5u2mv&=l=1*46r*p2090$j=0=5sv@(@d@('
ALLOWED_HOSTS=['*']

# DATABASE
DATABASE_NAME=academy_master_local
TEST_DATABASE_NAME=academy_master_local_test
POSTGRES_NAME=academy_master_local
TEST_POSTGRES_NAME=academy_master_local_test
POSTGRES_USER=postgres
POSTGRES_PASSWORD=1234EErr
POSTGRES_HOST=postgres
POSTGRES_PORT=5432

DATABASE_USER=postgres
DATABASE_PASSWORD=1234EErr
DATABASE_HOST=database
DATABASE_PORT=5432

# PostgreSQL
POSTGRES_DB=${DATABASE_NAME}
POSTGRES_USER=${DATABASE_USER}
POSTGRES_PASSWORD=${DATABASE_PASSWORD}

# Celery
CELERY_BROKER_URL=amqp://rabbituser:1234EErr@rabbitmq:5672/
Expand Down
19 changes: 7 additions & 12 deletions backend/.env.prod
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,13 @@
SECRET_KEY='django-insecure-4$97jqsglkh1@q3a5u2mv&=l=1*46r*p2090$j=0=5sv@(@d@('
ALLOWED_HOSTS=['*']

# DATABASE
DATABASE_NAME=academy_master_production
TEST_DATABASE_NAME=academy_master_production_test
DATABASE_USER=postgres
DATABASE_PASSWORD=1234EErr
DATABASE_HOST=database
DATABASE_PORT=5432

# Postgres Config
POSTGRES_DB=${DATABASE_NAME}
POSTGRES_USER=${DATABASE_USER}
POSTGRES_PASSWORD=${DATABASE_PASSWORD}
# Postgres
POSTGRES_NAME=academy_master_production
POSTGRES_USER=postgres
POSTGRES_PASSWORD=1234EErr
POSTGRES_HOST=postgres
POSTGRES_PORT=5432
TEST_POSTGRES_NAME=academy_master_production_test


# Celery
Expand Down
10 changes: 5 additions & 5 deletions backend/config/settings/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
DATABASES = {
"default": {
"ENGINE": "django.db.backends.postgresql_psycopg2",
"NAME": config("DATABASE_NAME"),
"USER": config("DATABASE_USER"),
"PASSWORD": config("DATABASE_PASSWORD"),
"HOST": config("DATABASE_HOST"),
"PORT": config("DATABASE_PORT"),
"NAME": config("POSTGRES_NAME"),
"USER": config("POSTGRES_USER"),
"PASSWORD": config("POSTGRES_PASSWORD"),
"HOST": config("POSTGRES_HOST"),
"PORT": config("POSTGRES_PORT"),
}
}

Expand Down
10 changes: 5 additions & 5 deletions backend/config/settings/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
DATABASES = {
"default": {
"ENGINE": "django.db.backends.postgresql_psycopg2",
"NAME": config("DATABASE_NAME"),
"USER": config("DATABASE_USER"),
"PASSWORD": config("DATABASE_PASSWORD"),
"HOST": config("DATABASE_HOST"),
"PORT": config("DATABASE_PORT"),
"NAME": config("POSTGRES_NAME"),
"USER": config("POSTGRES_USER"),
"PASSWORD": config("POSTGRES_PASSWORD"),
"HOST": config("POSTGRES_HOST"),
"PORT": config("POSTGRES_PORT"),
}
}

Expand Down
10 changes: 5 additions & 5 deletions backend/config/settings/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
DATABASES = {
"default": {
"ENGINE": "django.db.backends.postgresql_psycopg2",
"NAME": config("TEST_DATABASE_NAME"),
"USER": config("DATABASE_USER"),
"PASSWORD": config("DATABASE_PASSWORD"),
"HOST": config("DATABASE_HOST"),
"PORT": config("DATABASE_PORT"),
"NAME": config("TEST_POSTGRES_NAME"),
"USER": config("POSTGRES_USER"),
"PASSWORD": config("POSTGRES_PASSWORD"),
"HOST": config("POSTGRES_HOST"),
"PORT": config("POSTGRES_PORT"),
}
}

Expand Down
6 changes: 3 additions & 3 deletions docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ services:
depends_on:
elastic:
condition: service_started
database:
postgres:
condition: service_started
rabbitmq:
condition: service_started
Expand All @@ -33,7 +33,7 @@ services:
smtp4dev:
condition: service_started

database:
postgres:
image: postgres:12
container_name: academy-master-postgres
restart: on-failure
Expand All @@ -45,7 +45,7 @@ services:
- postgres-data:/var/lib/postgresql/data
- ./docker/scripts/pg-entrypoint.sh:/docker-entrypoint-initdb.d/entrypoint.sh
environment:
- POSTGRES_MULTIPLE_DATABASES="${DATABASE_NAME},${TEST_DATABASE_NAME}"
- POSTGRES_MULTIPLE_DATABASES="${POSTGRES_NAME},${TEST_POSTGRES_NAME}"
networks:
- main

Expand Down
6 changes: 3 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ services:
depends_on:
elastic:
condition: service_started
database:
postgres:
condition: service_started
rabbitmq:
condition: service_started
Expand All @@ -34,7 +34,7 @@ services:
smtp4dev:
condition: service_started

database:
postgres:
image: postgres:12
container_name: academy-master-postgres
restart: on-failure
Expand All @@ -48,7 +48,7 @@ services:
networks:
- main
environment:
- POSTGRES_MULTIPLE_DATABASES="${DATABASE_NAME},${TEST_DATABASE_NAME}"
- POSTGRES_MULTIPLE_DATABASES="${POSTGRES_NAME},${TEST_POSTGRES_NAME}"

rabbitmq:
image: rabbitmq:3.10-management-alpine
Expand Down
2 changes: 1 addition & 1 deletion kubernetes/backend.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ spec:
value: "config.settings.local"
- name: ENVIRONMENT
value: "LOCAL"
- name: DATABASE_PORT
- name: POSTGRES_PORT
value: "5432"

volumes:
Expand Down
10 changes: 4 additions & 6 deletions kubernetes/postgres.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,13 @@ spec:

env:
- name: POSTGRES_USER
value: "$(DATABASE_USER)"
value: "$(POSTGRES_USER)"
- name: POSTGRES_PASSWORD
value: "$(DATABASE_PASSWORD)"
value: "$(POSTGRES_PASSWORD)"
- name: POSTGRES_DB
value: "$(DATABASE_NAME)"
- name: DATABASE_HOST
value: "postgres"
value: "$(POSTGRES_NAME)"
- name: POSTGRES_MULTIPLE_DATABASES
value: "$(DATABASE_NAME),$(DATABASE_TEST_NAME)"
value: "$(POSTGRES_NAME),$(POSTGRES_TEST_NAME)"

volumeMounts:
- mountPath: /var/lib/postgresql/data
Expand Down

0 comments on commit 2d81ccf

Please sign in to comment.