Skip to content

Instantly share code, notes, and snippets.

@unlocomqx
Created January 23, 2021 10:59
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save unlocomqx/9d7a8510ab857d660edb309eff2b9e1a to your computer and use it in GitHub Desktop.
Save unlocomqx/9d7a8510ab857d660edb309eff2b9e1a to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
docker pull fauna/faunadb
docker container stop faunadb || true && docker container rm faunadb || true
docker run --name faunadb -d \
--health-cmd="faunadb-admin status" --health-interval=2s \
-p 8443:8443 \
-p 8084:8084 \
fauna/faunadb
./docker/wait-for-healthy.sh faunadb 30
echo n | fauna add-endpoint http://localhost:8443/ --alias localhost --key secret
fauna create-database db_name --endpoint=localhost
OUTPUT=$(fauna create-key db_name --endpoint=localhost)
echo "${OUTPUT}"
[[ "${OUTPUT}" =~ secret\:[[:space:]]([A-Za-z0-9_\-]+) ]]
SECRET="${BASH_REMATCH[1]}"
echo "Secret is ${SECRET}"
curl -u ${SECRET}: http://localhost:8084/import --data-binary "@path/to/schema.graphql"
echo "FAUNADB_SECRET=${SECRET}
GRAPHQL_ENDPOINT=http://localhost:8084/graphql" > ".env.test";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment