This directory shows a very simple way of building a docker container to apply your database migrations. This is not intended to be prod ready (passing environments etc) but just to get you started.
With PowerShell 7, pwsh -File examples/docker/build-and-run.ps1 starts the
example and tears it down after a successful run. Run this command from the
repository root; the script selects the example directory automatically.
Simply docker-compose up to:
- start a sql database server
- run the
gratemigration against the server with script locate indbfolder and store the backup script inoutput
- You wouldn't normally do db migrations using compose, this is just an example.
You can easily extend the support command using an entrypoint mount in Docker. You have 2 options below
Option 1: Adding the additional flags when invoking the container (for example: warnandignoreononetimescriptchanges and verbosity)
docker run --rm -v $(pwd)/db:/db -v $(pwd)/output:/output erikbra/grate:latest --warnandignoreononetimescriptchanges=true --verbosity=TraceOption 2: Using a custom entrypoint script in a restricted environment (for example my-entrypoint.sh)
This small runtime launcher remains in POSIX shell because the application container does not include PowerShell. Host-side scripts use PowerShell 7.
chmod +x my-entrypoint.sh
docker run --rm -v $(pwd)/db:/db -v $(pwd)/output:/output -v $(pwd)/my-entrypoint.sh:/app/entrypoint.sh erikbra/grate:latest