Make the docker App image
NOTE: THIS FILE IS ALREADY ADDED TO OUR PROJECTS
1. Create a Docker file
touch Dockerfile
2. Copy the contents
Dockerfile The first instruction is what image we want to base our container on We Use an official Python runtime as a parent image FROM python:3.8
Install basic requirements
RUN pip install django
RUN pip install djangorestframework
RUN pip install django-cors-headers
Mounts the application code to the image
COPY . code
WORKDIR /code
Allows docker to cache installed dependencies between builds COPY requirements.txt requirements.txt
RUN pip install --no-cache-dir -r requirements.txt
RUN python manage.py migrate
Runs the production server
ENTRYPOINT ["python", "manage.py"]
CMD ["runserver", "0.0.0.0:8000"]
Building the container
cd PROJECT_FOLDER_HERE
Then build
docker build -t PROJECT_NAME .
cat Dockerfile | docker build -