i have an server for application in which via child Processes in Node.js i am calling python Scripts which are responsible for ML model running.. Server is running good but the issue is of large requirements for ML model running
<code>bidict==0.23.1
mediapipe==0.10.14
numpy==1.26.0
opencv-contrib-python==4.10.0.84
opencv-python==4.10.0.84
pandas==2.2.2
tensorflow==2.17.0
</code>
<code>bidict==0.23.1
mediapipe==0.10.14
numpy==1.26.0
opencv-contrib-python==4.10.0.84
opencv-python==4.10.0.84
pandas==2.2.2
tensorflow==2.17.0
</code>
bidict==0.23.1
mediapipe==0.10.14
numpy==1.26.0
opencv-contrib-python==4.10.0.84
opencv-python==4.10.0.84
pandas==2.2.2
tensorflow==2.17.0
While dockerizing the server. this requirenmets takes upto 3.9GB of size and final image is of approx 5GB large..
this is my dockerFile if any solution can possible
<code># Use a base image with both Python and Node.js
FROM nikolaik/python-nodejs:latest
# Set up the working directory
WORKDIR /home/pn/app
# Switch to root to perform installations
USER root
# Install dependencies required by OpenCV
RUN apt-get update && apt-get install -y
libgl1-mesa-glx
libglib2.0-0
# Create a virtual environment and install Python dependencies
RUN python -m venv /home/pn/app/venv
ENV PATH="/home/pn/app/venv/bin:$PATH"
# Copy and install Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy Node.js app files and install as root
COPY package*.json ./
RUN npm install
# Switch to the 'pn' user and ensure proper ownership
# RUN chown -R pn:pn /home/pn/app
# Copy the rest of the application code
COPY . .
# Expose the necessary ports
EXPOSE 5000
# Verify Python and Node.js versions
RUN python --version
RUN node --version
# Start the application
CMD ["node", "app.js"]
</code>
<code># Use a base image with both Python and Node.js
FROM nikolaik/python-nodejs:latest
# Set up the working directory
WORKDIR /home/pn/app
# Switch to root to perform installations
USER root
# Install dependencies required by OpenCV
RUN apt-get update && apt-get install -y
libgl1-mesa-glx
libglib2.0-0
# Create a virtual environment and install Python dependencies
RUN python -m venv /home/pn/app/venv
ENV PATH="/home/pn/app/venv/bin:$PATH"
# Copy and install Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy Node.js app files and install as root
COPY package*.json ./
RUN npm install
# Switch to the 'pn' user and ensure proper ownership
# RUN chown -R pn:pn /home/pn/app
# Copy the rest of the application code
COPY . .
# Expose the necessary ports
EXPOSE 5000
# Verify Python and Node.js versions
RUN python --version
RUN node --version
# Start the application
CMD ["node", "app.js"]
</code>
# Use a base image with both Python and Node.js
FROM nikolaik/python-nodejs:latest
# Set up the working directory
WORKDIR /home/pn/app
# Switch to root to perform installations
USER root
# Install dependencies required by OpenCV
RUN apt-get update && apt-get install -y
libgl1-mesa-glx
libglib2.0-0
# Create a virtual environment and install Python dependencies
RUN python -m venv /home/pn/app/venv
ENV PATH="/home/pn/app/venv/bin:$PATH"
# Copy and install Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy Node.js app files and install as root
COPY package*.json ./
RUN npm install
# Switch to the 'pn' user and ensure proper ownership
# RUN chown -R pn:pn /home/pn/app
# Copy the rest of the application code
COPY . .
# Expose the necessary ports
EXPOSE 5000
# Verify Python and Node.js versions
RUN python --version
RUN node --version
# Start the application
CMD ["node", "app.js"]
2