diff --git a/Machine-Backend/Dockerfile b/Machine-Backend/Dockerfile index d5de0bf..8cfc572 100644 --- a/Machine-Backend/Dockerfile +++ b/Machine-Backend/Dockerfile @@ -1,39 +1,31 @@ -FROM ubuntu:22.04 +# Use official Python base image (faster & smaller than Ubuntu + manual Python) +FROM python:3.10-slim +# Set working directory WORKDIR /app -# Prevent interactive prompts -ENV DEBIAN_FRONTEND=noninteractive +# Prevent Python from buffering stdout/stderr +ENV PYTHONUNBUFFERED=1 -# Install Python 3.10 and dependencies -RUN apt-get update && apt-get install -y \ - python3.10 \ - python3-pip \ - gcc \ - libmysqlclient-dev \ - pkg-config \ - libssl-dev \ - libffi-dev \ - && rm -rf /var/lib/apt/lists/* - -# Create symlinks -RUN ln -sf /usr/bin/python3.10 /usr/bin/python && \ - ln -sf /usr/bin/pip3 /usr/bin/pip - -# Copy requirements and install +# Copy requirements first for better caching COPY requirements.txt . -RUN pip install --no-cache-dir -r requirements.txt -# Copy app code +# Use PyPI mirror + increased timeout to avoid network errors +RUN pip install --no-cache-dir -r requirements.txt \ + -i https://pypi.org/simple \ + --timeout=100 + +# Copy application code COPY . . -# Production environment +# Environment variables ENV FLASK_ENV=production ENV FLASK_APP=run.py ENV FLASK_RUN_HOST=0.0.0.0 ENV FLASK_RUN_PORT=5000 +# Expose the Flask port EXPOSE 5000 -# Use Gunicorn -CMD ["gunicorn", "--bind", "0.0.0.0:5000", "run:app"] \ No newline at end of file +# Use Gunicorn for production +CMD ["gunicorn", "--bind", "0.0.0.0:5000", "run:app"]