33 lines
No EOL
752 B
Docker
33 lines
No EOL
752 B
Docker
# Use Python 3.9 slim image
|
|
FROM python:3.9-slim
|
|
|
|
# Set working directory
|
|
WORKDIR /app
|
|
|
|
# Set environment variables
|
|
ENV PYTHONDONTWRITEBYTECODE 1
|
|
ENV PYTHONUNBUFFERED 1
|
|
ENV FLASK_APP app
|
|
ENV FLASK_ENV production
|
|
|
|
# Install dependencies
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
gcc \
|
|
libpq-dev \
|
|
&& apt-get clean \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Install Python packages
|
|
COPY requirements.txt .
|
|
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
# Copy application code
|
|
COPY . .
|
|
|
|
# Create a non-root user to run the application
|
|
RUN adduser --disabled-password --gecos "" netviz
|
|
RUN chown -R netviz:netviz /app
|
|
USER netviz
|
|
|
|
# Run gunicorn with 4 workers
|
|
CMD gunicorn --bind 0.0.0.0:5000 --workers 4 "app:create_app()" |