From ba55e58f40d24ad3f09bd7e91de8dfbd62b58055 Mon Sep 17 00:00:00 2001 From: Felipe Morais Date: Wed, 10 May 2017 15:11:04 -0300 Subject: [PATCH 01/13] fixes elm docker file to make docker work again for development with Jarbas --- Dockerfile-elm | 7 ++----- docker-compose.yml | 1 + 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/Dockerfile-elm b/Dockerfile-elm index ef23959..129f0ca 100644 --- a/Dockerfile-elm +++ b/Dockerfile-elm @@ -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 diff --git a/docker-compose.yml b/docker-compose.yml index 1c9226b..d2e643e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -32,6 +32,7 @@ services: - "/code/node_modules" - "assets:/code/jarbas/frontend/static" command: [yarn, watch] + nginx: build: context: . From 15ab50ef4194abc10103e1f45e1c50c026d8b7d3 Mon Sep 17 00:00:00 2001 From: Felipe Morais Date: Fri, 12 May 2017 00:18:40 -0300 Subject: [PATCH 02/13] makes rest_framework statics available trough nginx --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index d2e643e..88b4c89 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,7 +5,7 @@ services: context: . dockerfile: Dockerfile volumes: - - "staticfiles:/code/staticfiles" + - "assets:/code/staticfiles" - "./:/code" environment: - SECRET_KEY=lets-rock From 63529dd41161d76c8fd27ae5e12bf76c704bbf30 Mon Sep 17 00:00:00 2001 From: Felipe Morais Date: Fri, 12 May 2017 15:25:58 -0300 Subject: [PATCH 03/13] removes .env from .gitignore, so jarbas will able to have automated docker image builds --- .env | 11 +++++++++++ .gitignore | 1 - 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 .env diff --git a/.env b/.env new file mode 100644 index 0000000..54b2a65 --- /dev/null +++ b/.env @@ -0,0 +1,11 @@ +SECRET_KEY=jaa-aaa-ar-bas +DEBUG=True +ALLOWED_HOSTS=localhost,127.0.0.1 + +DATABASE_URL=postgres://jarbas@localhost/jarbas + +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=my-google-places-api-key diff --git a/.gitignore b/.gitignore index cbdc2d3..56cce51 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,5 @@ # development environment .coverage -.env .floo *.sqlite3 htmlcov/ From ed7a7114b0748cb1432385284a36333e4b3775a2 Mon Sep 17 00:00:00 2001 From: Felipe Morais Date: Fri, 12 May 2017 15:51:53 -0300 Subject: [PATCH 04/13] Revert "removes .env from .gitignore, so jarbas will able to have automated docker image builds" This reverts commit 63529dd41161d76c8fd27ae5e12bf76c704bbf30. --- .env | 11 ----------- .gitignore | 1 + 2 files changed, 1 insertion(+), 11 deletions(-) delete mode 100644 .env diff --git a/.env b/.env deleted file mode 100644 index 54b2a65..0000000 --- a/.env +++ /dev/null @@ -1,11 +0,0 @@ -SECRET_KEY=jaa-aaa-ar-bas -DEBUG=True -ALLOWED_HOSTS=localhost,127.0.0.1 - -DATABASE_URL=postgres://jarbas@localhost/jarbas - -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=my-google-places-api-key diff --git a/.gitignore b/.gitignore index 56cce51..cbdc2d3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ # development environment .coverage +.env .floo *.sqlite3 htmlcov/ From 40a939ae679d6a77255b3757415d5e9bc5df2ef4 Mon Sep 17 00:00:00 2001 From: Felipe Morais Date: Fri, 12 May 2017 16:43:47 -0300 Subject: [PATCH 05/13] moves environment variables from .env to docker-compose so the runner of docker-compose will set the right configurarions --- docker-compose.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 88b4c89..676949d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,18 +1,23 @@ version: '2' services: jarbas: - build: - context: . - dockerfile: Dockerfile + image: felipedemorais/auto-jarbas volumes: - "assets:/code/staticfiles" - "./:/code" + - ".env:/code/.env" environment: - SECRET_KEY=lets-rock - 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=my-google-places-api-key + depends_on: - elm - db From 3b73256bfe5b4f55515cf18e75cc51bad2ee9d14 Mon Sep 17 00:00:00 2001 From: Felipe Morais Date: Fri, 12 May 2017 16:52:40 -0300 Subject: [PATCH 06/13] remove the copy of .env in Dockerfile because it is not necessary anymore since environment variables are now given through docker-compose or sytem environment variables --- Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index e5a22b5..be9f822 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 .env /code/.env COPY manage.py /code/manage.py COPY jarbas /code/jarbas WORKDIR /code From 246e87fd3396ba8140cffa6ed84702dabe901be1 Mon Sep 17 00:00:00 2001 From: Felipe Morais Date: Sun, 14 May 2017 02:26:57 -0300 Subject: [PATCH 07/13] uses best practice to handle CMD in Docker to do not surprises running this elm container --- Dockerfile-elm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile-elm b/Dockerfile-elm index 129f0ca..4ce6486 100644 --- a/Dockerfile-elm +++ b/Dockerfile-elm @@ -11,4 +11,4 @@ COPY gulpfile.js gulpfile.js RUN yarn install --pure-lockfile COPY jarbas jarbas -CMD yarn assets +CMD ["yarn", "assets"] From fd09172ecda700313b232279add53e8073022709 Mon Sep 17 00:00:00 2001 From: Felipe Morais Date: Sun, 14 May 2017 02:30:33 -0300 Subject: [PATCH 08/13] uses images from docker hub instead of build every time that docker-compose is ran --- Makefile | 2 +- docker-compose.yml | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index d9bd8fd..09bdfd4 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ run.jarbas: - docker-compose up -d --build + docker-compose up -d docker-compose run --rm jarbas python manage.py ceapdatasets docker-compose run --rm jarbas python manage.py migrate diff --git a/docker-compose.yml b/docker-compose.yml index 676949d..244c2e6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -29,9 +29,7 @@ services: - apps elm: - build: - context: . - dockerfile: Dockerfile-elm + image: felipedemorais/auto-jarbas-frontend volumes: - "./:/code" - "/code/node_modules" @@ -39,9 +37,7 @@ services: command: [yarn, watch] nginx: - build: - context: . - dockerfile: Dockerfile-nginx + image: felipedemorais/aut-jarbas-nginx volumes: - "assets:/opt/jarbas/staticfiles" ports: From 8b73b79c248b5a6658b9ca88b5311b3734e75cda Mon Sep 17 00:00:00 2001 From: Felipe Morais Date: Tue, 16 May 2017 11:01:48 -0300 Subject: [PATCH 09/13] fixes command to run docker-compose on README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7598128..443cd01 100644 --- a/README.md +++ b/README.md @@ -148,7 +148,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 From f60ea8e1d9349ab78d07c13f4147c099326bbccd Mon Sep 17 00:00:00 2001 From: Felipe Morais Date: Tue, 16 May 2017 11:19:22 -0300 Subject: [PATCH 10/13] change beta images for oficials from datasciencebr Docker Hub --- docker-compose.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 244c2e6..79ef8e7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,7 @@ version: '2' services: jarbas: - image: felipedemorais/auto-jarbas + image: datasciencebr/jarbas-backend volumes: - "assets:/code/staticfiles" - "./:/code" @@ -29,7 +29,7 @@ services: - apps elm: - image: felipedemorais/auto-jarbas-frontend + image: datasciencebr/jarbas-frontend volumes: - "./:/code" - "/code/node_modules" @@ -37,7 +37,7 @@ services: command: [yarn, watch] nginx: - image: felipedemorais/aut-jarbas-nginx + image: datasciencebr/jarbas-server volumes: - "assets:/opt/jarbas/staticfiles" ports: From 1cdab6d63b310be6391715971c4ceadac0c4dec8 Mon Sep 17 00:00:00 2001 From: Felipe Morais Date: Wed, 17 May 2017 10:06:18 -0300 Subject: [PATCH 11/13] makes GOOGLE_STREET_VIEW_API_KEY work easily with docker compose and add the instructions in README --- README.md | 5 ++++- docker-compose.yml | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 443cd01..0b3c26d 100644 --- a/README.md +++ b/README.md @@ -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 @@ -218,6 +219,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: diff --git a/docker-compose.yml b/docker-compose.yml index 79ef8e7..3a07dba 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,7 +16,7 @@ services: - 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=my-google-places-api-key + - GOOGLE_STREET_VIEW_API_KEY depends_on: - elm From 6d018288a7d2e47ef02b704a884b4965f70e7118 Mon Sep 17 00:00:00 2001 From: Felipe Morais Date: Wed, 17 May 2017 11:42:04 -0300 Subject: [PATCH 12/13] exposes the database port to make it easy to connect --- docker-compose.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docker-compose.yml b/docker-compose.yml index 3a07dba..7d5ac11 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -53,6 +53,8 @@ services: - POSTGRES_PASSWORD=mysecretpassword - POSTGRES_USER=jarbas - POSTGRES_DB=jarbas + ports: + - "5432:5432" networks: - backend volumes: From f2a6f31f02601eab857799a11abc02a59c72a392 Mon Sep 17 00:00:00 2001 From: Felipe Morais Date: Wed, 17 May 2017 11:50:47 -0300 Subject: [PATCH 13/13] adds instructions to seed database with a new reimbursements.xz in the database --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 0b3c26d..d8d02c9 100644 --- a/README.md +++ b/README.md @@ -171,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