Skip to content

Commit

Permalink
working Docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
lobis committed Nov 29, 2023
1 parent 6123585 commit d400120
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
venv
build
*-build-*
*_cache
.github
45 changes: 45 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Build and Test

on:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
docker-image:
timeout-minutes: 30
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- uses: actions/checkout@v4

- name: Log in to the GitHub Container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.CONTAINER_REGISTRY_GITHUB_TOKEN }}

- name: Build Docker image
uses: docker/build-push-action@v3
with:
context: .
push: false
tags: |
ghcr.io/lobis/geant4:latest
labels: |
maintainer.name="Luis Antonio Obis Aparicio"
maintainer.email="luis.antonio.obis@gmail.com"
org.opencontainers.image.source="https://github.com/lobis/geant4-pythonic-application"
- name: Test image
run: |
docker run --rm ghcr.io/lobis/geant4:latest -c 'from geant4 import Application; Application().setup_manager()'
- name: Publish
run: docker push ghcr.io/lobis/geant4:latest
File renamed without changes.
25 changes: 21 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM ubuntu:latest

# Install dependencies and upgrade
RUN apt-get update && apt-get install -y \
build-essential bzip2 ca-certificates curl mesa-common-dev libglu1-mesa-dev python3-dev \
build-essential bzip2 ca-certificates curl git mesa-common-dev libglu1-mesa-dev python3-dev \
&& apt-get upgrade -y \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
Expand All @@ -20,7 +20,24 @@ RUN curl -o miniconda_installer.sh https://repo.anaconda.com/miniconda/Miniconda
RUN /opt/conda/bin/mamba install -y -c conda-forge cmake geant4 \
&& /opt/conda/bin/conda clean -ya

SHELL [ "/bin/bash", "-c" ]
# Copy files
COPY . /source

# Set python as the entrypoint
ENTRYPOINT [ "/opt/conda/bin/python3" ]
# Build and install
RUN cd /source/application \
&& mkdir build \
&& cd build \
&& /opt/conda/bin/cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=/opt/conda -DCMAKE_INSTALL_PREFIX=/opt/conda \
&& make -j$(nproc) \
&& make install \
&& cd /source \
&& /opt/conda/bin/pip install . \
&& rm -rf /source

ENV PYTHONPATH=/opt/conda/lib:${PYTHONPATH}

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

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

0 comments on commit d400120

Please sign in to comment.