Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def dbconf
- Rails.configuration.database_configuration[Rails.env]
- end
- namespace :docker do
- namespace :db do
- desc "Launch docker container for database"
- task run: :environment do
- sh <<-BASH.strip_heredoc
- docker run \
- --rm \
- --name #{dbconf["database"]} \
- --env POSTGRES_PASSWORD=#{dbconf["password"]} \
- --env POSTGRES_USER=#{dbconf["username"]} \
- --env POSTGRES_DB=#{dbconf["database"]} \
- --publish "#{dbconf["port"]}:5432" \
- --volume "$PWD/docker/db:/var/lib/postgresql" \
- postgres
- BASH
- end
- task rm: :environment do
- sh "docker rm #{dbconf["database"]}"
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement