I have a working Docker-Compose on my local server Now that I have to go to prod, I just copied the whole directory on my prod server, same directory structure, config file etc... But when I run the docker-compose command (docker-compose -f docker-compose.dev.yml up) it throws me this error :
Step 7/28 : COPY ../../data_acquisition_survey_api/ . ERROR: Service 'web' failed to build: COPY failed: forbidden path outside the build context: ../../data_acquisition_survey_api/ ()
I went through all google available threads but with no luck, tried Docker build, docker context etc.... but nothing works, any suggestion?
Thanks !!
Folder structure :
server/docker/api
server/docker/db
server/docker/nginx
server/docker-compose.dev.yml file details:
version: '3.7'
services:
web:
build:
context: .
dockerfile: docker/api/Dockerfile.dev
command: gunicorn data_acquisition_survey_api.wsgi:application --bind 0.0.0.0:8000 --reload
expose:
- 8000
volumes:
- .:/home/server/web
env_file:
- docker/api/.env
depends_on:
- db
db:
build:
context: ./docker/db
dockerfile: Dockerfile
volumes:
- postgres_data:/var/lib/postgresql/data/
env_file:
- docker/db/.env
environment:
- "POSTGRES_INITDB_ARGS=-E UTF8"
nginx:
build:
context: ./docker/nginx
dockerfile: Dockerfile.dev
ports:
- 80:80
depends_on:
- web
environment:
TZ: Europe/Paris
volumes:
postgres_data:
server/docker/api/Dockerfile.dev as follow:
###########
# BUILDER #
###########
# pull official base image
FROM python:3.7-slim-buster as builder
# set work directory
WORKDIR /usr/src/server
# set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
# install psycopg2 dependencies
RUN apt-get update \
&& apt-get -y install postgresql-server-dev-all gcc python3-dev musl-dev
# lint
RUN pip install --upgrade pip
COPY ../../data_acquisition_survey_api/ .
COPY ../../manage.py .
# install dependencies
COPY ../../docker/api/requirements.txt .
RUN pip wheel --no-cache-dir --no-deps --wheel-dir /usr/src/server/wheels -r requirements.txt
#########
# FINAL #
#########
# pull official base image
FROM python:3.7-slim-buster
# create directory for the app user
RUN mkdir -p /home/server
# create the app user
RUN adduser --system --group server
# create the appropriate directories
ENV HOME=/home/server
ENV APP_HOME=/home/server/web
RUN mkdir $APP_HOME
WORKDIR $APP_HOME
# install dependencies
RUN apt-get update && apt-get -y install libpq-dev
RUN apt install -y netcat
COPY --from=builder /usr/src/server/wheels /wheels
COPY --from=builder /usr/src/server/requirements.txt .
RUN pip install --no-cache /wheels/*
COPY ../../docker/api/entrypoint.sh $APP_HOME
RUN chmod +x $APP_HOME/entrypoint.sh
# copy project
COPY . $APP_HOME
# chown all the files to the app user
RUN chown -R server:server $APP_HOME
# change to the app user
USER server