Docker Image Gotchas and Help Request

Today I noticed that there are some gotchas in the Fauna Docker image.

  1. The secret key that is supplied with the image should be use to create a database and a key to use to create everything else. You can’t use it to just plug into your regular code.
  2. CreateRole doesn’t behave the same as production. The following code doesn’t work locally for some reason but it does in production Fauna. Create Role in Fauna · GitHub

Any suggestions for what I’m doing wrong would be gladly welcomed.

The secret key that is supplied with the image should be use to create a database and a key to use to create everything else. You can’t use it to just plug into your regular code.

When using Fauna Dev, secret is, indeed, the default secret used to access the top-level database running within the Docker image. That secret gives you admin access, so you can create whatever collections, documents, indexes, functions, roles, access providers, etc., that you need. It is not limited in any way.

When you tried to “plug it into your regular code”, what issues did you encounter?

CreateRole doesn’t behave the same as production. The following code doesn’t work locally for some reason but it does in production Fauna. Create Role in Fauna · GitHub

What different behaviour did you see? The Role that you linked to doesn’t specify any membership, so it doesn’t automatically apply to any identity documents contained in your database, but perhaps you are assigning that role to a UDF?

More details would be required to help you further.

The code I linked here works in production Fauna but I receive a BadRequest error in the Docker version. I’ve noticed for any role I try to create that has a function resource that I try to add call to fails.

Also, the code I was initially testing specified a membership resource. The code I linked above was most created from the code here

The code I linked here works in production Fauna

The BadRequest error might be happening if the create_user UDF does not exist in your Fauna Dev database. Can you verify whether it exists?

I thought the same thing so I moved creating the roles until after the collections, indexes, and functions are created and it still happened.

Also, I can’t seem to get the data to persist. Below is my docker-compose file.

version: '3.7'

services:
  web:
    restart: always
    build:
      dockerfile: Dockerfile
      context: .
    expose:
      - "8010"
    ports:
      - 8010:8888
    volumes:
      - ./:/code/
    env_file: .env
    working_dir: /code/
    command: /root/.cache/pypoetry/virtualenvs/pfunk-MATOk_fk-py3.7/bin/jupyter notebook --port=8888 --ip=0.0.0.0 --allow-root

  fauna:
    restart: always
    image: fauna/faunadb
    ports:
      - 8443:8443
      - 8444:8444
      - 8445:8445
      - 8084:8084
    volumes:
      - ./logs:/var/log/faunadb
      - ./docker-fauna.yml:/docker-fauna.yml
      - pfunk-fauna-data:/var/lib/faunadb
    command: --init --config /docker-fauna.yml

volumes:
  pfunk-fauna-data:
    external: true

I appreciate your help I’m trying to finish the unit test for my Fauna library Pfunk. I figure this might help in figuring out what I’m doing wrong.

I figured out the main problem, I forgot I removed a function from the database locally but I didn’t in production. That was causing the role to fail.

I still have not figured out how to get the data to persist.

After you run docker-compose up and execute a few queries, does the pfunk-fauna-data volume appear to have anything in it?

Can you show us the contents of docker-fauna.yml?

It does seem to have data in it but the keys are never the same. Here are the contents of the docker-fauna.yml file but I’ve since stop using it. pfunk/docker-fauna.yml at master · capless/pfunk · GitHub

I figured it out. The data persists now.

1 Like