Last active 1730123829

Pour LKA

mathieu revised this gist 1730123829. Go to revision

1 file changed, 0 insertions, 0 deletions

gistfile1.txt renamed to Dockerfile

File renamed without changes

mathieu revised this gist 1730123804. Go to revision

1 file changed, 49 insertions

gistfile1.txt(file created)

@@ -0,0 +1,49 @@
1 + # Build stage
2 + FROM python:3.12-slim as builder
3 +
4 + # Install build dependencies
5 + RUN 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
10 + RUN python -m venv /opt/venv
11 + ENV PATH="/opt/venv/bin:$PATH"
12 +
13 + # Copy and install requirements
14 + COPY requirements.txt .
15 + RUN pip install --no-cache-dir -r requirements.txt
16 +
17 + # Final stage
18 + FROM python:3.12-slim
19 +
20 + # Copy virtual environment from builder
21 + COPY --from=builder /opt/venv /opt/venv
22 + ENV PATH="/opt/venv/bin:$PATH"
23 +
24 + # Create a non-root user
25 + RUN useradd -m -u 1000 appuser
26 +
27 + # Set working directory
28 + WORKDIR /app
29 +
30 + # Copy only necessary files
31 + COPY --chown=appuser:appuser main.py .
32 + COPY --chown=appuser:appuser config ./config/
33 + COPY --chown=appuser:appuser entrypoint.sh .
34 +
35 + # Create necessary directories
36 + RUN 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 +
43 + RUN apt-get clean && \
44 + rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
45 +
46 + # Expose port
47 + EXPOSE 8501
48 +
49 + ENTRYPOINT ["./entrypoint.sh"]
Newer Older