Coder Social home page Coder Social logo

vzctl / capistrano-docker-compose Goto Github PK

View Code? Open in Web Editor NEW

This project forked from acandidmind/capistrano-docker-compose

0.0 1.0 0.0 11 KB

Invoking docker-compose commands during deployment and on demand.

License: MIT License

Ruby 100.00%

capistrano-docker-compose's Introduction

capistrano-docker-compose

Invoking docker-compose commands during deployment and on demand.

Uses a flat directory approach (no shared/releases folder) to be able to simply specify service directories to build without injecting variables for the release date or switching symlinks.

A git submodule install is executed after fetching and checking out the git repo.

Installation

To get started you need to have:

1. A project with existing docker-compose.yml file
2. A capistrano >= 3.3 version already hooked to your project

First - add the following line to your gemfile:

gem 'capistrano-docker', github: 'aCandidMind/capistrano-docker-compose'

Next, add the following to your Capfile:

require 'capistrano/docker-compose'

Optionally, specify the options in your config/stage/deploy.rb file, however the defaults provided should work out-of-the-box.

set :docker_role - the name of the role which is used for Docker host, defaults to ':web'
set :docker_compose_project_name - prefix for the container names, defaults to nil, so it defaults to the directory name the project is at
set :docker_compose_remove_after_stop - should we remove the containers after stopping them, defaults to true
set :docker_compose_remove_volumes - should we remove associated volumes with containers during their removal (rm -v option), default: true
set :docker_compose_build_services - specify services which should be built / ran with docker-compose (ex. docker-compose build web), default: none
set :docker_pass_env - the list of the environment variables that should be passed over to the docker-compose commands from command line (they are validated wether they exists before they are used) (ex: PULL_REQUEST_ID=10 cap staging docker:compose:start )

This is how deployment is handled:

1. validate wether we passed over the environment variables described in "docker_pass_env"
2. it runs docker-compose up with project_name and detached options

By default containers are not stopped automatically. You can use the "docker:compose:stop" task to do that (just remember that this will remove any compose-created containers unless you change the "docker_compose_remove_after_stop" option).

Usage

Run

cap STAGE docker_compose:deploy  # Perform a git checkout deploy, then build & (re)start through docker-compose

Development

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

TODO

  • create the app directory on first deploy if it's not there.

Acknowledgements

The docker-compose task wrapping is heavily inspired by netguru/capistrano-docker and the flat directory approach copied almost completely from rossriley/capistrano-simplegit.

Both are great projects but on their own didn't work out for me in their current form. I will try to get in touch with the author of capistrano-docker whether he is interested in a flat directory approach.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/aCandidMind/capistrano-docker-compose.

License

The gem is available as open source under the terms of the MIT License.

capistrano-docker-compose's People

Contributors

acandidmind avatar vzctl avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.