Skip to content

Commit

Permalink
chore: fix docker compose postgresql
Browse files Browse the repository at this point in the history
  • Loading branch information
tructn committed Jun 2, 2024
1 parent abdb76c commit c2684c6
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ COPY . ./

RUN go build -v -o ./app

CMD ["./app/main"]
CMD ["./app"]
1 change: 1 addition & 0 deletions db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ func NewDatabase() *gorm.DB {
&domain.AdditionalCost{},
&domain.SportCenter{},
)

db = dbCtx.Debug()
})

Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ services:
ports:
- "5432:5432"
volumes:
- ./scripts/init.sql:/docker-entrypoint-initdb.d/init.sql
- pgdata:/var/lib/postgresql/data

volumes:
Expand Down
7 changes: 7 additions & 0 deletions scripts/init.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
IF NOT EXISTS (
SELECT
FROM pg_catalog.pg_database
WHERE datname = 'racket'
) THEN
PERFORM dblink_exec('dbname=postgres', 'CREATE DATABASE racket');
END IF;

0 comments on commit c2684c6

Please sign in to comment.