Advertisement
Guest User

Untitled

a guest
Sep 6th, 2017
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. def dbconf
  2. Rails.configuration.database_configuration[Rails.env]
  3. end
  4.  
  5. namespace :docker do
  6. namespace :db do
  7. desc "Launch docker container for database"
  8. task run: :environment do
  9. sh <<-BASH.strip_heredoc
  10. docker run \
  11. --rm \
  12. --name #{dbconf["database"]} \
  13. --env POSTGRES_PASSWORD=#{dbconf["password"]} \
  14. --env POSTGRES_USER=#{dbconf["username"]} \
  15. --env POSTGRES_DB=#{dbconf["database"]} \
  16. --publish "#{dbconf["port"]}:5432" \
  17. --volume "$PWD/docker/db:/var/lib/postgresql" \
  18. postgres
  19. BASH
  20. end
  21.  
  22. task rm: :environment do
  23. sh "docker rm #{dbconf["database"]}"
  24. end
  25. end
  26. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement