Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker Setup #47

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM elixir:1.3

RUN curl -sL https://deb.nodesource.com/setup_5.x | bash -
RUN apt-get update && apt-get install -y \
nodejs \
inotify-tools

RUN mkdir /app
WORKDIR /app

ENTRYPOINT ["sh", "docker-entrypoint.sh"]
CMD ["mix", "phoenix.server"]
32 changes: 22 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,21 @@ The user flow is as follows:

## Development Setup

### Prerequisites
There are two ways to set up this application – using Docker or install everything natively on macOS.
In either case you will have to:

* Clone this repository and
* Copy the `dev.secret.exs.sample` file to `dev.secret.exs` and add the appropriate values

### Option 1: Use Docker

* Get [Docker Community Edition for your platform](https://store.docker.com/search?type=edition&offering=community)
* Run `docker-compose up web`.
* Open http://localhost:4000 in your browser

### Option 2: Native Installation on macOS

#### Prerequisites

The app is built using:

Expand All @@ -36,52 +50,50 @@ The app is built using:
* PostgreSQL `9.4`
* Redis `3.2`

#### Homebrew
##### Homebrew

Homebrew is a package manger for OSX, we'll use this install `node` and `elixir`.

```
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
```

#### Elixir
##### Elixir

Install Elixir via Homebrew

```
brew install elixir
```

#### Postgresql
##### Postgresql

Install PostgreSQL using the [Postgres.app](http://postgresapp.com)

#### Node.js
##### Node.js

Install noedejs via Homebrew

```
brew install nodejs
```

#### Redis
##### Redis

Install redis via Homebrew

```
brew install redis
```

### Setup
#### Setup

* Clone the repo
* Copy the `dev.secret.exs.sample` file to `dev.secret.ext` and add the appropriate values
* Install dependencies with `mix deps.get`
* If you get errors here, open a new terminal window. Some commands don't yet have proper binding if you've just installed `elixir` from Homebrew.
* Create and migrate your database with `mix ecto.create && mix ecto.migrate`
* Install Node.js dependencies with `npm install`

### Running the App
#### Running the App

To start the app locally:

Expand Down
6 changes: 4 additions & 2 deletions config/dev.exs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ config :phoenix, :stacktrace_depth, 20
config :espi_dni, EspiDni.Repo,
adapter: Ecto.Adapters.Postgres,
database: "espi_dni_dev",
hostname: "localhost",
hostname: System.get_env("DATABASE_HOST") || "localhost",
username: System.get_env("DATABASE_USER") || "postgres",
password: System.get_env("DATABASE_PASSWORD"),
pool_size: 10

config :rollbax,
Expand All @@ -48,7 +50,7 @@ config :rollbax, enabled: :log

# configure exq for background jobs with redis
config :exq,
host: "127.0.0.1",
host: System.get_env("REDIS_HOST") || "localhost",
port: 6379,
namespace: "exq",
concurrency: 1000,
Expand Down
12 changes: 11 additions & 1 deletion config/test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ config :logger, level: :warn
config :espi_dni, EspiDni.Repo,
adapter: Ecto.Adapters.Postgres,
database: "espi_dni_test",
hostname: "localhost",
hostname: System.get_env("DATABASE_HOST") || "localhost",
username: System.get_env("DATABASE_USER") || "postgres",
password: System.get_env("DATABASE_PASSWORD"),
pool: Ecto.Adapters.SQL.Sandbox,
ownership_timeout: 50_0000

Expand All @@ -24,6 +26,14 @@ config :rollbax,
# Set rollbar erorrs to just log locally
config :rollbax, enabled: :log

# configure exq for background jobs with redis
config :exq,
host: System.get_env("REDIS_HOST") || "localhost",
port: 6379,
namespace: "exq-test",
concurrency: 1000,
queues: ["default"]

config :espi_dni, EspiDni.Plugs.RequireSlackToken,
slack_token: "test-slack-token"

Expand Down
22 changes: 22 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
web:
build: .
volumes:
- .:/app
ports:
- 4000:4000
links:
- db
- redis
environment:
DATABASE_HOST: db
REDIS_HOST: redis

db:
image: postgres
ports:
- 5432:5432

redis:
image: redis
ports:
- 6379:6379
10 changes: 10 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh

#set -e

mix local.hex --force
mix deps.get
mix ecto.create && mix ecto.migrate
npm install

exec "$@"