ruby - How to use Capistrano with Rails and Docker-compose? -


i'm deploying rails application capistrano. doesn't have problem in way nginx , passenger.

now, move use docker-compose.

capfile

# load dsl , set stages require "capistrano/setup" require "capistrano/deploy" dir.glob("lib/capistrano/tasks/*.rake").each { |r| import r } 

deploy.rb

namespace :deploy   desc "docker compose task"   task docker_compose: :updated     on roles(:web, :app), in: :groups, limit: 3, wait: 10       within release_path         execute "cd #{release_path} && docker-compose --build -d"       end     end   end   after 'deploy:updated', 'deploy:docker_compose' end 

docker-compose.yml

version: '2'  services:   db:     image: mysql/mysql-server:5.7     environment:       - mysql_root_password=myapp12345    redis:     image: 'redis:3.2-alpine'     command: redis-server     ports:       - '6379:6379'     volumes:       - 'redis:/var/lib/redis/data'    website:     depends_on:       - 'redis'       - 'db'     build: .     image: namle/myapp_api     ports:       - '3001:3000'     volumes:       - '.:/myapp_ruby'     environment:       - redis_url=redis://redis     env_file:       - '.env'    sidekiq:     depends_on:       - 'redis'       - 'db'     build: .     command: bundle exec sidekiq     environment:       - redis_url=redis://redis     volumes:       - '.:/myapp_ruby'     env_file:       - '.env'    nginx-proxy:     image: jwilder/nginx-proxy     container_name: nginx-proxy     ports:       - 80:80     volumes:       - /var/run/docker.sock:/tmp/docker.sock:ro  volumes:   redis:   website:   sidekiq:   nginx-proxy: 

it runs okay.

but have problem

docker-compose create new network groups, volumes, images, containers after deploy because of release_path changed.

how fix it?

don't use capistrano docker. capistrano designed repeatedly deploy application existing server, while docker designed bundle application container deployed.

i don't use docker, can't give instructions, in nutshell, add dockerfile project, run docker build (or that), , deploy resulting container server.

docker compose (if understand correctly) way of assembling set of existing containers. need have application container created before docker compose run , other containers create server environment.


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -