Skip to content

Commit

Permalink
base on miniconda docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
lobis committed Dec 1, 2023
1 parent 3f1e6c6 commit adfd733
Showing 1 changed file with 20 additions and 30 deletions.
50 changes: 20 additions & 30 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,39 +1,29 @@
FROM ubuntu:latest
FROM continuumio/miniconda3:latest

# Install dependencies and upgrade
RUN apt-get update && apt-get install -y \
build-essential bzip2 ca-certificates curl git mesa-common-dev libglu1-mesa-dev python3-dev \
&& apt-get upgrade -y \
RUN apt-get update -qq && apt-get install -q -y --no-install-recommends \
build-essential libxerces-c-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

# Install miniconda and activate base on startup
ENV PATH /opt/conda/bin:/opt/conda/condabin:${PATH}
ENV CMAKE_PREFIX_PATH=/opt/conda

RUN curl -o miniconda_installer.sh https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh \
&& bash miniconda_installer.sh -b -p /opt/conda \
&& rm miniconda_installer.sh \
&& conda install -y -c conda-forge mamba \
&& mamba init bash \
&& mamba config --set auto_activate_base true \
&& mamba clean -ya

# Install conda packages (geant4 is not available for aarch64 at the time of writing)
RUN mamba install -y -c conda-forge geant4 \
# remove data package to reduce image size (we should not install them in the first place, how?)
# && mamba remove -y $(mamba list | grep 'geant4-data' | awk '{print $1}') \
# && rm -rf /opt/conda/share/Geant4/data/* \
&& mamba clean -ya

# Copy files
# Need a more recent version of cmake
RUN conda install -y cmake

ARG CMAKE_CXX_STANDARD=20
ARG GEANT4_VERSION=v11.1.3

RUN git clone https://github.com/Geant4/geant4.git /tmp/geant4 --branch=${GEANT4_VERSION} --depth=1 \
&& cmake -B /tmp/geant4/build -S /tmp/geant4 -DCMAKE_INSTALL_PREFIX=/usr/local/ -DCMAKE_CXX_STANDARD=$CMAKE_CXX_STANDARD \
-DGEANT4_INSTALL_DATA=ON -DGEANT4_USE_QT=OFF -DGEANT4_INSTALL_EXAMPLES=OFF -DGEANT4_USE_GDML=ON \
-DGEANT4_BUILD_STORE_TRAJECTORY=OFF -DGEANT4_BUILD_VERBOSE_CODE=OFF \
&& cmake --build /tmp/geant4/build -j$(nproc) --target install \
&& rm -rf /tmp/geant4

# RUN geant4-config --instal-datasets

COPY . /source

# Build and install
RUN cd source && python -m pip install .

RUN echo "#!/bin/bash\nexec /opt/conda/bin/conda run --no-capture-output -n base /opt/conda/bin/python \"\$@\"" > /usr/local/bin/entrypoint.sh \
&& chmod +x /usr/local/bin/entrypoint.sh
RUN pip install /source && rm -rf /source

# Set the entry point to the script
ENTRYPOINT [ "/usr/local/bin/entrypoint.sh" ]
ENTRYPOINT ["python"]

0 comments on commit adfd733

Please sign in to comment.