Docker – Creating a docker container from a capistrano deploy

capistranodeploymentdockerruby-on-rails

I'm having a bit of a difficult time understanding how I can leverage my existing infrastructure code with Docker.

I have a Ruby on Rails app that uses capistrano to push out deployments. I want to use this capistrano script to create a new docker image. Can I push out a deploy and then use the deployed to directory to deploy on top of an existing image say, precise (since that matches my target OS).

Would this be the right approach or am I missing something?

Best Answer

@EightyEight

We are using docker and Jenkins to do the deployments. We keep our code always out of docker till the time we want to release and run it.

You should have Docker Image available on all the servers/instances where you want to deploy the application.

You should do the complete deployment in two steps.

1) Have a Job in Capistrano to build a package (tar or gz) for the tag/branch of you application you want to deploy.

2) Have another job to do the actual deployments in following steps:

i) Push the package to all the servers you want to deploy the application on & untar the package.

ii) Stop if any container is already running for the same application and run the container with the appropriate container and code mounted onto it.

For e.g. docker run -d -p 8000:8000 -v /path/to/the/tag:/deployment/path/inside/docker --name (NameOfContainer) --env TERM=xterm accountid/imagename:version

Related Topic