FROM tsys-aios-gis-tools-weather-base:latest

# Avoid prompts from apt
ENV DEBIAN_FRONTEND=noninteractive

# Install additional analysis tools
RUN apt-get update && apt-get install -y \
    jupyter-notebook \
    nodejs \
    npm \
    octave \
    && rm -rf /var/lib/apt/lists/*

# Install additional Python libraries for weather analysis
RUN pip3 install --break-system-packages \
    jupyter \
    notebook \
    ipykernel \
    apache-airflow \
    prefect \
    folium \
    plotly \
    cartopy \
    geoviews

# Install additional R packages for weather analysis
RUN R --slave -e "install.packages(c('lubridate', 'ggplot2', 'dplyr', 'tidyr', 'forecast', 'RColorBrewer'), repos='https://cran.rstudio.com/', dependencies=TRUE)"

# Set up Jupyter
RUN jupyter notebook --generate-config --allow-root --ip=0.0.0.0 --port=8888 --no-browser --notebook-dir=/workspace --NotebookApp.token='' --NotebookApp.password='' 2>/dev/null || true

# Create a working directory
WORKDIR /workspace

# Add entrypoint script
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

# Use the entrypoint script to handle user creation
ENTRYPOINT ["/entrypoint.sh"]