I am new to Docker and trying to deploy a django project with the same. But after building the docker-compose I am getting this error:
ERROR: Could not open requirements file: [Errno 2] No such file or directory: 'requirements.txt' ERROR: Service 'web' failed to build: The command '/bin/sh -c pip install -r requirements.txt' returned a non-zero code: 1
I might be messing up in setting the correct path so here is my project structure
~/Desktop/Projects/ToDoApp
ToDoApp
settings.py
docker-compose.yml
Dockerfile
manage.py
requirements.txt
Here is my dockerfile
#pull official base image
FROM python:3
#set envionment variables
ENV PYTHONUNBUFFERED 1
# Adding requirements file
ADD requirements.txt ToDoApp/ToDoApp
#set work directory
WORKDIR /ToDoApp
#install dependencies
RUN pip install --upgrade pip
RUN pip install -r requirements.txt
CMD ["python", "./ToDoApp/manage.py runserver 0.0.0.0:8000"]
and this is my docker-compose.yml
version: '3'
services:
web:
build: .
command: python /ToDoApp/manage.py runserver 0.0.0.0:8000
volumes:
- .:/Desktop/Projects/ToDoApp
ports:
- "8000:8000"
environment:
- SECRET_KEY = please_change_me
requirements.txt
in a subdirectory,ToDoApp/ToDoApp/
, or, provided that subdir didn't exist, you renamed it toToDoApp/ToDoApp
.ADD
command uses a relative directory, whileWORKDIR
uses an absolute directory. Unless your Docker working directory was/
first, I assume this won't be correct.WORKDIR /ToDoApp/ToDoApp
and try