From 560e9df1ba5d8d44c5241e26598d44fbf37f48b9 Mon Sep 17 00:00:00 2001 From: Felix Date: Fri, 19 Apr 2024 13:07:51 +0300 Subject: [PATCH 1/2] minimized docker image --- Dockerfile | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index aadd8ba..f6e89c2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,41 @@ -FROM python:3.8.3-slim +# FROM python:3.8.3-slim +# # Install build tools +# RUN apt-get update && \ +# apt-get install -y --no-install-recommends build-essential && \ +# rm -rf /var/lib/apt/lists/* + +# WORKDIR /app +# COPY requirements.txt requirements.txt +# RUN pip install -r requirements.txt +# COPY . . + +# ENV PYTHONDONTWRITEBYTECODE=1 +# ENV PYTHONUNBUFFERED=1 + +# CMD ["python", "manage.py", "runserver","0.0.0.0:8000"] + +# Use a smaller base image +FROM python:3.8.3-alpine + +# Install build tools and dependencies +RUN apk add --no-cache build-base && \ + apk add --no-cache libffi-dev openssl-dev && \ + rm -rf /var/cache/apk/* + +# Set the working directory in the container WORKDIR /app + +# Copy requirements.txt and install dependencies COPY requirements.txt requirements.txt -RUN pip install -r requirements.txt +RUN pip install --no-cache-dir -r requirements.txt + +# Copy the rest of the application code COPY . . +# Set environment variables ENV PYTHONDONTWRITEBYTECODE=1 ENV PYTHONUNBUFFERED=1 -CMD ["python", "manage.py", "runserver","0.0.0.0:8000"] \ No newline at end of file +# Command to run the application +CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"] \ No newline at end of file From f89a3a3069ec508accf39984485d5d59d2f94945 Mon Sep 17 00:00:00 2001 From: Felix Date: Fri, 19 Apr 2024 13:17:02 +0300 Subject: [PATCH 2/2] reduced image of python application docker image --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index f6e89c2..90cb7ca 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,6 +15,7 @@ # CMD ["python", "manage.py", "runserver","0.0.0.0:8000"] + # Use a smaller base image FROM python:3.8.3-alpine