Performance: Docker containerization
Docker containerization affects application startup time, resource usage, and deployment speed, impacting how quickly a Flask app becomes responsive.
FROM python:3.12-slim WORKDIR /app COPY requirements.txt /app/ RUN pip install --no-cache-dir -r requirements.txt COPY . /app CMD ["python", "app.py"]
FROM python:3.12 WORKDIR /app COPY . /app RUN pip install -r requirements.txt CMD ["python", "app.py"]
| Pattern | Image Size | Startup Time | Resource Usage | Verdict |
|---|---|---|---|---|
| Large base image with full copy | 500MB+ | 5+ seconds | High CPU and memory | [X] Bad |
| Slim base image with layered caching | 200MB | 2 seconds | Optimized CPU and memory | [OK] Good |
FROM python:3.12-slim WORKDIR /app COPY requirements.txt ./ RUN pip install -r requirements.txt COPY . . CMD ["python", "app.py"]
docker build . and then docker run?FROM python:3.12-slim COPY app.py /app/ CMD ["python", "app.py"]
docker run -e VAR=value passes variables dynamically to container.docker run -e VAR=value and access via os.environ in Flask -> Option CPass the test and this pattern moves unknown