Skip to content

Commit

Permalink
Revisited env variables and removed the unnecessary ones
Browse files Browse the repository at this point in the history
  • Loading branch information
lhbelfanti committed Jun 3, 2024
1 parent 2997d93 commit 4b74fe6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,17 @@ erDiagram
INTEGER user_id FK
BOOLEAN adverse_behavior
}
```
```

#### Necessary files to start the database

To connect to the database we need to define a `.env` file in the root of the project. It should contain the following environment variables

```
DB_PORT=<Database port>
DB_NAME=<Database name>
DB_USER=<Database username>
DB_PASS=<Database password>
```

Replace the `< ... >` by the correct value. For example: `DB_NAME=<Database name>` --> `DB_NAME=ahbcc`.
3 changes: 1 addition & 2 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ func databaseURL() string {
dbUser := os.Getenv("POSTGRES_DB_USER")
dbPass := os.Getenv("POSTGRES_DB_PASS")
dbName := os.Getenv("POSTGRES_DB_NAME")
dbHost := os.Getenv("POSTGRES_DB_HOST")
dbPort := os.Getenv("POSTGRES_DB_PORT")

return fmt.Sprintf("user=%s password=%s dbname=%s host=%s port=%s sslmode=disable", dbUser, dbPass, dbName, dbHost, dbPort)
return fmt.Sprintf("user=%s password=%s dbname=%s host=postgres_db port=%s sslmode=disable", dbUser, dbPass, dbName, dbPort)
}
3 changes: 1 addition & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ services:
build: .
container_name: app
environment:
POSTGRES_DB_HOST: ${DB_HOST}
POSTGRES_DB_PORT: ${DB_PORT}
POSTGRES_DB_NAME: ${DB_NAME}
POSTGRES_DB_USER: ${DB_USER}
Expand All @@ -27,7 +26,7 @@ services:
POSTGRES_USER: ${DB_USER}
POSTGRES_PASSWORD: ${DB_PASS}
ports:
- '1234:5432'
- '1234:${DB_PORT}'
volumes:
- database:/var/lib/postgresql/data
networks:
Expand Down

0 comments on commit 4b74fe6

Please # to comment.