forked from nlweb-ai/NLWeb
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
56 lines (42 loc) · 1.4 KB
/
Dockerfile
File metadata and controls
56 lines (42 loc) · 1.4 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
# Stage 1: Build stage
FROM python:3.13-slim AS builder
# Install build dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends gcc python3-dev && \
pip install --no-cache-dir --upgrade pip && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy requirements file
COPY code/python/requirements.txt .
# Install Python packages
RUN pip install --no-cache-dir -r requirements.txt
# Stage 2: Runtime stage
FROM python:3.13-slim
# Apply security updates
RUN apt-get update && \
apt-get install -y --no-install-recommends --only-upgrade \
$(apt-get --just-print upgrade | grep "^Inst" | grep -i securi | awk '{print $2}') && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Create a non-root user and set permissions
RUN groupadd -r nlweb && \
useradd -r -g nlweb -d /app -s /bin/bash nlweb && \
chown -R nlweb:nlweb /app
USER nlweb
# Copy application code
COPY code/ /app/
COPY static/ /app/static/
# Copy installed packages from builder stage
COPY --from=builder /usr/local/lib/python3.13/site-packages /usr/local/lib/python3.13/site-packages
COPY --from=builder /usr/local/bin /usr/local/bin
# Expose the port the app runs on
EXPOSE 8000
# Set environment variables
ENV NLWEB_OUTPUT_DIR=/app
ENV PYTHONPATH=/app
ENV PORT=8000
ENV NLWEB_CONFIG_DIR=/app/config
# Command to run the application
CMD ["python", "python/app-file.py"]