I'm attempting to use evolve migration for my db, in docker-compose, enabling a local version of production for development. The idea is for each time I start my docker-compose, the changes to my db tables will be migrated. I started using docker-entrypoint-initdb.d, but this requires a full restart of the db to enact the table changes, which would lead to a loss of all the db data in my volume, which I want to have persistent data.
In my docker-compose file I have the following, migrate indicates the migration, the out commented line in the database, is what I used before attempting migration:
version: '3.4'
name: dockertest
services:
dockertestapi:
image: ${DOCKER_REGISTRY-}dockertestapi
build:
context: ../
dockerfile: DockerTestApi/Dockerfile
container_name: DockerTest-service
environment:
- ASPNETCORE_ENVIRONMENT=LocalDocker
ports:
- 5237:80
networks:
- backend
depends_on:
rabbitmq:
condition: service_healthy
database:
condition: service_healthy
rabbitmq:
image: rabbitmq:3-management
hostname: rabbitmq
container_name: rabbitmq
ports:
- 15672:15672
- 5672:5672
networks:
- backend
volumes:
- ./rabbitmq/rabbitmq.config:/etc/rabbitmq/rabbitmq.config
- ./rabbitmq/definitions.json:/etc/rabbitmq/definitions.json
healthcheck:
test: rabbitmq-diagnostics check_port_connectivity
interval: 5s
timeout: 30s
retries: 3
database:
image: mariadb:10.9
container_name: database
ports:
- "33061:3306"
networks:
- backend
volumes:
#- ../Migrations:/docker-entrypoint-initdb.d
- ../../dockertest-data:/var/lib/mysql
environment:
MYSQL_ROOT_USER: root
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: dockertestdb
migrate:
image: <base_url>/backend/evolve-bin:master
command: evolve migrate mariadb -c "Server=localhost;Port=3306;Database=dockertestdb;Uid=root;Pwd=root;" -l "/tmp/migrations"
depends_on:
- database
volumes:
- ../Migrations:/tmp/migrations
volumes:
dockertest-data:
networks:
backend:
I have removed the url and replaced it with base_url, for the purpose of this question. Everything is working and spinning up nicely in docker, except the migrate, which gives the following error:
Unrecognized command or argument 'mariadb'
Note: I need to use mariadb and evolve for the migration to replicate what is used in production.