diff --git a/castor/service/README.md b/castor/service/README.md index 131373f86f..12117290ed 100644 --- a/castor/service/README.md +++ b/castor/service/README.md @@ -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 +``` diff --git a/castor/service/api-server/src/main/scala/io/iohk/atala/castor/apiserver/grpc/GrpcServer.scala b/castor/service/api-server/src/main/scala/io/iohk/atala/castor/apiserver/grpc/GrpcServer.scala index 96bc5a5e7f..d8f16b744a 100644 --- a/castor/service/api-server/src/main/scala/io/iohk/atala/castor/apiserver/grpc/GrpcServer.scala +++ b/castor/service/api-server/src/main/scala/io/iohk/atala/castor/apiserver/grpc/GrpcServer.scala @@ -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)) diff --git a/castor/service/docker/docker-compose-local.yaml b/castor/service/docker/docker-compose-local.yaml new file mode 100644 index 0000000000..98ae0a927d --- /dev/null +++ b/castor/service/docker/docker-compose-local.yaml @@ -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: diff --git a/castor/service/migrations/sql/V1__init_tables.sql b/castor/service/migrations/sql/V1__init_tables.sql new file mode 100644 index 0000000000..6f727ec9fe --- /dev/null +++ b/castor/service/migrations/sql/V1__init_tables.sql @@ -0,0 +1,4 @@ +CREATE TABLE public.published_did_operations( + "foo" VARCHAR(100) NOT NULL, + "bar" VARCHAR(100) NOT NULL +);