Skip to content
This repository has been archived by the owner on Feb 28, 2018. It is now read-only.

Make Docker great again #163

Merged
merged 13 commits into from
May 17, 2017
Merged
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
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ COPY requirements.txt /requirements.txt
RUN python -m pip install -U pip
RUN python -m pip install -r requirements.txt
RUN apt-get update && apt-get install -y postgresql postgresql-contrib
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In theory we were installing PostgreSQL because pyscopg2 (PostgreSQL driver for Python) needs one or other library that comes with PostgreSQL. If this apt-get is coming after pip this might not be necessary anymore.

TLDR IMHO we can get rid of line 5

COPY .env /code/.env
COPY manage.py /code/manage.py
COPY jarbas /code/jarbas
WORKDIR /code
Expand Down
9 changes: 3 additions & 6 deletions Dockerfile-elm
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
FROM node:6.9.1

RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
RUN sudo apt-get update
RUN sudo apt-get install yarn

RUN npm install yarn
RUN ln -s /node_modules/yarn/bin/yarn.js /usr/bin/yarn
WORKDIR /code

COPY yarn.lock yarn.lock
Expand All @@ -14,4 +11,4 @@ COPY gulpfile.js gulpfile.js
RUN yarn install --pure-lockfile

COPY jarbas jarbas
CMD yarn assets
CMD ["yarn", "assets"]
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
run.jarbas:
docker-compose up -d --build
docker-compose up -d
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We must reflect this change in README.md before merging

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed: 8b73b79

docker-compose run --rm jarbas python manage.py ceapdatasets
docker-compose run --rm jarbas python manage.py migrate

Expand Down
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ cp contrib/.env.sample .env

### Using Docker

If you have [Docker](https://docs.docker.com/engine/installation/) (with [Docker Compose](https://docs.docker.com/compose/install/)) and make, just run:
#### Requirements
[Docker](https://docs.docker.com/engine/installation/) (with [Docker Compose](https://docs.docker.com/compose/install/)), just run:

```console
make run.devel
Expand All @@ -148,7 +149,7 @@ make run.devel
or

```console
docker-compose up -d --build
docker-compose up -d
docker-compose run --rm jarbas python manage.py migrate
docker-compose run --rm jarbas python manage.py ceapdatasets
docker-compose run --rm jarbas python manage.py collectstatic --no-input
Expand All @@ -170,6 +171,10 @@ docker-compose run --rm jarbas python manage.py irregularities contrib/sample-da

You can get the datasets running [Rosie](https://github.com/datasciencebr/rosie) or directly with the [toolbox](https://github.com/datasciencebr/rosie).

To add a fresh new reimbursements.xz brewed by [Rosie](https://github.com/datasciencebr/rosie) or from [toolbox](https://github.com/datasciencebr/rosie), you just need to have this file inside project folder and give the path at the end of the command, as bellow:
```
docker-compose run --rm jarbas python manage.py reimbursements PATH_TO_YOUR_FRESH_NEW_REIMBURSEMENTS.xz
```

### Local install

Expand Down Expand Up @@ -218,6 +223,8 @@ Copy `contrib/.env.sample` as `.env` in the project's root folder and adjust you
* `GOOGLE_ANALYTICS` (_str_) Google Analytics tracking code (e.g. `UA-123456-7`)
* `GOOGLE_STREET_VIEW_API_KEY` (_str_) Google Street View Image API key

To use GOOGLE_STREET_VIEW_API_KEY just export it in a local environment variable, so when you run Jarbas it will get from the local environment variable.

#### Migrations

Once you're done with requirements, dependencies and settings, create the basic database structure:
Expand Down
24 changes: 14 additions & 10 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
version: '2'
services:
jarbas:
build:
context: .
dockerfile: Dockerfile
image: datasciencebr/jarbas-backend
volumes:
- "staticfiles:/code/staticfiles"
- "assets:/code/staticfiles"
- "./:/code"
- ".env:/code/.env"
environment:
- SECRET_KEY=lets-rock
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's extremely unsafe to use this for production. As the focus is development environment this is not a problem right now… but I decided to let this note here so we can (later) take care of that and of GOOGLE_STREET_VIEW_API_KEY ; )

- DATABASE_URL=postgres://jarbas:mysecretpassword@db/jarbas
- CACHE_BACKEND=django.core.cache.backends.memcached.MemcachedCache
- CACHE_LOCATION=cache:11211
- DEBUG=True
- ALLOWED_HOSTS=localhost,127.0.0.1
- AMAZON_S3_BUCKET=serenata-de-amor-data
- AMAZON_S3_REGION=s3-sa-east-1
- AMAZON_S3_CEAPTRANSLATION_DATE=2016-08-08
- GOOGLE_STREET_VIEW_API_KEY

depends_on:
- elm
- db
Expand All @@ -24,18 +29,15 @@ services:
- apps

elm:
build:
context: .
dockerfile: Dockerfile-elm
image: datasciencebr/jarbas-frontend
volumes:
- "./:/code"
- "/code/node_modules"
- "assets:/code/jarbas/frontend/static"
command: [yarn, watch]

nginx:
build:
context: .
dockerfile: Dockerfile-nginx
image: datasciencebr/jarbas-server
volumes:
- "assets:/opt/jarbas/staticfiles"
ports:
Expand All @@ -51,6 +53,8 @@ services:
- POSTGRES_PASSWORD=mysecretpassword
- POSTGRES_USER=jarbas
- POSTGRES_DB=jarbas
ports:
- "5432:5432"
networks:
- backend
volumes:
Expand Down