Skip to content

Commit

Permalink
feat: base compose for postgres with database bootstrap
Browse files Browse the repository at this point in the history
  • Loading branch information
logan-bobo committed Jun 10, 2024
1 parent 2727087 commit 05c725c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@ test:
docker run -t "url-short:test"
.PHONY:test

migrate:
goose postgres "postgres://url-short:password@localhost:5002/url-short" up
7 changes: 7 additions & 0 deletions bin/local-init.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
CREATE ROLE url_short WITH
CREATEDB
LOGIN
PASSWORD 'password';

CREATE DATABASE url_short WITH
OWNER url_short;
9 changes: 8 additions & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ services:
- .env
ports:
- 5001:8080
healthcheck:
test: wget --no-verbose --tries=1 --spider http://localhost/api/v1/healthz || exit 1
interval: 2s
retries: 5
timeout: 10s
depends_on:
db:
condition: service_healthy
Expand All @@ -15,10 +20,12 @@ services:
restart: always
environment:
PGDATA: /var/lib/postgresql/data/pgdata
PGUSER: url-short
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
user: postgres
volumes:
- pgdata:/var/lib/postgresql/data
- ./bin/local-init.sql:/docker-entrypoint-initdb.d/local-init.sql
ports:
- 5002:5432
healthcheck:
Expand Down

0 comments on commit 05c725c

Please sign in to comment.