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 converted into multistage #295

Closed
wants to merge 5 commits into from

Conversation

zubairshakoorarbisoft
Copy link
Contributor

@zubairshakoorarbisoft zubairshakoorarbisoft commented Feb 16, 2023

Description:

Added two stages dev and prod target in Dockerfile.

Steps to test

  • Clone the repo
  • Checkout to zshkoor/multi-stage-dockerfile branch
  • Use this command to createe an IDA
    cookiecutter -o /path/to/folder/for/creating/project cookiecutter-django-ida
  • Now go to project's root and run make upgrade to prepare requirements files
  • Now run make docker_build to make test image build

Issue:

#292

Merge checklist:

  • All reviewers approved
  • CI build is green
  • Changelog record added
  • Documentation updated (not only docstrings)
  • Commits are squashed

Copy link
Member

@UsamaSadiq UsamaSadiq left a comment

Choose a reason for hiding this comment

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

These changes looks good to go.

Copy link
Contributor

@iamsobanjaved iamsobanjaved left a comment

Choose a reason for hiding this comment

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

While enhancing native Dockerfiles to use to build docker images for devstack, we have set some standards which we want to replicate in cookiecutter here. From those standards was the use of virtualenv to install python requirements. We also need to set up virtualenv here so we have consistency among IDAs.


RUN mkdir -p /edx/var/log
# Gunicorn 19 does not log to stdout or stderr by default. Once we are past gunicorn 19, the logging to STDOUT need not be specified.
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment isn't relevant here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed


# Gunicorn 19 does not log to stdout or stderr by default. Once we are past gunicorn 19, the logging to STDOUT need not be specified.
CMD gunicorn --workers=2 --name {{cookiecutter.repo_name}} -c /edx/app/{{cookiecutter.repo_name}}/{{cookiecutter.project_name}}/docker_gunicorn_configuration.py --log-file - --max-requests=1000 {{cookiecutter.project_name}}.wsgi:application

# This line is after the requirements so that changes to the code will not
# bust the image cache
COPY . /edx/app/{{cookiecutter.repo_name}}
COPY . /edx/app/{{cookiecutter.repo_name}}
Copy link
Contributor

Choose a reason for hiding this comment

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

Add an empty line at the end of the file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added


RUN mkdir -p /edx/var/log
# Gunicorn 19 does not log to stdout or stderr by default. Once we are past gunicorn 19, the logging to STDOUT need not be specified.
CMD while true; do python ./manage.py runserver 0.0.0.0:8120; sleep 2; done
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of hardcoding the port, use cookie-cutter input {{cookiecutter.port}}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Contributor Author

Choose a reason for hiding this comment

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

While enhancing native Dockerfiles to use to build docker images for devstack, we have set some standards which we want to replicate in cookiecutter here. From those standards was the use of virtualenv to install python requirements. We also need to set up virtualenv here so we have consistency among IDAs.

Thanks @iamsobanjaved for the suggestion. I've added virtual environment and tested its successful docker image build on local.

@zubairshakoorarbisoft
Copy link
Contributor Author

Closing this PR as an other PR has already been merged which is doing the same.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants