question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Question] How to handle/init/persist migrations in Docker Image

See original GitHub issue

If someone is using Hasura (cli-migrations) docker image, what is the recommended way to init migrations and share metadata and migrations with host?

I could not find anything related to docker management in the documentation. All information is about when running docker locally.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
GavinRay97commented, Apr 13, 2020

The workflow you can use with Docker/Kubernetes and the .cli-migrations image is to make a custom Dockerfile where you copy the migrations folder from the host to the container and let it apply them.

If you are using the V2 migrations format:

FROM hasura/graphql-engine:v1.2.0-beta.3.cli-migrations-v2
COPY migrations /hasura-migrations
COPY metadata /hasura-metadata

If you are using the V1 format:

FROM hasura/graphql-engine:v1.2.0-beta.3.cli-migrations
COPY migrations /hasura-migrations

Assuming that your migrations/metadata are stored in those directories. You can also customize the location from which Hasura reads migrations/metadata by setting environment variables:

HASURA_GRAPHQL_MIGRATIONS_DIR=/custom-path-for-migrations
# V2 Only
HASURA_GRAPHQL_METADATA_DIR=/custom-path-for-metadata

The workflow looks like this:

  • Dockerfile copies metadata/migrations automatically
  • .cli-migrations image applies them on start
  • Use the Hasura CLI to make changes to your schema/metadata
    • They will be applied now on your instance but will also have the migrations generated for them
    • So creating a fresh container instance will replicate the same state as your current one

Do you think the documentation would be improved by putting more information about the specifics of the entire workflow, outside of what pertains to CI/CD here?

https://hasura.io/docs/1.0/graphql/manual/migrations/auto-apply-migrations.html#

0reactions
mubaidrcommented, Apr 17, 2020

Got it running. I need to use 0.0.0.0 to make sure it is available outside the container. (localhost is not)

hasura-cli console --address 0.0.0.0

Thanks @GavinRay97

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do you perform Django database migrations when using ...
The first time I run Django's manage.py migrate, using the command sudo docker-compose run web python manage.py migrate , it works as expected....
Read more >
Docker frequently asked questions (FAQ)
Most frequently asked questions. ... This container can be transferred to any Docker-enabled machine. The container can be executed there with the guarantee ......
Read more >
Prisma Migrate: Deploy Migration with Docker - notiz.dev
One question about the guide Dockerizing a NestJS app with Prisma and PostgreSQL was asked frequently: "How to run database migrations in ...
Read more >
Migrating to Docker: How to Plan a Migration and ... - Codefresh
And the most important question, that has to be answered before departing on ... Whether your product is ready to run as a...
Read more >
Migrate your Applications to Containers at Scale - Amazon AWS
Modernize with AWS App2Container · Packages the application artifact and identified dependencies into container images · Configures the network ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found