I run docker-compose build command to set up the environment. But I had a following error.
=> ERROR [3/5] COPY ../requirements.txt /code/
failed to compute cache key: "/requirements.txt" not found: not found
ERROR: Service 'web' failed to build : Build failed
What is the problem here. My folder structure is wrong ?
.
├── backend/
│ └── api/
│ ├── __init__.py
│ ├── main.py
│ └── Dockerfile
├── .dockerignore
├── docker-compose.yml
└── requirements.txt
This is the Dockerfile in backend folder
FROM python:3.10.8-slim-buster
WORKDIR /code
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
COPY ../requirements.txt /code/
RUN pip3 install --no-cache-dir --upgrade -r /code/requirements.txt
COPY ./api /code/api
CMD ["uvicorn", "api.main:app", "--host", "0.0.0.0", "--port", "80"]
This is the docker-compose.yml in root directory
version: "3.8"
services:
web:
container_name: "sukeba_api"
build: ./backend
volumes:
- ./backend/api:/code/api
ports:
- "8000:80"
depends_on:
- db
db:
image: postgres:latest
container_name: "sukeba_db"
volumes:
- postgres_data:/var/lib/postgresql/data/
ports:
- 5432:5432
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=sukeba
volumes:
postgres_data:
I changed the folder structure but it dindt work.