-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Slow Python Docker Image Build when installingnumpy
or pandas
#159
Comments
yes, there are plans to fix this by decoupling the nodeJS CLI from bot execution inside the container (which is currently why we use a node-alpine base image). the dependent issue is tracked here: #145 an alternative solution in the meantime could be to just use a python base image, and then install node to it so the CLI can be invoked. |
This alternative solution provided by vvlovsky works! # Build stage: compile Python dependencies
FROM ubuntu:focal as builder
RUN apt-get update -y && apt-get upgrade -y
RUN apt-get install -y python3 pip
RUN python3 -m pip install --upgrade pip
COPY requirements.txt ./
RUN python3 -m pip install --user -r requirements.txt
# Final stage: copy over Python dependencies and install production Node dependencies
FROM ubuntu:focal
# this python version should match the build stage python version
RUN apt-get update
RUN apt-get -y install curl gnupg
RUN curl -sL https://deb.nodesource.com/setup_14.x | bash -
RUN apt-get -y install nodejs
COPY --from=builder /root/.local /root/.local
ENV PATH=/root/.local:$PATH
ENV NODE_ENV=production
# Uncomment the following line to enable agent logging
LABEL "network.forta.settings.agent-logs.enable"="true"
WORKDIR /app
COPY ./src ./src
COPY package*.json ./
RUN npm ci --production
CMD [ "npm", "run", "start:prod" ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi! I have a detection bot that utilizes python data science related packages
pandas
andnumpy
, and it took ~2 hours to build the docker image.It took the most time installing
pandas
andnumpy
because alpine was rebuilding from source code for these packages instead of copying the wheel packages over which is a much faster and reliable python package installation method. However, Alpine platform doesn't support wheel packages, so we may need to switch to a different base builder image, e.g. debian based for python bots.The text was updated successfully, but these errors were encountered: