FROM ubuntu:23.10

ENV DEBIAN_FRONTEND=non-interactive \
    PYTHONUNBUFFERED=1 \
    PYTHONDONTWRITEBYTECODE=1 \
    PATH="/venv/bin:$PATH" \
    NODE_MAJOR=20

WORKDIR /code

COPY ./src/ /code/src/
COPY package.json requirements.txt /code/

RUN apt-get update && \
    apt-get install -y python3 python3-venv python3-pip ca-certificates curl gnupg && \
    curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg && \
    echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list && \
    apt-get update && apt-get install -y nodejs && \
    python3 -m venv /venv && \
    pip install --upgrade pip && \
    pip install -r requirements.txt && \
    npm install tailwindcss postcss autoprefixer -g && \
    npm run build && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/*
