-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
85 lines (66 loc) · 2.17 KB
/
Dockerfile
File metadata and controls
85 lines (66 loc) · 2.17 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# Enhanced Dockerfile for SharePoint AI Assistant
# Multi-stage build for optimized production image
# Build stage
FROM python:3.11-slim as builder
# Set build arguments
ARG BUILD_DATE
ARG VERSION=1.0.0
ARG VCS_REF
# Add metadata
LABEL maintainer="SharePoint AI Assistant Team" \
version="${VERSION}" \
description="Enhanced SharePoint AI Assistant with comprehensive error handling" \
build-date="${BUILD_DATE}" \
vcs-ref="${VCS_REF}"
# Set environment variables for build
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1
# Install system dependencies
RUN apt-get update && apt-get install -y \
build-essential \
curl \
&& rm -rf /var/lib/apt/lists/*
# Create virtual environment
RUN python -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
# Copy requirements and install Python dependencies
COPY requirements/base.txt /tmp/requirements.txt
RUN pip install --upgrade pip setuptools wheel && \
pip install -r /tmp/requirements.txt
# Production stage
FROM python:3.11-slim as production
# Set environment variables
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PATH="/opt/venv/bin:$PATH" \
STREAMLIT_SERVER_PORT=8501 \
STREAMLIT_SERVER_ADDRESS=0.0.0.0 \
STREAMLIT_SERVER_HEADLESS=true \
STREAMLIT_BROWSER_GATHER_USAGE_STATS=false
# Install runtime dependencies
RUN apt-get update && apt-get install -y \
curl \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
# Copy virtual environment from builder stage
COPY --from=builder /opt/venv /opt/venv
# Create non-root user for security
RUN groupadd -r appuser && useradd -r -g appuser appuser
# Create application directory
WORKDIR /app
# Copy application code
COPY --chown=appuser:appuser . .
# Create necessary directories
RUN mkdir -p /app/logs /app/data && \
chown -R appuser:appuser /app
# Switch to non-root user
USER appuser
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://localhost:8501/_stcore/health || exit 1
# Expose port
EXPOSE 8501
# Default command
CMD ["streamlit", "run", "main.py", "--server.port=8501", "--server.address=0.0.0.0"]