You can pass `migrate head` as args to
# spicedb
b
You can pass
migrate head
as args to the container when starting it, it'll exit after finishing the migration
n
I have this Dockerfile, how should I pass it as args
Copy code
# Use a base image
FROM authzed/spicedb:latest

# Set environment variables for PostgreSQL connection
ENV SPICEDB_DATASTORE_ENGINE=postgres
ENV SPICEDB_DATASTORE_CONN_URI=postgres://postgres:password@localhost:5432/spicedb?sslmode=disable

# Run migration command
RUN spicedb migrate head

# Start SpiceDB service
CMD ["serve", "--grpc-preshared-key", "mykey"]
b
RUN
is a build thing, I'm not sure you want to init your database when building the image? I was talking about running the container, something like this:
docker run authzed/spicedb:latest -e "SPICEDB_DATASTORE_ENGINE=..." -e "SPICEDB_DATASTORE_CONN_URI=..." migrate head
v
is this for development purposes? Why not using
serve-testing
?
n
We are doing kind of POC
v
and you are not deploying to kube?
n
Nope! simple dev-ite deployent on a single machine via Jenkins pipline
Okay, btw for a normal setup, migrate is a one-time setup, right? Like, once we have the proper schema in PostgreSQL, we can connect to it from SpiceDB. Can this be achieved without the spicedb migrate command?
b
Yes, you also need to run it if you update SpiceDB and there are changes to the datastore that need applying
v
also do note that some migrations are multi-phase. That's the reason we recommend using the spicedb operator, because it knows about all the migrations and how they need to be executed
n
Okay, will check the operator approach.
v
the operator only runs on kube, so I don't think it would work for you
n
Oh! then I will see how I can run the migrate command
v
yeah If you are running in something that only runs containers, I can only think deploying the migrate command as anoter container, or doing an adhoc one-off execution
y
@naveen_kr unless this is purely for "how does this work?" validation, I wouldn't recommend running spicedb without kubernetes in a deployed environment
n
@yetitwo For now it is for POC only, but sure will look into kubernetes depolyment