Skip to content

Commit

Permalink
update docker image to use static geant4
Browse files Browse the repository at this point in the history
  • Loading branch information
lobis committed Dec 6, 2023
1 parent 5981946 commit ccb3d66
Showing 1 changed file with 34 additions and 11 deletions.
45 changes: 34 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.11-slim-bullseye
FROM python:3.11-slim-bullseye as builder

RUN apt-get update -qq && apt-get install -q -y --no-install-recommends \
build-essential ninja-build git curl libxerces-c-dev \
Expand All @@ -10,29 +10,52 @@ RUN pip install cmake

ARG CMAKE_CXX_STANDARD=23
ARG GEANT4_VERSION=v11.1.3
ARG XERCES_VERSION=v3.2.4

RUN git clone https://github.com/apache/xerces-c.git /tmp/xerces \
&& git -C /tmp/xerces checkout tags/v${XERCES_VERSION} \
&& cmake -G Ninja -B /tmp/xerces/build -S /tmp/xerces \
-DCMAKE_INSTALL_PREFIX=/opt/xerces \
-DXERCESC_ROOT_DIR=${{ github.workspace }}/xerces \
-DCMAKE_CXX_STANDARD=23 \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=OFF \
-Dnetwork-accessor=socket \
-Dtranscoder=iconv \
-DCMAKE_CXX_FLAGS=-fPIC \
-DCMAKE_C_FLAGS=-fPIC \
&& cmake --build /tmp/geant4/build -j$(nproc) --target install \
&& rm -rf /tmp/geant4 \

RUN git clone https://github.com/Geant4/geant4.git /tmp/geant4 --branch=${GEANT4_VERSION} --depth=1 \
&& cmake -G Ninja -B /tmp/geant4/build -S /tmp/geant4 \
-DCMAKE_INSTALL_PREFIX=/opt/geant4 -DCMAKE_CXX_STANDARD=$CMAKE_CXX_STANDARD -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/opt/geant4 \
-DXERCESC_ROOT_DIR=/opt/xerces \
-DCMAKE_CXX_STANDARD=23 \
-DCMAKE_BUILD_TYPE=Release \
-DGEANT4_USE_GDML=ON \
-DGEANT4_INSTALL_EXAMPLES=OFF \
-DGEANT4_INSTALL_DATA=OFF \
-DGEANT4_BUILD_TLS_MODEL=global-dynamic \
-DCMAKE_CXX_FLAGS=-fPIC \
-DCMAKE_C_FLAGS=-fPIC \
-DGEANT4_USE_SYSTEM_EXPAT=OFF \
# -DBUILD_STATIC_LIBS=ON \
# -DBUILD_SHARED_LIBS=OFF \
# -DGEANT4_BUILD_STORE_TRAJECTORY=OFF -DGEANT4_BUILD_VERBOSE_CODE=OFF \
-DBUILD_STATIC_LIBS=ON \
-DBUILD_SHARED_LIBS=OFF \
&& cmake --build /tmp/geant4/build -j$(nproc) --target install \
&& rm -rf /tmp/geant4

ENV PATH=/opt/geant4/bin:$PATH
ENV LD_LIBRARY_PATH=/opt/geant4/lib:$LD_LIBRARY_PATH

# RUN geant4-config --install-datasets

COPY . /source

# Build and install
RUN pip install /source && rm -rf /source
RUN source /opt/geant4/bin/geant4.sh \
&& pip install /source \
&& rm -rf /source

# Create the final image
FROM python:3.11-slim-bullseye

# Copy installed Python package from the builder image
COPY --from=builder /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages

ENTRYPOINT ["python"]

0 comments on commit ccb3d66

Please sign in to comment.