Saturday, 2 September 2023

Trying to avoid g++ installed in my image

I have the following dockerfile

FROM python:3.8-slim as builder

RUN apt-get update && apt-get install -y g++

WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir --prefix=/install -r requirements.txt

FROM python:3.8-slim

WORKDIR /app
COPY --from=builder /install /usr/local
COPY . .

EXPOSE 5004

CMD ["python", "server.py"]

The one of my libraries ( I need PyStan library without the possibility of considering other alternatives) needs a C++ compiler to be installed (not to run) so I have g++ which causes the image size increase to 1.4GB .

I tried looking for other alternatives such as musl-gcc or llvm-g++ but none of them seem to be available under my python image.

Is there any workaround to reduce the image weight without needing to install g++?



from Trying to avoid g++ installed in my image

No comments:

Post a Comment