user8852465
user8852465

Reputation:

How to integrate lib into python project using docker?

I rewrote some sync python lib to async. How do I integrate it into my project?

I did the following:

  1. clone it from github and rewrited
  2. build the lib using python3 setup.py bdist_wheel --universal and got the file .whl file

How can I integrate it to my project? Currently I have the following docker file:

FROM python:3.6

MAINTAINER ...

COPY requirements.txt requirements.txt
RUN pip install --upgrade pip
RUN pip install -r requirements.txt
COPY . $APP_DIR

EXPOSE 8080
CMD python app.py

How do I copy the .whl file into to container and install it using pip3 install {...}.whl?

Upvotes: 1

Views: 69

Answers (1)

misraX
misraX

Reputation: 985

First add WORKDIR /app before COPY requirements.txt to specify your app working directory inside the container, then if you have xxx.whl in the same folder as requirements.txt just copy it COPY xxx.whl /app then RUN pip install xxx.whl

like this:

FROM python:3.6

MAINTAINER ...

# specify workdir
WORKDIR /app
COPY requirements.txt /app
# copy xxx.whl from host to container
COPY xxx.whl /app
RUN pip install --upgrade pip
RUN pip install -r requirements.txt
# install xxx.whl
RUN pip install xxx.whl
COPY . /app

EXPOSE 8080
CMD python app.py

Upvotes: 2

Related Questions