Updating postgres variables

This commit is contained in:
farhan 2025-01-24 21:30:25 +00:00
parent c6ba6fdfde
commit d3efb1c8dd
2 changed files with 15 additions and 8 deletions

View File

@ -1,6 +1,11 @@
services:
fedilogue:
build: fedilogger/
build: fedilogue/
environment:
POSTGRES_USER: $POSTGRES_USER
POSTGRES_PASSWORD: $POSTGRES_PASSWORD
POSTGRES_HOSTNAME: $POSTGRES_HOSTNAME
POSTGRES_DB: $POSTGRES_DB
depends_on:
- db
ports:
@ -10,16 +15,17 @@ services:
ports:
- "127.0.0.1:6431:6432"
environment:
POSTGRES_USER: $PGUSER
POSTGRES_PASSWORD: $PGPASS
POSTGRES_DB: $PGDATABASE
POSTGRES_USER: $POSTGRES_USER
POSTGRES_PASSWORD: $POSTGRES_PASSWORD
POSTGRES_HOSTNAME: $POSTGRES_HOSTNAME
POSTGRES_DB: $POSTGRES_DB
depends_on:
- db
db:
image: postgres:alpine
environment:
POSTGRES_USER: $PGUSER
POSTGRES_PASSWORD: $PGPASS
POSTGRES_DB: $PGDATABASE
POSTGRES_USER: $POSTGRES_USER
POSTGRES_PASSWORD: $POSTGRES_PASSWORD
POSTGRES_DB: $POSTGRES_DB
volumes:
- ./postgres-data:/var/lib/postgresql

View File

@ -11,7 +11,8 @@ var pool *pgxpool.Pool
func getDbPool() *pgxpool.Pool {
// Setup Database
pool, err := pgxpool.Connect(context.Background(), os.Getenv("DATABASE_URL"))
dburl := "postgres://" + os.Getenv("POSTGRES_USER") + ":" +u os.Getenv("POSTGRES_PASSWORD") + "@" + os.Getenv("POSTGRES_HOSTNAME") + "/" + os.Getenv("POSTGRES_DB")
pool, err := pgxpool.Connect(context.Background(), dburl)
if err != nil {
log.Fatal("Unable to connect to database:", err)
}