Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker build seems to not see requirements.txt even though it's in same directory

I'm setting up a website, I have the backend set up using Django and Gunicorn, and I am trying to package the whole thing in a docker container. I am using docker 17.05.0-ce edge on Ubuntu 17.04 Zesty. For some reason, even though the directory mysite has the Dockerfile, Django app, requirements.txt, start.sh (on github here), the docker build stops at ADD requirements.txt /app/src/requirements.txt.

# Dockerfile

# FROM base image to build upon
FROM phusion/baseimage

# RUN install python and pip
RUN apt-get update
RUN apt-get install -y python python-pip python-dev 

# ADD requirements.txt and RUN pip to install them
ADD requirements.txt /app/src/requirements.txt
WORKDIR /app/src
RUN pip install -r requirements.txt

# EXPOSE port 8000 to allow communication to/from server
EXPOSE 8000

# CMD execute start.sh to start the server running.

WORKDIR /app/src/mysite
CMD ["/start.sh"]
# done!

I navigate to 'mysite', run docker build - < Dockerfile and it stops on the line where it copies requirements.txt and i get the following error:

Sending build context to Docker daemon  2.048kB
Step 1/9 : FROM phusion/baseimage
 ---> 877509368a8d
Step 2/9 : RUN apt-get update
 ---> Using cache
 ---> adcb4b9e8b08
Step 3/9 : RUN apt-get install -y python python-pip python-dev
 ---> Using cache
 ---> 8dbbd3e010d5
Step 4/9 : ADD requirements.txt /app/src/requirements.txt
lstat requirements.txt: no such file or directory

Which, to me, says that I'm doing this all wrong.

like image 786
ThisGuyCantEven Avatar asked Jun 06 '17 21:06

ThisGuyCantEven


1 Answers

You are not sending a context to the docker daemon to build your project.

Use this:

docker build -t invent_an_image_name /path/to/mysite
like image 68
Robert Avatar answered Oct 01 '22 22:10

Robert