Last active 1730123829

Pour LKA

Dockerfile Raw
1# Build stage
2FROM python:3.12-slim as builder
3
4# Install build dependencies
5RUN apt-get update && apt-get install -y --no-install-recommends \
6 build-essential \
7 && rm -rf /var/lib/apt/lists/*
8
9# Create and activate virtual environment
10RUN python -m venv /opt/venv
11ENV PATH="/opt/venv/bin:$PATH"
12
13# Copy and install requirements
14COPY requirements.txt .
15RUN pip install --no-cache-dir -r requirements.txt
16
17# Final stage
18FROM python:3.12-slim
19
20# Copy virtual environment from builder
21COPY --from=builder /opt/venv /opt/venv
22ENV PATH="/opt/venv/bin:$PATH"
23
24# Create a non-root user
25RUN useradd -m -u 1000 appuser
26
27# Set working directory
28WORKDIR /app
29
30# Copy only necessary files
31COPY --chown=appuser:appuser main.py .
32COPY --chown=appuser:appuser config ./config/
33COPY --chown=appuser:appuser entrypoint.sh .
34
35# Create necessary directories
36RUN mkdir -p /app/data /app/storage /app/config && \
37 chown -R appuser:appuser /app && \
38 mkdir -p /app/default_config && \
39 cp /app/config/* /app/default_config/ && \
40 chown -R appuser:appuser /app/default_config && \
41 chmod +x entrypoint.sh
42
43RUN apt-get clean && \
44 rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
45
46# Expose port
47EXPOSE 8501
48
49ENTRYPOINT ["./entrypoint.sh"]