Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- APP_NAME=$1
- PORT=$2
- : ${PORT:=4000}
- echo "Creating a Phoenix app called $APP_NAME in docker with the port $PORT."
- docker run -it --rm -v "$PWD":/code -w /phoenix stevobengtson/vt-phoenix-docker mix phoenix.new /code/$APP_NAME
- cd $1
- # Change the database connection
- sed -i -e 's/hostname: "localhost"/hostname: "db"/g' config/dev.exs
- sed -i -e 's/hostname: "localhost"/hostname: "db"/g' config/test.exs
- cat > startup.sh << EOF
- #!/bin/bash
- mix local.hex --force
- mix local.rebar --force
- mix phoenix.server
- EOF
- cat > docker-compose.yml << EOF
- version: '2'
- services:
- db:
- image: postgres:9.4
- environment:
- - POSTGRES_USER=postgres
- - POSTGRES_PASSWORD=postgres
- - POSTGRES_DB=${APP_NAME}_dev
- # alpine based version to keep it tiny
- redis:
- image: redis:alpine
- expose:
- - 6379
- web:
- image: stevobengtson/vt-phoenix-docker
- command: /bin/bash /code/startup.sh
- environment:
- PORT: $PORT
- links:
- - db
- - redis
- volumes:
- - .:/code
- ports:
- - "$PORT:$PORT"
- depends_on:
- - db
- EOF
- docker-compose up -d
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement