okfn-brasil / jarbas

🎩 API for information and suspicions about reimbursements by Brazilian congresspeople
https://jarbas.serenata.ai/
296 stars 61 forks source link

Refactor jarbas-backend docker image #285

Closed caduvieira closed 6 years ago

caduvieira commented 6 years ago

Changes to jarbas-backend

How to test:

Change docker-compose.yml django from image to build: .

sed -i "s\image: datasciencebr/jarbas-backend\build: .\g" docker-compose.yml
docker-compose build django
docker-compose run --rm django test
docker-compose run --rm django check
docker inspect -f '{{ range .State.Health.Log }}{{ println "======\nStart:" .Start }}{{ .Output }}{{end}}' jarbas_django_1

@anaschwendler please could review?

caduvieira commented 6 years ago

Forgot to mention the size reduction. From 373M to 178M

anaschwendler commented 6 years ago

Thanks @caduvieira, that seem to be really good!

As @cuducos said that he want to test by himself, I'll let him properly test, but if he doesn't do that I'll test it later :)

cuducos commented 6 years ago

As @cuducos said that he want to test by himself, I'll let him properly test, but if he doesn't do that I'll test it later :)

Make yourself at home, go on ; )

anaschwendler commented 6 years ago

Ok, so let's go test this PR, what I plan to do:

  1. Clone the repository:

    $ git clone git@github.com:datasciencebr/jarbas.git
  2. Open the repo folder:

    $ cd jarbas
  3. Checkout to @caduvieira branch:

    $ git checkout -b caduvieira-master master
  4. Update the branch:

    $ git pull https://github.com/caduvieira/jarbas.git master
  5. Copy the .env file:

    $ cp contrib/.env.sample env
  6. Build and start services:

    $ docker build -t datasciencebr/jarbas-backend .
    $ docker run --rm django test
    $ docker run --rm django check
    $ docker inspect -f '{{ range .State.Health.Log }}{{ println "======\nStart:" .Start }}{{ .Output }}{{end}}' jarbas_django_1

    Result:

    
    ➜  jarbas git:(caduvieira-master) ✗ docker inspect -f '{{ range .State.Health.Log }}{{ println "======\nStart:" .Start }}{{ .Output }}{{end}}' jarbas_django_1
    ======
    Start: 2017-11-13 19:15:54.1284389 +0000 UTC
    ..

Total Duration: 0.088s Count: 2, Failed: 0, Skipped: 0

Start: 2017-11-13 19:16:54.2898246 +0000 UTC ..

Total Duration: 0.054s Count: 2, Failed: 0, Skipped: 0

Start: 2017-11-13 19:17:54.3989147 +0000 UTC ..

Total Duration: 0.138s Count: 2, Failed: 0, Skipped: 0

Start: 2017-11-13 19:18:54.8013659 +0000 UTC ..

Total Duration: 0.094s Count: 2, Failed: 0, Skipped: 0



Seems to be working!
cuducos commented 6 years ago

I did something wrong @caduvieira ?

This command was basically to use the Dockerfile docker-compose.yml instead of the image from Docker Hub. You can comment image: datasciencebr out of the Dockerfile docker-compose.yml replacing it by build: . manually.

caduvieira commented 6 years ago

Use the command

sed -i "s\image: datasciencebr/jarbas-backend\build: .\g" docker-compose.yml

to change the build to manual.

You could also run: docker build -t datasciencebr/jarbas-backend . If you dont want to use the sed command.

The inspect command expects the name of the container. You should change it accordingly

anaschwendler commented 6 years ago

Hi @caduvieira, I was having problems to run the sed command:

➜  jarbas git:(caduvieira-master) ✗ sed -i "s\image: datasciencebr/jarbas-backend\build: .\g" docker-compose.yml
sed: 1: "docker-compose.yml": extra characters at the end of d command

Am I doing something wrong?

caduvieira commented 6 years ago

Maybe something in different versions screenshot from 2017-11-10 18-30-55

Try using this other command and don't use the sed

docker build -t datasciencebr/jarbas-backend .
anaschwendler commented 6 years ago

Finally got it!

Here it is, works fine, thanks @caduvieira! I'll wait for @cuducos give an 👍 and then I'll merge!