raazkumar commited on
Commit
3f85952
·
verified ·
1 Parent(s): e7b843e

Upload production/Dockerfile.prod

Browse files
Files changed (1) hide show
  1. production/Dockerfile.prod +31 -11
production/Dockerfile.prod CHANGED
@@ -1,24 +1,44 @@
1
  FROM python:3.11-slim AS builder
 
2
  RUN apt-get update && apt-get install -y --no-install-recommends \
3
- gcc libpq-dev && rm -rf /var/lib/apt/lists/*
4
- RUN python -m venv /opt/venv
5
- ENV PATH="/opt/venv/bin:$PATH"
6
- COPY requirements.prod.txt .
7
- RUN pip install --no-cache-dir --upgrade pip && \
8
- pip install --no-cache-dir -r requirements.prod.txt
 
 
 
 
 
 
9
 
10
  FROM python:3.11-slim AS production
 
11
  RUN apt-get update && apt-get install -y --no-install-recommends \
12
  libpq5 curl && rm -rf /var/lib/apt/lists/*
13
- COPY --from=builder /opt/venv /opt/venv
14
- ENV PATH="/opt/venv/bin:$PATH"
 
 
 
15
  RUN useradd --create-home --shell /bin/bash appuser
 
16
  WORKDIR /app
17
- COPY --chown=appuser:appuser production_server.py .
18
- COPY --chown=appuser:appuser worker.py .
 
 
 
 
 
19
  RUN chown -R appuser:appuser /app
20
  USER appuser
 
21
  EXPOSE 8000
 
22
  HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
23
  CMD curl -f http://localhost:8000/health || exit 1
24
- CMD ["python", "-m", "production_server"]
 
 
1
  FROM python:3.11-slim AS builder
2
+
3
  RUN apt-get update && apt-get install -y --no-install-recommends \
4
+ gcc libpq-dev curl && rm -rf /var/lib/apt/lists/*
5
+
6
+ # Install uv
7
+ RUN curl -LsSf https://astral.sh/uv/install.sh | sh
8
+ ENV PATH="/root/.local/bin:$PATH"
9
+
10
+ WORKDIR /app
11
+ COPY pyproject.toml .
12
+ COPY production/ ./production/
13
+
14
+ # Sync dependencies with uv
15
+ RUN uv sync --frozen
16
 
17
  FROM python:3.11-slim AS production
18
+
19
  RUN apt-get update && apt-get install -y --no-install-recommends \
20
  libpq5 curl && rm -rf /var/lib/apt/lists/*
21
+
22
+ # Install uv in production too
23
+ RUN curl -LsSf https://astral.sh/uv/install.sh | sh
24
+ ENV PATH="/root/.local/bin:$PATH"
25
+
26
  RUN useradd --create-home --shell /bin/bash appuser
27
+
28
  WORKDIR /app
29
+ COPY --from=builder /app/.venv /app/.venv
30
+ COPY --chown=appuser:appuser production/ ./production/
31
+ COPY --chown=appuser:appuser pyproject.toml .
32
+
33
+ ENV PATH="/app/.venv/bin:$PATH"
34
+ ENV PYTHONPATH="/app"
35
+
36
  RUN chown -R appuser:appuser /app
37
  USER appuser
38
+
39
  EXPOSE 8000
40
+
41
  HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
42
  CMD curl -f http://localhost:8000/health || exit 1
43
+
44
+ CMD ["uvicorn", "production.production_server:app", "--host", "0.0.0.0", "--port", "8000"]