-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
54 lines (38 loc) · 1.25 KB
/
Dockerfile
File metadata and controls
54 lines (38 loc) · 1.25 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
# LogiBot Docker Image
# Multi-stage build for optimized production image
FROM python:3.11-slim as builder
# Set working directory
WORKDIR /app
# Install build dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc \
&& rm -rf /var/lib/apt/lists/*
# Copy requirements
COPY requirements.txt .
# Install Python dependencies
RUN pip install --user --no-cache-dir -r requirements.txt
# Production stage
FROM python:3.11-slim
# Set working directory
WORKDIR /app
# Create non-root user
RUN useradd -m -u 1000 logibot && \
mkdir -p /app/logs && \
chown -R logibot:logibot /app
# Copy Python dependencies from builder
COPY --from=builder /root/.local /home/logibot/.local
# Copy application code
COPY --chown=logibot:logibot . .
# Set environment variables
ENV PATH=/home/logibot/.local/bin:$PATH \
PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1
# Switch to non-root user
USER logibot
# Expose webhook port
EXPOSE 8080
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD python3 -c "import requests; requests.get('http://localhost:8080/health', timeout=5)" || exit 1
# Default command
CMD ["python3", "logibot_core.py"]