Skip to content

Production API #266

Closed Answered by floresdwm
floresdwm asked this question in Q&A
Discussion options

You must be logged in to vote

I have figure out, how to reduce the size of final image.

# Use Python 3.10 slim image as base
FROM python:3.10-slim

# Set working directory
WORKDIR /app

# Copy source code into container
COPY . .

# Install build dependencies
RUN apt-get update && \
    apt-get install -y build-essential && \
    rm -rf /var/lib/apt/lists/*

# Install torch first
RUN pip install --no-cache-dir "torch>=1.10.0,<2.0" -f https://download.pytorch.org/whl/cpu

# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt

# Expose port if you have a flask api
EXPOSE 8000

# Run Flask application
CMD ["python3", "-m", "app.py"]

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by floresdwm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant