Skip to content

Commit 41ad0c2

Browse files
committed
Configure docker + database
1 parent e0afa53 commit 41ad0c2

File tree

5 files changed

+63
-4
lines changed

5 files changed

+63
-4
lines changed

.dockerignore

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# .dockerignore
2+
.git
3+
Dockerfile
4+
5+
# Mix artifacts
6+
_build
7+
deps
8+
*.ez
9+
10+
# Generate on crash by the VM
11+
erl_crash.dump
12+
13+
# Static artifacts
14+
node_modules

Dockerfile

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
FROM voidlock/elixir:1.1
2+
3+
# install psql
4+
RUN apt-get update && apt-get install -y postgresql-client
5+
6+
# install mix and rebar
7+
RUN mix local.hex --force && \
8+
mix local.rebar --force
9+
10+
# configure work directory
11+
RUN mkdir -p /usr/src/app
12+
WORKDIR /usr/src/app
13+
14+
# install dependencies
15+
COPY mix.* /usr/src/app/
16+
COPY config /usr/src/app/
17+
RUN mix do deps.get, deps.compile
18+
19+
CMD ["mix", "phoenix.server"]

README.md

+15
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,18 @@ Ready to run in production? Please [check our deployment guides](http://www.phoe
1717
* Docs: http://hexdocs.pm/phoenix
1818
* Mailing list: http://groups.google.com/group/phoenix-talk
1919
* Source: https://github.com/phoenixframework/phoenix
20+
21+
22+
## Docker
23+
24+
### Provisioning the Database
25+
26+
```shell
27+
docker-compose run --rm local sh -c "mix ecto.create"
28+
```
29+
30+
### Running Migrations
31+
32+
```shell
33+
docker-compose run --rm local sh -c "mix ecto.migrate"
34+
```

config/dev.exs

+1-4
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,5 @@ config :phoenix, :stacktrace_depth, 20
3535
# Configure your database
3636
config :rest_api, RestApi.Repo,
3737
adapter: Ecto.Adapters.Postgres,
38-
username: "postgres",
39-
password: "postgres",
40-
database: "rest_api_dev",
41-
hostname: "localhost",
38+
url: {:system, "DATABASE_URL"},
4239
pool_size: 10

docker-compose.yml

+14
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
local:
2+
build: .
3+
ports:
4+
- 4000
5+
environment:
6+
VIRTUAL_HOST: api.local.dockito.org
7+
VIRTUAL_PORT: 4000
8+
DATABASE_URL: ecto://user:password@db/rest_api_dev
9+
volumes:
10+
- ./:/usr/src/app
11+
links:
12+
- postgres:db
13+
14+
115
postgres:
216
image: postgres:9.4.5
317
ports:

0 commit comments

Comments
 (0)