Skip to content

Commit

Permalink
feat(castor): add local docker-compose db and migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
Pat Losoponkul committed Sep 13, 2022
1 parent e4bc0d0 commit 2d5a447
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 2 deletions.
11 changes: 10 additions & 1 deletion castor/service/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
# Castor BB
# Castor BB service

## Quickstart

__Running Castor locally for development__

```bash
docker-compose -f docker/docker-compose-loca.yaml up -d
sbt api-server/run
```
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ object GrpcServer {
def start(port: Int, services: Seq[ServerServiceDefinition]): Task[Unit] = {
val managedServer = ZIO.acquireRelease(
for {
_ <- ZIO.logInfo(s"staring grpc server on port $port")
_ <- ZIO.logInfo(s"starting grpc server on port $port")
server <- ZIO.attempt {
val builder = ServerBuilder.forPort(port)
services.foreach(s => builder.addService(s))
Expand Down
34 changes: 34 additions & 0 deletions castor/service/docker/docker-compose-local.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
version: "3.9"

services:
db:
image: postgres:13
restart: always
environment:
POSTGRES_DB: castor
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
volumes:
- pg_data_castor_db:/var/lib/postgresql/data

# delay to ensure DB is up before apply migrations
db_init_delay:
image: alpine:3
command: sleep 5
depends_on:
db:
condition: service_started

db_init:
image: flyway/flyway:9.3.0-alpine
volumes:
- $PWD/migrations/sql:/flyway/sql
command: -url=jdbc:postgresql://db:5432/castor?user=postgres&password=postgres migrate
depends_on:
db_init_delay:
condition: service_completed_successfully

volumes:
pg_data_castor_db:
4 changes: 4 additions & 0 deletions castor/service/migrations/sql/V1__init_tables.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
CREATE TABLE public.published_did_operations(
"foo" VARCHAR(100) NOT NULL,
"bar" VARCHAR(100) NOT NULL
);

0 comments on commit 2d5a447

Please sign in to comment.