-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.optimized
More file actions
37 lines (27 loc) · 976 Bytes
/
Dockerfile.optimized
File metadata and controls
37 lines (27 loc) · 976 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# ---------- Base with optimized caching ----------
FROM python:3.12-slim AS base
# Install system dependencies in one layer
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
WORKDIR /app
# Set environment variables for faster builds
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_CACHE_DIR=/tmp/pip-cache \
PIP_NO_CACHE_DIR=0
# Copy dependency files first for better layer caching
COPY pyproject.toml README.md /app/
# Install dependencies with caching
RUN mkdir -p ${PIP_CACHE_DIR} && \
pip install --upgrade pip && \
pip install --cache-dir ${PIP_CACHE_DIR} -e .
# ---------- Production ----------
FROM base AS production
# Copy application code
COPY app /app/app
EXPOSE 8000
# Default Redis URL for docker-compose network
ENV WINEAR_REDIS_URL=redis://redis:6379/0
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]