Gasim Gasim - 2 months ago 14
Git Question

How to make docker-compose load the context from GIT to a specific directory?

Here is my docker-compose file:

version: '2'
services:
web:
build:
context: git@git.example.com:/abc/abc-backend
volumes:
- ./.data/app:/app


The git repository has a Dockerfile in it such as this one:

FROM python:3.5
ENV PYTHONBUFFERED 1
RUN mkdir /app
WORKDIR /app
RUN pip install -r requirements.txt
RUN ./manage.py runserver


requirements.txt is inside the git repository. When I do
docker-compose build
, it gives me error:


Could not open requirements file: [Errno 2] No such file or directory: 'requirements.txt'


My understanding is that, docker-compose clones the repository to a directory that I don't know. Is there a way I can change where docker-compose clones the directory? I want the directory to be cloned to
/app
.

Answer

Your Dockerfile never copies any files into the image. You need to add a COPY . /app/ instruction before the RUN pip ... instruction, just as if you were building from a local context instead of a Git repository.