CroppAndWeedD / Dockerfile
MrTechie's picture
Updated Dockerfile
56aba29
Raw History Blame Contribute Delete
1.1 kB
# Use a lightweight Python image
FROM python:3.9
# Install system dependencies required for OpenCV (libGL.so.1)
RUN apt-get update && apt-get install -y libgl1-mesa-glx
# Set environment variables so that configuration and cache directories are writable.
# MPLCONFIGDIR: For Matplotlib to write its configuration cache.
# YOLO_CONFIG_DIR: For Ultralytics YOLO to store its settings.
# XDG_CACHE_HOME: A fallback cache home used by Fontconfig and other libraries.
ENV MPLCONFIGDIR=/tmp/matplotlib
ENV YOLO_CONFIG_DIR=/tmp/ultralytics
ENV XDG_CACHE_HOME=/tmp
# Set the working directory
WORKDIR /app
# Copy the requirements and install dependencies
COPY requirements.txt /app/
RUN pip install -r requirements.txt
# Copy the Django app files
COPY . /app/
# Ensure the database directory is writable
RUN mkdir -p /app/db && chmod 777 /app/db
# Expose the default Django port
EXPOSE 8000
# Run migrations and start Django application using Gunicorn
CMD ["sh", "-c", "python manage.py makemigrations && python manage.py migrate && gunicorn Crop_and_Weed_Detector.wsgi:application --bind 0.0.0.0:8000"]