-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathDockerfile
More file actions
66 lines (53 loc) · 2.2 KB
/
Dockerfile
File metadata and controls
66 lines (53 loc) · 2.2 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
# Single-stage Dockerfile using slim Python base
FROM python:3.11-slim
# Environment variables
ENV DEBIAN_FRONTEND=noninteractive \
PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1 \
PIP_DEFAULT_TIMEOUT=100 \
NEXT_TELEMETRY_DISABLED=1
ARG APP_ENV=production
ENV NODE_ENV=$APP_ENV
WORKDIR /app
# Install minimal tooling
RUN apt-get update && \
apt-get install -y --no-install-recommends \
ca-certificates wget curl gnupg lsb-release software-properties-common graphviz && \
rm -rf /var/lib/apt/lists/*
# Add LLVM 22 repository
RUN curl -L https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - && \
echo "deb https://apt.llvm.org/jammy/ llvm-toolchain-jammy main" >> /etc/apt/sources.list && \
apt-get update && \
apt-get -y install llvm-22-dev llvm-22-tools mlir-22-tools && \
rm -rf /var/lib/apt/lists/*
# Add Node.js 20 repository and install runtime deps
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
apt-get update && \
apt-get install -y --no-install-recommends nodejs && \
rm -rf /var/lib/apt/lists/*
# Copy application code
COPY --chown=10001:10001 . /app
# Install JS dependencies, then install 'concurrently' globally
WORKDIR /app
RUN npm install && \
npm install -g concurrently
# Create Python venv and install Python packages
RUN python3 -m venv /opt/venv && \
/opt/venv/bin/pip install --upgrade pip setuptools wheel && \
/opt/venv/bin/pip install --pre torch-mlir torchvision \
--extra-index-url=https://download.pytorch.org/whl/nightly/cpu \
-f https://github.com/llvm/torch-mlir-release/releases/expanded_assets/dev-wheels && \
/opt/venv/bin/pip install triton fastapi uvicorn pytest httpx PyPDF2
# Create non-root user and fix permissions
RUN useradd -u 10001 -m --shell /usr/sbin/nologin appuser && \
mkdir -p /home/appuser/.cache && \
chown -R appuser:appuser /home/appuser/.cache /app
USER appuser
# Update PATH for venv and LLVM
ENV PATH="/opt/venv/bin:/usr/lib/llvm-22/bin:$PATH"
# Expose ports and add healthcheck
EXPOSE 3000 8000
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s \
CMD curl -f http://localhost:8000/health || exit 1
# Default to interactive shell
CMD ["npm", "run", "start:all"]