===== Stage 1: Build the Python Backend ===== FROM python:3.10-slim as python-builder Set the working directory for the backend code WORKDIR /app Install system dependencies RUN apt-get update && apt-get install -y --no-install-recommends build-essential Copy ONLY the requirements file first to leverage Docker's layer caching COPY backend/requirements.txt . RUN pip install --no-cache-dir -r requirements.txt Now copy the entire backend application code The source is 'backend/' and the destination is the current WORKDIR ('/app') COPY backend/ . ===== Stage 2: Final Production Image ===== FROM nginx:stable-alpine Remove default Nginx config and copy our custom one RUN rm /etc/nginx/conf.d/default.conf COPY nginx.conf /etc/nginx/nginx.conf Copy the installed Python environment from the builder stage COPY --from=python-builder /usr/local/lib/python3.10/site-packages /usr/local/lib/python3.10/site-packages COPY --from=python-builder /usr/local/bin /usr/local/bin Copy the Python application code from the builder stage COPY --from=python-builder /app /app WORKDIR /app Copy the static frontend files into the Nginx public directory This is the key change to match your structure COPY frontend/. /usr/share/nginx/html Expose the port Nginx will listen on EXPOSE 80 The command to start both Gunicorn (for Python) and Nginx (for serving files) Gunicorn will find 'main.py' inside the '/app' WORKDIR CMD ["sh", "-c", "gunicorn --worker-class eventlet -w 1 --bind 0.0.0.0:5000 main:app & nginx -g 'daemon off;'"]