- Più recenti
- Maggior numero di voti
- Maggior numero di commenti
While it is technically possible to install sshd in your image so you can SSH into your task, that's not a terribly practical approach. It would be helpful to understand your scenario in a little bit more detail. What's driving doing the DB migrations? Are you deploying updated code? If that's the case, consider automating the DB migration as part of your deployment (e.g. validate the state of the DB when you're task starts up and if not what you expect, do the migration).
/Mats
Hi,
Were you able to solve this issue? I am also facing the same sort of issue. I have an application deployed on ECS (fargate) and I want to run migrations.
You have 2 options
1 - do them as part of CICD pipeline in CodeBuild https://aws.amazon.com/blogs/database/building-a-cross-account-continuous-delivery-pipeline-for-database-migrations/
2 - set up fargate task and execute the migration there. The task can be invoked after the CloudWatch event
https://docs.aws.amazon.com/AmazonECS/latest/developerguide/scheduled_tasks.html
https://aws.amazon.com/about-aws/whats-new/2018/08/aws-fargate-now-supports-time-and-event-based-task-scheduling/
You have 2 options
1 - do them as part of CICD pipeline in CodeBuild https://aws.amazon.com/blogs/database/building-a-cross-account-continuous-delivery-pipeline-for-database-migrations/
2 - set up fargate task and execute the migration there. The task can be invoked after the CloudWatch event
https://docs.aws.amazon.com/AmazonECS/latest/developerguide/scheduled_tasks.html
https://aws.amazon.com/about-aws/whats-new/2018/08/aws-fargate-now-supports-time-and-event-based-task-scheduling/
You can do it in your Dockerfile as part of your ENTRYPOINT or CMD. In Rails app you would normally run the migrations before you start the server by running
bundle exec rails db:migrate
bundle exec rails server -p 3000
@Mats ideally that would be good, but the deployment process of an ECS task doesn't seem to provide a mechanism to execute one-off commands as part of the process (in the same way that you can use initContainers in Kubernetes deployments or lifecycle hooks in Helm charts).
@jedrek that's a non-ideal workaround as 1) you'd be running migrations (eg: start db connections and execute queries at least to check the migration version) every time a container starts (not just a deployment). If I have a service running 100 copies, migrations would be execute at least 100 times during the deploy process with potential race conditions if multiple containers can start around the same time. 2) migrations would also run whenever containers get moved around container instances, when instances get removed/readded and so on.
would be great if the ECS service would allow for something like init containers so that a check (in the form of a command running inside a container) could be performed before a deployment starts.
Contenuto pertinente
- AWS UFFICIALEAggiornata un anno fa
- AWS UFFICIALEAggiornata 3 mesi fa
- AWS UFFICIALEAggiornata 9 mesi fa