Currently I am creating a virtual environment in the first stage.
Running command pip install -r requirements.txt , which install executables in /venv/bin dir .
In second stage i am copying the /venv/bin dir , but on running the python app error comes as module not found i.e i need to run pip install -r requirements.txt again to run the app .
The application is running in python 2.7 and some of the dependencies requires compiler to build . Also those dependencies are failing with alpine images compiler , and only works with ubuntu compiler or python:2.7 official image ( which in turn uses debian)
Am I missing some command in the second stage that will help in using the copied dependencies instead of installing it again .
RUN apt-get update &&apt-get install -y --no-install-recommends build-essential gcc RUN pip install --upgrade pip RUN python3 -m venv /venv COPY ./requirements.txt /project/requirements/ RUN /venv/bin/pip install -r /project/requirements/requirements.txt COPY . /venv/bin FROM python:2.7-slim AS release COPY --from=build /venv /venv WORKDIR /venv/bin RUN apt-get update && apt-get install -y --no-install-recommends build-essential gcc #RUN pip install -r requirements.txt // RUN cp settings.py.sample settings.py CMD ["/venv/bin/python3", "-m", "main.py"]
I am trying to avoid pip install -r requirements.txt in second stage to reduce the image size which is not happening currently.