37 lines
1.0 KiB
Docker
37 lines
1.0 KiB
Docker
# Use a lightweight Python base image
|
|
FROM python:3.13-slim
|
|
|
|
# Set environment variables to prevent Python from writing pyc files
|
|
# and to flush stdout/stderr immediately (useful for docker logs)
|
|
ENV PYTHONDONTWRITEBYTECODE=1
|
|
ENV PYTHONUNBUFFERED=1
|
|
|
|
# Set the working directory
|
|
WORKDIR /app
|
|
|
|
RUN apt-get update && \
|
|
apt-get install -y git && \
|
|
rm -rf /var/lib/apt/lists/*
|
|
|
|
# Install dependencies first (for better caching)
|
|
COPY requirements.txt .
|
|
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
# Copy the rest of the application code
|
|
COPY . .
|
|
|
|
# Create a directory for the database mount (optional but good for clarity)
|
|
RUN mkdir -p /data
|
|
|
|
# Default environment variable for the database path inside the container
|
|
ENV DB_PATH="/data/speedtest.db"
|
|
ENV PORT=5000
|
|
|
|
# Expose the port the app runs on
|
|
EXPOSE 5000
|
|
|
|
# Run using Gunicorn
|
|
# -b 0.0.0.0:5000: Bind to all interfaces on port 5000
|
|
# --access-logfile -: Log access to stdout
|
|
CMD ["gunicorn", "--workers", "1", "--bind", "0.0.0.0:5000", "--access-logfile", "-", "app:app"]
|