I am deploying a Dockerized Ruby on Rails application in AWS. I need to run the docker-compose commands on server via Capistrano script.
Scenario 1: When I am trying to run docker-compose build command after deploy.
namespace :deploy do
task :docker_compose_build do
on roles(:app, :web) do
within release_path do
execute "cd #{release_path} && docker-compose build"
end
end
end
end
after "deploy", "deploy:docker_compose_build"
I am getting error "Invalid file database.yml" within docker image. Getting this error because Capistrano create symlink of linked_files instead copying.
Scenario 2: Removed database.yml from linked_files and trying to copy this file as below.
namespace :deploy do
task :docker_prepare do
on roles(:app) do
within release_path do
fetch(:config_files).each do |file|
execute "cp #{shared_path}/config/#{file} #{release_path}/config/#{file}"
end
end
end
end
task :docker_compose_build do
on roles(:app, :web) do
within release_path do
execute "cd #{release_path} && docker-compose build"
end
end
end
end
after "deploy:symlink:linked_files", "deploy:docker_prepare"
after "deploy", "deploy:docker_compose_build"
database.yml file is copying from shared path to release path but It is deleting from shared. I am not understanding why cp command is deleting the source file? Can anyone please help me to resolve my problem?