-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
38 lines (29 loc) · 1.1 KB
/
Dockerfile
File metadata and controls
38 lines (29 loc) · 1.1 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
FROM python:3.11-slim
# Set working directory
WORKDIR /app
# Set environment variables for Python optimization and virtual env isolation
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
# Install system dependencies required for WebPush/Cryptography and PostgreSQL
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc \
libffi-dev \
libpq-dev \
&& rm -rf /var/lib/apt/lists/*
# Install python dependencies. We use Gunicorn with Eventlet for Socket.IO support
COPY requirements.txt /app/
RUN pip install --upgrade pip && \
pip install --no-cache-dir -r requirements.txt && \
pip install --no-cache-dir gunicorn eventlet
# Ensure the database instance and upload directories exist
RUN mkdir -p /app/instance
RUN mkdir -p /app/app/static/uploads
# Copy application files
COPY . /app/
# Expose port
EXPOSE 5000
# Set environment variable defaults
ENV FLASK_APP=run.py
ENV FLASK_ENV=production
# Run migrations and start the server using gunicorn with eventlet worker
CMD ["sh", "-c", "flask db upgrade && gunicorn --worker-class eventlet -w 1 --bind 0.0.0.0:5000 run:app"]