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

dockerfile: remove bootstrap call #91

Merged
merged 8 commits into from
Feb 12, 2019

Conversation

dinosk
Copy link
Member

@dinosk dinosk commented Dec 6, 2018

  • Refactors Dockerfiles in the image building sequence to just
    copy the updated instance directory and run pip install, instead
    of running the bootstrap script again.

Signed-off-by: Dinos Kousidis dinos.kousidis@cern.ch


RUN ./scripts/bootstrap
RUN pipenv run pip install --upgrade marshmallow==2.16.3
Copy link
Member Author

Choose a reason for hiding this comment

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

Temporary fixes a marshmallow error with DateTime field

@@ -7,7 +7,6 @@ name = "pypi"
Babel = ">=2.4.0"
Flask-BabelEx = ">=0.9.3"
invenio = { version = ">=3.1.0dev20181106", extras = ["base", "metadata", "{{ cookiecutter.database }}", "auth", {%- if cookiecutter.elasticsearch == "5" %} "elasticsearch5", {%- elif cookiecutter.elasticsearch == "6" %} "elasticsearch6" {%- endif %} ]}
{{ cookiecutter.project_shortname }} = {editable = true, path = "."}
Copy link
Member Author

Choose a reason for hiding this comment

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

Removes the final application from Pipfile, so that it can be installed in the final step after with the dependencies has been built.

Copy link
Member

Choose a reason for hiding this comment

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

Since the application is not installed anymore, this should be reflected in the scripts/bootstrap, i.e. it should run pipenv run pip install -e . after the pipenv install ...


USER ${USER_ID}

RUN pipenv install --deploy --dev --pre
Copy link
Member Author

Choose a reason for hiding this comment

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

The --pre and --dev flags are moved here as they are meant for a dev environment. #87

@dinosk dinosk force-pushed the Dockerfile-base branch 19 times, most recently from f5a620f to 1ed800f Compare December 10, 2018 15:36
@dinosk dinosk moved this from In progress to Pending review in Invenio Sprint Dec 3 - Dec 14 2018 Dec 10, 2018
@lnielsen lnielsen assigned dinosk and kpsherva and unassigned kpsherva Dec 12, 2018
COPY ./docker/uwsgi/ ${INVENIO_INSTANCE_PATH}

RUN pipenv install --deploy --dev
RUN pipenv run pip install --upgrade marshmallow==2.16.3
Copy link
Member

Choose a reason for hiding this comment

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

I think this was an issue in case you do pipenv install --pre which will include package pre-releases. Doing the following should be fine:

$ pipenv install marshmallow
...
$ pipenv run pip freeze
marshmallow==2.16.3

# vs.

$ pipenv install --pre marshmallow
...
$ pipenv run pip freeze
marshmallow==3.0.0rc1


_rabbit_check(){ docker-compose exec mq bash -c "rabbitmqctl status" &>/dev/null; }
check_ready "RabbitMQ" _rabbit_check

_web_server_check_css(){
Copy link
Member

Choose a reason for hiding this comment

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

Isn't it enough to only wait for a valid HTTP response (as done below), since the assets are built before the server is actually started?

Copy link
Member Author

Choose a reason for hiding this comment

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

This covers the case where the link to the CSS file is there but returns 404.
In the webpack buildall step, the docker build doesn't fail so it won't actually show

Copy link
Member Author

Choose a reason for hiding this comment

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

I can't write under the comment above for some reason, (for marshmallow==2.16.3) this is indeed the case, we could remove the --pre when invenio 3.1.0 is not in prerelease and this won't be needed, except if I'm missing a better way

@@ -0,0 +1,1650 @@
{
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we should be checking-in version control Pipfile.lock for the cookiecutter. The purpose of the file is similar to what was done before when generating the requirements.txt via pip-compile. Probably something that should be added in the Invenio docs under "Getting started" -> "Next steps".

Copy link
Member Author

Choose a reason for hiding this comment

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

The point is to make the build faster, if you are installing the default configuration (e.g. db and es version) there's one less step, otherwise one would have to run it again as it is done in .travis.yml for the different environments, and this could be documented. If one follows the docs it would be ok, otherwise I see that it adds a complication. Generally this is recommended pypa/pipenv#598 https://pipenv.readthedocs.io/en/latest/basics/#pipfile-lock-security-features

Copy link
Member

Choose a reason for hiding this comment

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

I think you're correct (so let's keep the Pipfile.lock), but for different reasons. Doing ./scripts/bootstrap in the beginning runs pipenv install --dev --skip-lock which is fast since it doesn't resolve and lock dependencies in Pipfile.lock. The problem is that because of the lack of resolving dependencies it might produce a version-conflicted environment (which it actually does at the moment).

I would say that the correct practice would be to actually install dependencies from the Pipfile.lock in bootstrap, which is equivalent to the old way of first installing from requirements.txt before starting to developing the application. This is not slow since it installs pinned dependencies, and produces as stable build. The command for this would be pipenv install --dev --ignore-pipfile (or pipenv sync --dev)

Upgrading dependencies should be a separate, conscious step that is initiated by the maintainer of the instance as part of its development process (and probably documented in the official docs)

@dinosk dinosk force-pushed the Dockerfile-base branch 8 times, most recently from 66c3f5e to ae96a7f Compare December 13, 2018 14:53
@dinosk dinosk moved this from In progress to Pending review in Invenio Sprint Dec 3 - Dec 14 2018 Dec 13, 2018
@dinosk dinosk removed their assignment Dec 13, 2018
@dinosk dinosk moved this from Pending review to Pending merge in Invenio Sprint Dec 3 - Dec 14 2018 Dec 14, 2018
@@ -1,7 +1,7 @@
{% include 'misc/header.py' %}
FROM inveniosoftware/centos7-python:3.6

COPY ./ .
COPY Pipfile ./
Copy link
Member

Choose a reason for hiding this comment

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

Pipfile.lock?

Copy link
Member Author

Choose a reason for hiding this comment

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

It will be generated in the RUN pipenv install --deploy step

@slint slint self-assigned this Dec 14, 2018
dinosk and others added 8 commits December 14, 2018 18:42
* Refactors last Dockerfile in the image building sequence to just
  copy the updated instance directory and run pip install, instead
  of running the bootstrap script again.

Signed-off-by: Dinos Kousidis <dinos.kousidis@cern.ch>
* Adds Dockerfile.dev.base to install dev packages and pre releases.

* Refactors Dockerfiles to create a first image containing the application
  dependencies, and a second one to install the application, and collect
  and build its assets with webpack.

* Adds a Docker build process in run-tests.sh, to create the final instance
  image and bring up the container cluster from docker-compose.full.yml.
  Tests if web server is accessible with HTTP, HTTPS, and has loaded CSS.

Signed-off-by: Dinos Kousidis <dinos.kousidis@cern.ch>
@lnielsen
Copy link
Member

Comments have been ticktized so merging

@lnielsen lnielsen merged commit a0e20ec into inveniosoftware:master Feb 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

5 participants