From ca11a92361032917dc73369a6a63ea8b1d2ee12f Mon Sep 17 00:00:00 2001 From: Untone Date: Thu, 26 Sep 2024 23:58:11 +0300 Subject: [PATCH] dockerfile-fix --- Dockerfile | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index e5f4561..5ca1577 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,17 +1,26 @@ +# Stage 1: Build stage +FROM python:slim as builder + +WORKDIR /app + +COPY requirements.txt . + +RUN apt-get update && apt-get install -y --no-install-recommends \ + gcc \ + libffi-dev \ + libssl-dev \ + && pip install --no-cache-dir -r requirements.txt \ + && rm -rf /var/lib/apt/lists/* + +# Stage 2: Final stage FROM python:slim WORKDIR /app -# Copy just the requirements file first -COPY requirements.txt . - -# Install requirements -RUN pip install --no-cache-dir -r requirements.txt - -# Copy the rest of the application code +# Copy only necessary files from the builder stage +COPY --from=builder /usr/local/lib/python3.*/dist-packages /usr/local/lib/python3.*/dist-packages COPY . . EXPOSE 8080 -# Set the entry point -CMD ["python", "main.py"] +CMD ["python", "main.py"] \ No newline at end of file