Skip to content

Latest commit

 

History

History
55 lines (29 loc) · 3.89 KB

docker-notes.md

File metadata and controls

55 lines (29 loc) · 3.89 KB
  1. FROM python:3.10.0-slim-buster: This line specifies the base image for this Docker image, which is python:3.10.0-slim-buster. This is a slim version of the official Python 3.10 image based on Debian Buster.

  2. ENV APP_HOME=/app: This line sets the environment variable APP_HOME to /app.

  3. RUN mkdir $APP_HOME: This line creates a new directory in the Docker image at the path specified by the APP_HOME environment variable.

  4. RUN mkdir $APP_HOME/staticfiles: This line creates a new directory called staticfiles within the APP_HOME directory.

  5. WORKDIR $APP_HOME: This line sets the working directory of the Docker image to the APP_HOME directory.

  6. LABEL maintainer="[email protected]": This line sets a label in the Docker image with the maintainer information.

  7. LABEL description="development image for real estate project": This line sets a label in the Docker image with a brief description of the image.

  8. ENV PYTHONDONTWRITEBYTECODE 1: This line sets an environment variable to prevent Python from writing .pyc files.

  9. ENV PYTHONUNBUFFERED 1: This line sets an environment variable to enable unbuffered Python output.

  10. RUN apt-get update && apt-get install -y build-essential \: This line updates the package lists for the base image and installs the build-essential package.

  11. && apt-get install -y libpq-dev && apt-get install -y gettext \: This line continues the previous line by installing the libpq-dev and gettext packages.

  12. && apt-get install -y netcat gcc postgresql \: This line continues the previous line by installing the netcat, gcc, and postgresql packages.

  13. && apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \: This line removes any unused packages and dependencies from the image to reduce its size.

  14. && rm -f /var/lib/apt/lists/*: This line removes the package lists from the image to reduce its size.

  15. COPY ./requirements.txt /app/requirements.txt: This line copies the requirements.txt file from the host machine to the APP_HOME directory in the Docker image.

  16. RUN pip3 install --upgrade pip: This line upgrades pip to the latest version.

  17. RUN pip3 install -r requirements.txt: This line installs the Python packages specified in the requirements.txt file.

  18. COPY ./docker/local/django/entrypoint /entrypoint: This line copies the entrypoint script from the host machine to the root directory of the Docker image.

  19. RUN sed -i 's/\r$//g' /entrypoint: This line removes any Windows line endings from the entrypoint script.

  20. RUN chmod +x /entrypoint: This line makes the entrypoint script executable.

  21. COPY ./docker/local/django/start /start: This line copies the start script from the host machine to the root directory of the Docker image.

  22. RUN sed -i 's/\r$//g' /start: This line removes any Windows line endings from the start script.

  23. RUN chmod +x /start: This line makes the start script executable.

  24. ENTRYPOINT [ "/entrypoint"]

This line sets the entrypoint of the container to the /entrypoint script.

ENTRYPOINT

The ENTRYPOINT instruction specifies the command that will be run when a container is started from the image. In this Dockerfile, the entrypoint is set to /entrypoint.

The /entrypoint script is a custom script that is copied into the container, and it is used to set up the environment for the container. Specifically, it sets environment variables and runs any necessary migrations or other setup tasks for the Django application.

By setting the ENTRYPOINT to /entrypoint, any command that is passed to the container will be appended to this script, allowing the script to run before the command is executed. This is a common pattern in Dockerfiles for running setup tasks before the main command is executed.