-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
45 lines (35 loc) · 1.28 KB
/
Copy pathDockerfile
File metadata and controls
45 lines (35 loc) · 1.28 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
# syntax=docker/dockerfile:1
FROM python:3.12-slim as builder
# Install build dependencies for C++ pybind11 extension
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
cmake \
git \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY requirements.txt .
RUN pip wheel --no-cache-dir --no-deps --wheel-dir /app/wheels -r requirements.txt
# Copy source code and build the C++ extension
COPY . .
RUN pip install setuptools pybind11
RUN python setup.py build_ext --inplace
# Runner Image
FROM python:3.12-slim
# Create non-root user
RUN groupadd -r apexflow && useradd -r -g apexflow -d /app apexflow
WORKDIR /app
COPY --from=builder /app/wheels /wheels
COPY --from=builder /app/requirements.txt .
RUN pip install --no-cache-dir --no-index --find-links=/wheels -r requirements.txt
RUN pip install --no-cache-dir streamlit prometheus_client
# Copy the built extension and source
COPY --from=builder /app/apexflow_cpp*.so /app/
COPY --from=builder /app/src /app/src
COPY --from=builder /app/scripts /app/scripts
# Set permissions
RUN chown -R apexflow:apexflow /app
USER apexflow
ENV PYTHONPATH=/app/src:/app
ENV APEXFLOW_ENV=production
EXPOSE 8501 9090
CMD ["streamlit", "run", "src/apexflow/ui/app.py", "--server.port=8501", "--server.address=0.0.0.0"]