Skip to content

Commit

Permalink
Update database configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
fjpacheco committed Mar 3, 2024
1 parent 1953dfa commit 2929af4
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 52 deletions.
4 changes: 2 additions & 2 deletions .env.dist
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ POSTGRES_USER=
POSTGRES_PASSWORD=
POSTGRES_HOST=
POSTGRES_PORT=
USERS_DB=
USERS_SCHEMA=
POSTGRES_DB=
POSTGRES_SCHEMA=

# Google
GOOGLE_CLIENT_ID=
Expand Down
2 changes: 1 addition & 1 deletion app/models/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

class User(Base):
__tablename__ = "users"
__table_args__ = {'schema': environ.get("USERS_SCHEMA", "dev")}
__table_args__ = {'schema': environ.get("POSTGRES_SCHEMA", "users_service")}
id = Column(Integer, primary_key=True, index=True, autoincrement=True)
name = Column(String, nullable=True)
email = Column(String, nullable=False)
Expand Down
2 changes: 1 addition & 1 deletion app/repository/Users.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
class UsersRepository:
db_url = environ.get("DATABASE_URL", engine.URL.create(
"postgres",
database=environ.get("USERS_DB", "users"),
database=environ.get("POSTGRES_DB", "dev"),
username=environ.get("POSTGRES_USER", "user"),
password=environ.get("POSTGRES_PASSWORD", "1234"),
host=environ.get("POSTGRES_HOST", "sql"),
Expand Down
96 changes: 48 additions & 48 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,48 +1,48 @@
version: '3.9'

services:

python:
build:
context: .
container_name: users-app
env_file:
- .env
ports:
- "8080:8080"
depends_on:
sql:
condition: service_healthy
volumes:
- ./app:/app
tty: true

sql:
build:
context: ./app/docker
dockerfile: Dockerfile
env_file:
- .env
ports:
- "5432:5432"
volumes:
- ./app/docker:/docker-entrypoint-initdb.d
healthcheck:
test:
[
"CMD",
"pg_isready",
"-h",
"localhost",
"-p",
"5432",
"-q",
"-U",
"${POSTGRES_USER}",
"-d",
"${POSTGRES_DB}"
]
interval: 5s
timeout: 3s
retries: 10
start_period: 50s
version: '3.9'

services:

python:
build:
context: .
container_name: users-app
env_file:
- .env
ports:
- "8080:8080"
depends_on:
sql:
condition: service_healthy
volumes:
- ./app:/app
tty: true

sql:
build:
context: ./app/docker
dockerfile: Dockerfile
env_file:
- .env
ports:
- "5432:5432"
volumes:
- ./app/docker:/docker-entrypoint-initdb.d
healthcheck:
test:
[
"CMD",
"pg_isready",
"-h",
"localhost",
"-p",
"5432",
"-q",
"-U",
"${POSTGRES_USER}",
"-d",
"${POSTGRES_DB}"
]
interval: 5s
timeout: 3s
retries: 10
start_period: 50s

0 comments on commit 2929af4

Please sign in to comment.