Skip to content

Commit

Permalink
github to docker build
Browse files Browse the repository at this point in the history
  • Loading branch information
simoneponcioni committed May 22, 2024
1 parent 624d9cd commit 45f615a
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 16 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Build Docker Container

on:
push:
branches:
- main
- master

jobs:
docker:
runs-on: ubuntu-latest
steps:
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
-
name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build and push
uses: docker/build-push-action@v4
with:
push: true
tags: simoneponcioni/hfe_development:latest
41 changes: 25 additions & 16 deletions 02_CODE/Dockerfile.ubuntu24.04
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,42 @@ FROM ubuntu:24.04

ENV DEBIAN_FRONTEND noninteractive

# Set GitHub username and personal access token
ARG GITHUB_USERNAME
ARG GITHUB_TOKEN
ARG USER_UID=1000
ARG USER_GID=1000

# RUN apt-get update && apt-get install -y wget git apt-utils git cmake gcc g++ gfortran python3 python3-numpy python3-scipy python3-pip swig clang-tidy emacs-nox valgrind texlive texlive-latex-recommended texlive-latex-extra texinfo libreoffice fonts-cmu libpetsc-complex-dev libslepc-complex3.19-dev python3-dev libopenblas-dev libfltk1.3-dev libfreetype6-dev libgl1-mesa-dev libxi-dev libxmu-dev mesa-common-dev tcl-dev tk-dev libhdf5-dev libcgns-dev libxft-dev libxinerama-dev libxcursor-dev libxfixes-dev libocct-foundation-dev libocct-data-exchange-dev libocct-ocaf-dev libopenmpi-dev libboost-dev cargo clang gcovr ftp libgl1-mesa-dri && apt-get clean
RUN apt-get update && apt-get install -y wget git apt-utils git cmake gcc g++ gfortran python3-pip swig clang-tidy emacs-nox valgrind fonts-cmu libpetsc-complex-dev libslepc-complex3.19-dev libopenblas-dev libfltk1.3-dev libfreetype6-dev libgl1-mesa-dev libxi-dev libxmu-dev mesa-common-dev tcl-dev tk-dev libhdf5-dev libcgns-dev libxft-dev libxinerama-dev libxcursor-dev libxfixes-dev libocct-foundation-dev libocct-data-exchange-dev libocct-ocaf-dev libopenmpi-dev libboost-dev cargo clang gcovr ftp libgl1-mesa-dri && apt-get clean
RUN apt-get update && apt-get install -y \
apt-utils cargo clang clang-tidy cmake \
emacs-nox fonts-cmu ftp gcc gcovr \
git g++ gfortran libboost-dev libcgns-dev \
libfltk1.3-dev libfreetype6-dev libgl1-mesa-dev libgl1-mesa-dri libhdf5-dev \
libocct-data-exchange-dev libocct-foundation-dev libocct-ocaf-dev libopenblas-dev libopenmpi-dev \
libpetsc-complex-dev libxfixes-dev libxcursor-dev libxft-dev libxi-dev \
libxinerama-dev libxmu-dev libslepc-complex3.19-dev mesa-common-dev python3-pip \
swig tcl-dev tk-dev valgrind wget \
&& apt-get clean

# Install miniconda
RUN wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda.sh && \
bash ~/miniconda.sh -b -p /opt/miniconda && \
rm ~/miniconda.sh
bash ~/miniconda.sh -b -p /opt/miniconda && rm ~/miniconda.sh
ENV PATH="/opt/miniconda/bin:$PATH"

# Create a conda environment
RUN conda create -n hfe-essentials python=3.12
SHELL ["conda", "run", "-n", "hfe-essentials", "/bin/bash", "-c"]
# Copy hfe requirements.txt and install requirements
COPY ./requirements.txt .
RUN pip install -r requirements.txt
RUN pip install --no-cache-dir -r requirements.txt
RUN pip install -U scikit-image
RUN pip install imutils

# Install the meshing package
RUN git clone https://${GITHUB_USERNAME}:${GITHUB_TOKEN}@github.com/artorg-unibe-ch/spline_mesher.git ./pyhexspline/spline_mesher
WORKDIR ./pyhexspline/spline_mesher
RUN pip install -e .
# Set GitHub username and personal access token
ARG GITHUB_USERNAME
ARG GITHUB_TOKEN
ARG USER_UID=1000
ARG USER_GID=1000

# Install the meshing package # TODO: reactivate when github action is cloning from public repo
# RUN git clone https://${GITHUB_USERNAME}:${GITHUB_TOKEN}@github.com/artorg-unibe-ch/spline_mesher.git ./pyhexspline/spline_mesher
# WORKDIR ./pyhexspline/spline_mesher
# RUN pip install -e .

# Change ownership of the conda environment to the hfe user
RUN useradd -ms /bin/bash hfe
Expand All @@ -43,6 +51,7 @@ ENV PATH="/opt/cargo/bin:${PATH}"

# conda init, source .bashrc, conda activate
RUN conda init bash
RUN echo "conda activate hfe-essentials" >> ~/.bashrc
RUN echo "source ~/.bashrc" >> ~/.bash_profile
RUN echo "conda activate hfe-essentials" >> ~/.bash_profile
CMD ["/bin/bash", "-c", "source ~/.bashrc && conda activate hfe-essentials && exec /bin/bash"]

# https://pythonspeed.com/articles/activate-conda-dockerfile/
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,9 @@ This will start a Docker container with the built image and open an interactive
Once you're inside the Docker container, you can run the project. The exact command depends on how your project is structured, but it will generally look something like this:

```sh
conda init
source .bashrc
conda activate hfe-essentials
cd 02_CODE
python src/pipeline_runner.py
```

0 comments on commit 45f615a

Please sign in to comment.