Hi all,
# spicedb
t
Hi all, I am using the authzed/spicedb image in my docker compose setup to run some tests for my component.
Copy code
yaml
spicedb:
        image: "authzed/spicedb"
        command: "serve"
        restart: "always"
        ports:
        - "8080:8080"
        - "9090:9090"
        - "50051:50051"
        environment:
        - "SPICE_DB_HOST_CONF=spicedb"
        - "SPICEDB_GRPC_PRESHARED_KEY=foobar"
        - "SPICEDB_DATASTORE_ENGINE=postgres"
        - "SPICEDB_DATASTORE_CONN_URI=postgres://postgres:postgrespw@postgres-db-auth-api:5432/spicedb?sslmode=disable"
        depends_on:
        - database
Is is possible to run the
migrate head
command before running
serve
? I tried giving the command as "migrate head && serve" but then it just migrates and exits without starting the service. I tried chaining commands using
sh -c "migrate head && serve
but it seems like bash or shell is not recognized by the image. Is there a way to do this?
v
Please have a look at our docker compose examples: https://github.com/authzed/examples/blob/main/datastores/postgres.yml You could do it in one go, but it's simpler to use another job that depends on the database and runs migrate head for you.
t
Thanks for this, I first went with this approach. The issue is I pass the
--abort-on-container-exit
flag for docker compose as I am running this in a CI/CD pipeline. Because of that, when the migration finishes the container exits and the whole process stops. That's why I'm looking for a way to do it in one go. Is there an example for that use case?
v
if its for CI, you could instead use the SpiceDB
serve-testing
mode which does not need of a datastore
if you really need to do this with postgres, you can't do this with the default SpiceDB images because they don't have a shell. Instead you want to use the
-debug
images (e.g. spicedb:latest-debug).
t
Oh okay, got it. Will try both and go with the best option. Thank you so much for the help
28 Views