FROM python:3.8.1-slim-buster

ENV PYTHONUNBUFFERED=1

# Install system dependencies
RUN apt-get update --yes && apt-get install --yes --no-install-recommends \
    build-essential \
    libpq-dev \
    libjpeg62-turbo-dev \
    zlib1g-dev \
    libwebp-dev \
    gettext \
 && rm -rf /var/lib/apt/lists/*

# Add and set up the working directory
WORKDIR /app

# Copy requirements file and install dependencies
COPY requirements.txt /app/
RUN pip install --upgrade pip \
    && pip install -r /app/requirements.txt

# Copy application code
COPY . /app/

# Collect static files
RUN python manage.py collectstatic --noinput --clear

# Expose the port the app runs on
EXPOSE 8000

# Run the application server
CMD ["gunicorn", "--bind", "0.0.0.0:8000", "saburly.wsgi:application"]