4👍
RUN mkdir /code
This line will create a directory under /
called code. This directory will contain the code which currentlt resides in .
on the host machine.
ADD ./mysite/requirements.txt /code/
Add the python requirements.txt from host machine into the code
directory inside the container.
RUN pip install -r requirements.txt
Install the requirements inside the container.
ADD . /code/
Add the python code from the host machine into the container inside /code
directory
volumes:
< - .:/code >
Mount the curent directory on the host onto the containers /code
directory. You may wonder why do this and the code has already been added via the ADD . /code/
?
This is a clever technique for developement purposes. Rather than rebuilding the image every time you change in the python code, you can mount the python code and automatically the changes will be visible inside the container. So only restarting the container is needed to have the new code changes.