Now that we have established a mechanism to securely access the db service in our stack, the final configuration task we need to perform is to add a service that will run database migrations. This is similar to the collectstatic service we created earlier, in that it needs to be a "one-shot" task that only executes whenever we create the stack or whenever we deploy a new version of the application:
version: '3.6'networks: ...volumes: ...secrets: ...services: app: ... migrate: image: 385605022855.dkr.ecr.us-east-1.amazonaws.com/docker-in-aws/todobackend:${APP_VERSION} networks: - net environment: DJANGO_SETTINGS_MODULE: todobackend.settings_release MYSQL_HOST: db MYSQL_USER: todo secrets: - source: todobackend_mysql_password ...