davidtavarez / glucolog

API para dar seguimiento a la glicemia en niños con Diabetes
https://glucologapi.docs.apiary.io/
2 stars 7 forks source link

Feature/dockerize repository #58

Closed sjortiz closed 5 years ago

sjortiz commented 5 years ago

Description

This PR aims to dockerize the python api by doing the following adjustments:

  1. Adds a multi stage Dockerfile, meaning that this Dockerfile is comprised of multi parts (the first one that builds the dependencies, another that copies that dependencies and run the app)

  2. Modifies the app.run command in src/python3/run.py to make it listen to all the interfaces by specifying the host as 0.0.0.0

  3. Adds the Dockerfile to the .dockerignore so its changes don't lost the cache after the copy command

  4. Adds the migrations folder to the .dockerignore so it doesn't get copy over as it needs to be deleted anyway

  5. Adds the tests folder to the .dockerignore so it doesn't get copy over as it's not used in the docker setup

Fixes

Fixes #57

davidtavarez commented 5 years ago

@sjortiz is there any way to update the .travis.yml file to run the tests inside the Docker container?

sjortiz commented 5 years ago

yes, there is but it will add extra size to docker, I specifically ignored the tests folder in the copy command

davidtavarez commented 5 years ago

Got it! So I think Laravel tests should be removed from the .travis.yml and then change the file to match the same environment of the Docker container. Is that possible?

davidtavarez commented 5 years ago

@sjortiz I sent you an email, please confirm the information. Thanks!

sjortiz commented 5 years ago

@davidtavarez are test test failing because of my latest changes? I'm not following the following statement:

change the file to match the same environment of the Docker container. Is that possible?

could you rephrase?

davidtavarez commented 5 years ago

If you can notice in the .travis.yml we have 2 groups of tests: Laravel on PHP 7.2 and Flask on Python 3.7. The Laravel tests are failing.

screen shot 2019-02-12 at 10 36 20 pm

We can remove the Laravel on PHP 7.2 tests from this repo since the Laravel code will be at the @nromero125's fork.

The Travis CI runs the tests under xenial but the Docker Container runs under alpine. I think both environments should have the same SO: alpine.

davidtavarez commented 5 years ago

@sjortiz I was investigating a little bit more and I was wrong. If you're able to match the SO is fine but not necessary.

sjortiz commented 5 years ago

In fact, due to the project structure, the pip install command won't run in alpine, it will fail with the following error:

Collecting psycopg2==2.7.6.1 (from -r requirements.txt (line 22))
  Downloading https://files.pythonhosted.org/packages/c0/07/93573b97ed61b6fb907c8439bf58f09957564cf7c39612cef36c547e68c6/psycopg2-2.7.6.1.tar.gz (427kB)
    Complete output from command python setup.py egg_info:
    running egg_info
    creating pip-egg-info/psycopg2.egg-info
    writing pip-egg-info/psycopg2.egg-info/PKG-INFO
    writing dependency_links to pip-egg-info/psycopg2.egg-info/dependency_links.txt
    writing top-level names to pip-egg-info/psycopg2.egg-info/top_level.txt
    writing manifest file 'pip-egg-info/psycopg2.egg-info/SOURCES.txt'

    Error: pg_config executable not found.

    pg_config is required to build psycopg2 from source.  Please add the directory
    containing pg_config to the $PATH or specify the full executable path with the
    option:

        python setup.py build_ext --pg-config /path/to/pg_config build ...

    or with the pg_config option in 'setup.cfg'.

    If you prefer to avoid building psycopg2 from source, please install the PyPI
    'psycopg2-binary' package instead.

    For further information please check the 'doc/src/install.rst' file (also at
    <http://initd.org/psycopg/docs/install.html>).

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-3vb8dr89/psycopg2/

That's why I had to made the trick of building on the full image and then copying over the dependencies, I'll proceed and remove the laravel part from the .yml

davidtavarez commented 5 years ago

make sense!