Advertisement
Guest User

Untitled

a guest
Sep 3rd, 2016
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. APP_NAME=$1
  4. PORT=$2
  5. : ${PORT:=4000}
  6.  
  7. echo "Creating a Phoenix app called $APP_NAME in docker with the port $PORT."
  8. docker run -it --rm -v "$PWD":/code -w /phoenix stevobengtson/vt-phoenix-docker mix phoenix.new /code/$APP_NAME
  9. cd $1
  10.  
  11. # Change the database connection
  12. sed -i -e 's/hostname: "localhost"/hostname: "db"/g' config/dev.exs
  13. sed -i -e 's/hostname: "localhost"/hostname: "db"/g' config/test.exs
  14.  
  15. cat > startup.sh << EOF
  16. #!/bin/bash
  17.  
  18. mix local.hex --force
  19. mix local.rebar --force
  20.  
  21. mix phoenix.server
  22. EOF
  23.  
  24. cat > docker-compose.yml << EOF
  25. version: '2'
  26. services:
  27. db:
  28. image: postgres:9.4
  29. environment:
  30. - POSTGRES_USER=postgres
  31. - POSTGRES_PASSWORD=postgres
  32. - POSTGRES_DB=${APP_NAME}_dev
  33.  
  34. # alpine based version to keep it tiny
  35. redis:
  36. image: redis:alpine
  37. expose:
  38. - 6379
  39.  
  40. web:
  41. image: stevobengtson/vt-phoenix-docker
  42. command: /bin/bash /code/startup.sh
  43. environment:
  44. PORT: $PORT
  45. links:
  46. - db
  47. - redis
  48. volumes:
  49. - .:/code
  50. ports:
  51. - "$PORT:$PORT"
  52. depends_on:
  53. - db
  54. EOF
  55.  
  56. docker-compose up -d
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement