Hey all,
# spicedb
k
Hey all, I am trying to run spicedb and zed command line in docker. I want to be able to run 3 commands with zed to set the context write the schema and add a relationship within my docker compose
Copy code
zed:
    image: authzed/zed:latest-debug
    environment:
      - ZED_KEYRING_PASSWORD=somerandomkeyhere
    command: |
      context set dev spicedb:50051 somerandomkeyhere \
      schema write ./zed/schema.zed \
      schema read \
    volumes:
      - ./spicedb/schema.zed:/zed/schema.zed
    depends_on:
      - "spicedb"
The zed container doesnt like the way the commands are being formatted here and cant seem to figure out how to successfully parse them into the container to run in sequence. Can anyone help ?
v
I don't think that's correct, I've certainly have never seen such an approach, the zed command will interpret that as a single command, and thus fail to parse it. If you want to do that, I suggest looking at the various options to run multiple commands in docker: https://www.baeldung.com/linux/docker-cmd-multiple-commands With that being said, you don't have to do that in 3 commands. SpiceDB supports loading schemas and relationship in a single operation with
zed import
, using the playground YAML format (play.authzed.com). It can load it from a URL or from the local filesystem. You also don't need to set the context, you can pass the context parameters as parameters to
zed import
Copy code
Usage:
  zed import <url> [flags]

Examples:

    From a gist:
        zed import https://gist.github.com/ecordell/8e3b613a677e3c844742cf24421c08b6

    From a playground link:
        zed import https://play.authzed.com/s/iksdFvCtvnkR/schema

    From pastebin:
        zed import https://pastebin.com/8qU45rVK

    From a devtools instance:
        zed import https://localhost:8443/download

    From a local file (with prefix):
        zed import file:///Users/zed/Downloads/authzed-x7izWU8_2Gw3.yaml

    From a local file (no prefix):
        zed import authzed-x7izWU8_2Gw3.yaml

    Only schema:
        zed import --relationships=false file:///Users/zed/Downloads/authzed-x7izWU8_2Gw3.yaml

    Only relationships:
        zed import --schema=false file:///Users/zed/Downloads/authzed-x7izWU8_2Gw3.yaml

    With schema definition prefix:
        zed import --schema-definition-prefix=mypermsystem file:///Users/zed/Downloads/authzed-x7izWU8_2Gw3.yaml
Copy code
Flags:
      --batch-size int                    import batch size (default 1000)
  -h, --help                              help for import
      --relationships                     import relationships (default true)
      --schema                            import schema (default true)
      --schema-definition-prefix string   prefix to add to the schema's definition(s) before importing
      --workers int                       number of concurrent batching workers (default 1)

Global Flags:
      --certificate-path string     path to certificate authority used to verify secure connections
      --endpoint string             spicedb gRPC API endpoint
      --hostname-override string    override the hostname used in the connection to the endpoint
      --insecure                    connect over a plaintext connection
      --log-format string           format of logs ("auto", "console", "json") (default "auto")
      --log-level string            verbosity of logging ("trace", "debug", "info", "warn", "error") (default "info")
      --no-verify-ca                do not attempt to verify the server's certificate chain and host name
      --permissions-system string   permissions system to query
      --request-id string           optional id to send along with SpiceDB requests for tracing
      --skip-version-check          if true, no version check is performed against the server
      --token string                token used to authenticate to SpiceDB
y
@KKING that's not how docker commands work - you're basically telling it to do:
zed context set dev <stuff> schema write
to be able to run multiple commands like this i'm pretty sure you'd need a shell script, and you won't be able to do that if the entrypoint is
zed
which would point to creating a bespoke container that downloads and runs the
zed
cli but is otherwise like an alpine container or something that runs a shell
alternatively, you could create a whole set of
zed
container declarations in docker-compose and chain them using
depends_on
(though that may end up having race conditions)
95 Views