问题
I'm new to Docker, and am trying to understand the workflow for updating my app in AWS, after it's live. For now, the rails app and MySQL database are both on the same EC2 instance. Here's what I'm doing to get the app live:
I have a dockerfile a docker-compose.yml file that define the services. The rails application source is linked to the app container with a bind mount in docker-compose.yml:
app:
...
volumes:
- $PWD:/zhxword
When I'm ready to deploy, I run:
docker-machine create --driver amazonec2 --amazonec2-instance-type "t2.micro" production
docker-machine env production
eval $(docker-machine env production)
From this point on, my docker-compose commands target the production container (EC2):
docker-compose build
docker-compose up -d
The docker-compose build
command took a really long time, but eventually it finished, and the app started, and I could access it over HTTP.
My question is about the process for making changes. For example, a change to docker-compose.yml (such as exposing port 443) or routine changes to the rails code. If I run docker-compose down && docker-compose up
that doesn't seem to be enough - changes to docker-compose.yml don't seem to be reflected. I assume running docker-compose build
is going to work, but that re-provisions the whole server, and takes an excruciatingly long time.
What are the practical steps for routine updates once the dockerized app is live? Is there a quick way of forcing it to refresh code?
来源:https://stackoverflow.com/questions/62240806/what-is-the-workflow-for-updating-a-rails-app-in-aws-ec2-via-docker-with-docker