FROM python:3.11.4-slim-buster

# Install PostgreSQL development libraries
RUN apt-get update && apt-get install -y libpq-dev gcc

# python related environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

WORKDIR /app

# install python dependencies
COPY requirements.txt /app/
RUN pip install --upgrade pip
RUN pip install --no-cache-dir -r requirements.txt

# setup entrypoint file
COPY scripts/entrypoint.sh /app/scripts/
RUN chmod +x /app/scripts/entrypoint.sh

COPY . /app/

ENTRYPOINT ["/app/scripts/entrypoint.sh"]

# gunicorn
CMD ["gunicorn", "--bind", "0.0.0.0:8000", "core.wsgi:application"]
