From a90d8b3a685a5965046a7659ec8519eac74129de Mon Sep 17 00:00:00 2001 From: mukeshs Date: Tue, 14 Oct 2025 17:25:55 +0530 Subject: [PATCH] first commit --- Machine-Backend/Dockerfile | 40 +++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/Machine-Backend/Dockerfile b/Machine-Backend/Dockerfile index cbdce20..44b8e7a 100644 --- a/Machine-Backend/Dockerfile +++ b/Machine-Backend/Dockerfile @@ -1,23 +1,35 @@ -# Backend Dockerfile -FROM python:3.10-slim +# syntax=docker/dockerfile:1.4 +# Builder stage: compile dependencies +FROM --platform=$BUILDPLATFORM python:3.10-alpine AS builder WORKDIR /app -# Install system dependencies (for mysqlclient or pymysql) -RUN apt-get update && apt-get install -y gcc python3-dev default-libmysqlclient-dev && rm -rf /var/lib/apt/lists/* +# Install build dependencies +RUN apk add --no-cache gcc musl-dev python3-dev mariadb-dev libffi-dev openssl-dev -# Copy dependencies -COPY requirements.txt ./ -RUN pip install --no-cache-dir -r requirements.txt +# Copy requirements and install +COPY requirements.txt . +RUN pip install --no-cache-dir --prefix=/install -r requirements.txt -# Copy project files +# Copy application code COPY . . -# Expose Flask port +# Final stage: minimal runtime image +FROM python:3.10-alpine AS final + +WORKDIR /app + +# Copy installed packages from builder +COPY --from=builder /install /usr/local +# Copy app code +COPY --from=builder /app /app + +# Set production 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 5000 -# Environment (set via docker-compose) -ENV FLASK_ENV=production - -# Start the Flask app -CMD ["python", "run.py"] +CMD ["flask", "run"]