I have such folder structure
project
- config
-docker
Dockerfile
docker-compose.yml
- src
here_is_code
requirements.txt
Dockerfile
FROM python:3
ENV PYTHONUNBUFFERED 1
RUN mkdir /code
WORKDIR /code
ADD ../../requirements.txt /code/
RUN pip install -r requirements.txt
ADD src /code/
docker-compose.yml
version: '3'
services:
web:
build:
context: ../../
dockerfile: config/docker/Dockerfile
command:
bash -c "ls"
volumes:
- .:/code
expose:
- "8000"
nginx:
image: nginx
ports:
- "8000:8000"
volumes:
- .:/code
- ./config/nginx:/etc/nginx/conf.d
depends_on:
- web
When I run docker-compose build
I get following error:
Service 'web' failed to build: ADD failed: Forbidden path outside the build context: ../../requirements.txt ()
Is it possible to add requirements.txt or I'll have to copy this file into docker directory? Or maybe I need to use any entrypoint (entrypoint.sh)?
UPDATE
After docker build -f config/docker/Dockerfile .
and docker-compose up
I can't see my code there. Here is the output of ls -R /code
web_1 | /code:
web_1 | Dockerfile
web_1 | config
web_1 | docker-compose.yml
web_1 | src
web_1 | static
web_1 |
web_1 | /code/config:
web_1 | nginx
web_1 |
web_1 | /code/config/nginx:
web_1 |
web_1 | /code/src:
web_1 | static
web_1 |
web_1 | /code/src/static:
web_1 |
web_1 | /code/static: