Skip to content

Commit fbf9b2d

Browse files
committed
Add init, docker-compose and dockerfile
1 parent a4022a5 commit fbf9b2d

File tree

3 files changed

+56
-0
lines changed

3 files changed

+56
-0
lines changed

Dockerfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM elixir:1.3.4
2+
3+
RUN mix local.hex --force
4+
RUN mix local.rebar --force
5+
RUN mix archive.install --force https://github.com/phoenixframework/archives/raw/master/phoenix_new.ez
6+
RUN curl -sL https://deb.nodesource.com/setup_6.x | bash -
7+
RUN apt-get install -y -q nodejs
8+
9+
WORKDIR /app
10+
ADD . /app
11+
12+
CMD mix phoenix.server

docker-compose.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
version: '3'
2+
services:
3+
db:
4+
image: postgres:9.6-alpine
5+
web:
6+
build:
7+
context: .
8+
args:
9+
http_proxy: ${HTTP_PROXY}
10+
https_proxy: ${HTTP_PROXY}
11+
HTTP_PROXY: ${HTTP_PROXY}
12+
HTTPS_PROXY: ${HTTP_PROXY}
13+
volumes:
14+
- .:/app
15+
ports:
16+
- "4000:4000"
17+
depends_on:
18+
- db

init

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/sh
2+
set -e
3+
#set -o xtrace
4+
5+
function usage () {
6+
printf """
7+
DESCRIPTION:
8+
Create a new dockerized Phoenix project
9+
Example: ./init hello_world
10+
"""
11+
12+
}
13+
14+
if [[ -z $1 ]]; then
15+
usage
16+
exit 1
17+
fi
18+
19+
docker-compose -p $1 up -d
20+
docker-compose -p $1 run web mix phoenix.new $1
21+
mv $1/* ./
22+
mv $1/.gitignore ./
23+
rm -rf $1
24+
sed -i.bak 's/hostname: "localhost"/hostname: "db"/g' config/dev.exs && rm -f config/dev.exs.bak
25+
docker-compose -p $1 run web mix ecto.create
26+
docker-compose -p $1 restart web

0 commit comments

Comments
 (0)