-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathDockerfile
More file actions
67 lines (52 loc) · 1.53 KB
/
Dockerfile
File metadata and controls
67 lines (52 loc) · 1.53 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
FROM python:3.10-slim
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y \
gcc \
g++ \
python3-dev \
build-essential \
git \
&& rm -rf /var/lib/apt/lists/*
# Copy requirements first for better caching
COPY requirements.txt .
# Install tgcrypto and gunicorn separately first
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir tgcrypto gunicorn
# Install other dependencies
RUN pip install --no-cache-dir -r requirements.txt
# Copy all files
COPY . .
# Create directory for session files
RUN mkdir -p /app/sessions
# Set environment variables
ENV PORT=8080
ENV PYTHONUNBUFFERED=1
# Health check configuration
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
CMD curl -f http://localhost:${PORT}/health || exit 1
# Expose port (using PORT env var from Render)
EXPOSE ${PORT}
# Set production environment
ENV FLASK_ENV=production
# Create log directory
RUN mkdir -p /app/logs
# Create entrypoint script
RUN echo '#!/bin/sh\n\
trap "exit" TERM\n\
python bot.py & BOT_PID=$!\n\
gunicorn --bind 0.0.0.0:${PORT} \
--worker-class=gthread \
--workers 2 \
--threads 4 \
--timeout 60 \
--log-level=info \
--access-logfile=/app/logs/access.log \
--error-logfile=/app/logs/error.log \
webapp:app & GUNICORN_PID=$!\n\
wait $BOT_PID $GUNICORN_PID' > /app/entrypoint.sh && \
chmod +x /app/entrypoint.sh
# Set the entrypoint
ENTRYPOINT ["/app/entrypoint.sh"]
# Run both the bot and webapp
CMD ["/app/entrypoint.sh"]