-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
67 lines (51 loc) · 1.63 KB
/
Dockerfile
File metadata and controls
67 lines (51 loc) · 1.63 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# Stage 1: Build frontend
FROM node:20-slim AS frontend-build
WORKDIR /frontend
COPY frontend/package.json frontend/package-lock.json ./
RUN npm ci --no-audit --no-fund
COPY frontend/ .
RUN npm run build
# Stage 2: Backend
FROM python:3.11-slim AS backend
# Prevent Python from writing .pyc files and enable unbuffered output
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1
WORKDIR /app
# Install system dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \
curl \
libpq-dev \
gcc \
&& rm -rf /var/lib/apt/lists/*
# Install Python dependencies first for better layer caching
COPY pyproject.toml .
RUN pip install --no-cache-dir -e . && \
pip install --no-cache-dir \
google-genai \
python-multipart \
slack-sdk \
celery[redis] \
python-jose[cryptography] \
alembic \
asyncpg \
psycopg2-binary
# Copy application source
COPY src/ src/
COPY alembic/ alembic/
COPY alembic.ini .
# Copy frontend build from stage 1
COPY --from=frontend-build /frontend/dist src/dashboard/
# Remove gcc after pip install (no longer needed)
RUN apt-get purge -y gcc && \
apt-get autoremove -y && \
rm -rf /var/lib/apt/lists/*
# Create non-root user
RUN groupadd --gid 1001 opslens && \
useradd --uid 1001 --gid opslens --shell /bin/bash --create-home opslens && \
chown -R opslens:opslens /app
USER opslens
HEALTHCHECK --interval=30s --timeout=10s --start-period=15s --retries=3 \
CMD curl -sf http://localhost:8000/healthz || exit 1
EXPOSE 8000
CMD ["uvicorn", "src.main:app", "--host", "0.0.0.0", "--port", "8000"]