Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to use run and migrate command in single docker container #1538

Open
1 task done
PatrickMunsey opened this issue Apr 16, 2024 · 0 comments
Open
1 task done
Labels
enhancement New feature or request

Comments

@PatrickMunsey
Copy link

Checklist

Describe the problem you'd like to have solved

It would be nice to be able to have a command that would migrate then run the docker container so that a separate container isn't needed purely for migration.

I have multiple docker-compose.yml files that utilise the extends property however this can't be used with containers in other files that use the depend_on: property. The openfga container depend_on the migrate container in the setup guides.

Having a single migrate container exited also changes the status in docker compose deployment to yellow instead of green which means other docker deployments aren't triggered correctly when chained together. e.g. status = Running (1/2)

Describe the ideal solution

It would be so much cleaner and allow for better docker file structuring if we had the optional ability to run migrations before the run command in the main openfga container.

This could be done by adding a new command or testing a boolean env var

run-with-migration = migrate && run
or
RUN_MIGRATIONS=true

  openfga:
    depends_on:
      migrate:
        condition: service_completed_successfully
    image: openfga/openfga:latest
    container_name: openfga
    environment:
      - OPENFGA_DATASTORE_ENGINE=postgres
      - OPENFGA_DATASTORE_URI=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_DB}:5432/openfga?sslmode=disable
      - OPENFGA_LOG_FORMAT=json
      - RUN_MIGRATIONS=true
    command: run-with-migration
    networks:
      - openfga-network
    ports:
      # Needed for the http server
      - '8080:8080'
      # Needed for the grpc server (if used)
      - '8081:8081'
      # Needed for the playground (Do not enable in prod!)
      - '3000:3000'

Alternatives and current workarounds

I tried many combinations for running two command in the container including below however they did not work

    command:
      - migrate
      - run
    command: >
      bash -c "migrate
      && run"

Additional context

No response

@PatrickMunsey PatrickMunsey added the enhancement New feature or request label Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant