[Answered ]-Aldryn – how to add own Django apps and its dependencies

2👍

Where to put project specific python code?

Project specific applications can be placed in the root of the project – that’ll just work out of the box. If there are many such apps that might be a bit messy though. But it is easy to add an extra directory to the PYTHONPATH. In the Dockerfile add: ENV PYTHONPATH /app/src:$PYTHONPATH. The beginning of the Dockerfile should look something like this:

# <DOCKER_FROM>  # Warning: text inside the DOCKER_FROM tags is auto-generated. Manual changes will be overwritten.
FROM aldryn/base-project:3.1.0
# </DOCKER_FROM>

# add the "src" folder to the PYTHONPATH
ENV PYTHONPATH /app/src:$PYTHONPATH

# <DOCKER_BUILD>  # Warning: text inside the DOCKER_BUILD tags is auto-generated. Manual changes will be overwritten.

# node modules
[....]

After this change the docker image will need to be rebuilt: docker-compose build web

How to install external project dependencies?

External project specific requirements can be added to requirements.in. It is very similar to requirements.txt, but is preprocessed with the pip-compile command from pip-tools.

Make sure to place custom dependencies outside of the

# <INSTALLED_ADDONS>
...
# </INSTALLED_ADDONS>

tags, since that part of the file is maintained automatically and is overwritten automatically with the requirements that were chosen in the UI.

For changes in this file to be picked up, rebuild the docker image: docker-compose build web

Leave a comment