# Use a Debian release that is supported by the Microsoft SQL Server ODBC repo.
FROM python:3.10-slim-bookworm
ENV PYTHONUNBUFFERED=1


# Install system dependencies for MS SQL ODBC (comment out if not using MSSQL)
# Install system dependencies for MS SQL ODBC and command-line tools
RUN apt-get update && apt-get install -y curl gnupg apt-transport-https ca-certificates \
    && curl -fsSL https://packages.microsoft.com/keys/microsoft.asc \
       | gpg --dearmor -o /usr/share/keyrings/microsoft-prod.gpg \
    && echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/microsoft-prod.gpg] https://packages.microsoft.com/debian/12/prod bookworm main" \
       > /etc/apt/sources.list.d/mssql-release.list \
    && apt-get update && ACCEPT_EULA=Y apt-get install -y msodbcsql18 mssql-tools18 unixodbc-dev \
    && echo 'export PATH="$PATH:/opt/mssql-tools18/bin"' >> ~/.bashrc \
    && apt-get clean && rm -rf /var/lib/apt/lists/*

RUN curl -fsSL https://deb.nodesource.com/setup_16.x | bash - \
    && apt-get install -y nodejs \
    && npm install -g yarn
# Set the working directory
WORKDIR /app

# Copy requirements and install Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Copy the Django project (app/ folder) into the container
COPY app/ /app/

# Expose Django's default port
EXPOSE 8000

# Default command: run Django's development server
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]
