-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(dockerfile): testing smaller docker build
- Loading branch information
Showing
3 changed files
with
91 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"] | ||
# ENV JPORT=8000 | ||
# ENV GAMMAPY_DATA=/gamma-tools/gammapy-datasets/1.3/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"] |