diff --git a/.dockerignore b/.dockerignore index 509bf7f..31eaa11 100644 --- a/.dockerignore +++ b/.dockerignore @@ -10,7 +10,7 @@ **/.classpath **/.dockerignore **/.env -# **/.git +#**/.git **/.gitignore **/.project **/.settings @@ -32,4 +32,13 @@ **/values.dev.yaml LICENSE README.md -*.sif \ No newline at end of file + + +# Some more specfic things +**/.github +**/.ruff_cache +**/*.def +**/*.sif +**/*.egg-info +build +examples \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 4a209b7..42e6949 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,60 +1,34 @@ -FROM jupyter/minimal-notebook AS base +FROM python:3.12-slim-bookworm AS base -# Install gammapy -RUN mamba install gcc jupyterlab "gammapy==1.2" ipykernel --yes -WORKDIR /gammapy-tools +RUN apt update && \ + apt upgrade -y && \ + apt install git curl bash wget gcc -y -# Clone V2DL3 -WORKDIR /gammapy-tools -RUN git clone https://github.com/VERITAS-Observatory/V2DL3.git -WORKDIR /gammapy-tools/V2DL3 +RUN python3 -m venv /opt/gammapy_tools && \ + . /opt/gammapy_tools/bin/activate && \ + pip install --no-cache iminuit cmasher pip papermill matplotlib \ + uproot "jupyterlab==4.0.12" notebook ipykernel ipython ipywidgets "gammapy==1.3" + +RUN mkdir /gamma-tools && cd /gamma-tools && \ + git clone --depth 1 --branch v0.6.0 https://github.com/VERITAS-Observatory/V2DL3.git && \ + cd V2DL3 && \ + grep -A 100 "dependencies:" environment-eventdisplay.yml | grep "-" | grep -v "python" | awk '{print $2}' | xargs pip install && \ + mv setup.py _setup.py && grep -v "root_numpy" _setup.py > setup.py && pip install . && \ + cd /gamma-tools/ && rm -r /gamma-tools/V2DL3 -# Because its an env install of requirements -# Note the python version in the latest test throws issues with pytest -RUN grep -A 100 "dependencies:" environment-eventdisplay.yml | grep "-" | grep -v "python" | awk '{print $2}' | xargs mamba install --yes +WORKDIR /gamma-tools/ +RUN /opt/gammapy_tools/bin/gammapy download datasets -# root_numpy throws issues too. Only VEGAS uses it -RUN mv setup.py _setup.py && grep -v "root_numpy" _setup.py > setup.py && pip install . +COPY . /gamma-tools/tmp_build +RUN cd /gamma-tools/tmp_build ; pip install . ; cd /gamma-tools ; rm -r /gamma-tools/tmp_build && \ + python -m pip cache purge -# Final product -FROM jupyter/minimal-notebook AS final +# FROM python:3.12-slim-bookworm AS final -# Copy across the conda/mamba install -COPY --from=base /opt/conda /opt/conda +# COPY --from=base /opt/gammapy_tools /opt/gammapy_tools +# COPY --from=base /gamma-tools /gamma-tools -# Contents of repo -WORKDIR /gammapy-tools/tmp_build - -# RUN gammapy download datasets -ENV GAMMAPY_DATA=/gammapy-tools/gammapy-datasets/1.2/ -RUN mkdir -p $GAMMAPY_DATA -WORKDIR /gammapy-tools/ -RUN gammapy download datasets - -# Add package -ADD --chown=1000:100 . /gammapy-tools/tmp_build/gammapy-tools -WORKDIR /gammapy-tools/tmp_build/gammapy-tools - - - -# RUN ls -lah -RUN pip install . -# RUN ./gammapy_tools/Hipparcos_MAG8_1997.dat $GAMMAPY_DATA/catalogs/ -RUN cp /opt/conda/lib/python3.11/site-packages/gammapy_tools/Hipparcos_MAG8_1997.dat $GAMMAPY_DATA/ -RUN wget https://raw.githubusercontent.com/gammapy/gammapy/main/gammapy/datasets/map.py -O /opt/conda/lib/python3.11/site-packages/gammapy/datasets/map.py - - -USER root -RUN mkdir /local_data - -# Clean up -RUN rm -r /gammapy-tools/tmp_build -USER jovyan -RUN mamba clean -a --yes -WORKDIR /local_data - -# Keep alive for Docker ipykernel usage -RUN echo -e "#!/bin/bash\nwhile true; do sleep 5; done" >> /gammapy-tools/keep_alive.sh ; chmod a+x /gammapy-tools/keep_alive.sh -CMD ["/gammapy-tools/keep_alive.sh"] \ No newline at end of file +# ENV JPORT=8000 +# ENV GAMMAPY_DATA=/gamma-tools/gammapy-datasets/1.3/ \ No newline at end of file diff --git a/Dockerfile_back b/Dockerfile_back new file mode 100644 index 0000000..76e9c04 --- /dev/null +++ b/Dockerfile_back @@ -0,0 +1,55 @@ +FROM jupyter/minimal-notebook AS base + +# Install gammapy +RUN mamba install gcc jupyterlab "gammapy==1.3" ipykernel --yes +WORKDIR /gammapy-tools + + +# Clone V2DL3 +WORKDIR /gammapy-tools +RUN git clone --depth 1 --branch v0.6.0 https://github.com/VERITAS-Observatory/V2DL3.git && \ + cd /gammapy-tools/V2DL3 && \ +# Because its an env install of requirements +# Note the python version in the latest test throws issues with pytest + grep -A 100 "dependencies:" environment-eventdisplay.yml | grep "-" | grep -v "python" | awk '{print $2}' | xargs mamba install --yes && \ +# root_numpy throws issues too. Only VEGAS uses it + mv setup.py _setup.py && grep -v "root_numpy" _setup.py > setup.py && pip install . + + +# Final product +FROM jupyter/minimal-notebook AS final + +# Copy across the conda/mamba install +COPY --from=base /opt/conda /opt/conda + +# Contents of repo +WORKDIR /gammapy-tools/tmp_build + +# RUN gammapy download datasets +ENV GAMMAPY_DATA=/gammapy-tools/gammapy-datasets/1.3/ +RUN mkdir -p $GAMMAPY_DATA +WORKDIR /gammapy-tools/ +RUN gammapy download datasets + +# Add package +ADD --chown=1000:100 . /gammapy-tools/tmp_build/gammapy-tools +WORKDIR /gammapy-tools/tmp_build/gammapy-tools + + + +# RUN ls -lah +RUN pip install . && \ +# RUN ./gammapy_tools/Hipparcos_MAG8_1997.dat $GAMMAPY_DATA/catalogs/ + cp /opt/conda/lib/python3.11/site-packages/gammapy_tools/Hipparcos_MAG8_1997.dat $GAMMAPY_DATA/ + + +USER root +RUN rm -r /gammapy-tools/tmp_build +# Clean up +USER jovyan +RUN mamba clean -a --yes +WORKDIR /local_data + +# Keep alive for Docker ipykernel usage +RUN echo -e "#!/bin/bash\nwhile true; do sleep 5; done" >> /gammapy-tools/keep_alive.sh ; chmod a+x /gammapy-tools/keep_alive.sh +CMD ["/gammapy-tools/keep_alive.sh"] \ No newline at end of file