Skip to content

Commit

Permalink
[build] Add GitHub Actions workflow for Docker images (#66)
Browse files Browse the repository at this point in the history
* Add GitHub Actions workflow for Docker images
* Batch Dependabot updates
* Make python3 default by installing python-is-python3
* update nodejs installation and silence w90 wget/tar
* Install Python dependencies via APT
* Backport linkify-it-py

---------

Co-authored-by: Alexander Hampel <[email protected]>
  • Loading branch information
hmenke and the-hampel committed Jan 11, 2024
1 parent 2e14b41 commit 506519a
Show file tree
Hide file tree
Showing 8 changed files with 310 additions and 255 deletions.
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
groups:
batch:
patterns:
- "*"
57 changes: 57 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Create and publish Docker images

on:
push: { branches: [ unstable ] }
pull_request: { branches: [ unstable ] }
workflow_call:
workflow_dispatch:

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

strategy:
fail-fast: false
matrix:
include:
- name: github_ci
- name: openmpi

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Docker buildx
uses: docker/setup-buildx-action@v3

- name: Log in to the Container registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}_${{ matrix.name }}

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: ./Docker
file: ./Docker/${{ matrix.name }}_dockerfile
build-args: |
NCORES=2
# cache pkgs layer in dockerfile
no-cache-filters: pkgs
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha,scope=${{ github.ref_name }}-${{ matrix.name }}
cache-to: type=gha,mode=max,scope=${{ github.ref_name }}-${{ matrix.name }}
94 changes: 53 additions & 41 deletions Docker/github_ci_dockerfile
Original file line number Diff line number Diff line change
@@ -1,66 +1,78 @@
FROM ubuntu:22.04
FROM ubuntu:22.04 AS base

RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
build-essential \
ca-certificates \
cmake \
curl \
cython3 \
debhelper \
dh-python \
g++-12 \
gfortran-12 \
git \
hdf5-tools \
liblapack-dev \
libboost-dev \
libfftw3-dev \
libnfft3-dev \
libgfortran5 \
libgmp-dev \
libhdf5-dev \
liblapack-dev \
libnfft3-dev \
libomp-dev \
libopenmpi-dev \
cython3 \
libpython3-dev \
openmpi-bin \
openmpi-common \
openmpi-doc \
openssl \
pandoc \
python-is-python3 \
python3-ase \
python3-decorator \
python3-dev \
python3-jinja2 \
python3-mako \
python3-numpy \
python3-scipy \
python3-matplotlib \
python3-monty \
python3-mpi4py \
python3-pip \
python3-sphinx \
python3-myst-parser \
python3-nbsphinx \
python3-skimage \
python3-notebook \
libpython3-dev \
curl \
ca-certificates \
openssl \
wget \
python3-numpy \
python3-pip \
python3-pytest \
python3-scipy \
python3-shapely \
python3-skimage \
python3-sphinx \
python3-sphinx-rtd-theme \
rsync \
libomp-dev \
sudo \
nodejs \
npm \
&& \
apt-get autoremove --purge -y && \
apt-get autoclean -y && \
rm -rf /var/cache/apt/* /var/lib/apt/lists/*

RUN pip3 install --no-cache-dir \
cython \
decorator \
pytest \
shapely \
monty \
mpi4py \
Jinja2 \
Mako \
ase \
tornado \
zmq \
tk \
myst_parser \
sphinx_rtd_theme \
linkify-it-py \
Pandoc

# linkify-it-py (required by sphinx doc build) is not available in Ubuntu 22.04 as package
# the following manually installs it and its only dependency uc-micro-py
RUN mkdir -p /src && cd /src \
&& curl -LOOO http://archive.ubuntu.com/ubuntu/pool/universe/u/uc-micro-py/uc-micro-py_1.0.1{-3.dsc,.orig.tar.xz,-3.debian.tar.xz} \
&& dpkg-source -x uc-micro-py_1.0.1-3.dsc \
&& cd uc-micro-py-1.0.1 \
&& DEB_BUILD_OPTIONS=nocheck dpkg-buildpackage -b -d -uc -us \
&& cd - \
&& apt-get install ./python3-uc-micro_1.0.1-3_all.deb \
&& curl -LOOO http://archive.ubuntu.com/ubuntu/pool/universe/l/linkify-it-py/linkify-it-py_2.0.0{-1.dsc,.orig.tar.gz,-1.debian.tar.xz} \
&& dpkg-source -x linkify-it-py_2.0.0-1.dsc \
&& cd linkify-it-py-2.0.0/ \
&& DEB_BUILD_OPTIONS=nocheck dpkg-buildpackage -b -d -uc -us \
&& cd - \
&& apt-get install ./python3-linkify-it_2.0.0-1_all.deb \
&& cd / && rm -rf /src

# the above is cached by the github action workflow
FROM base AS pkgs

ENV OMP_NUM_THREADS=1
ENV MKL_NUM_THREADS=1
Expand All @@ -78,6 +90,9 @@ ENV CPATH=/triqs/include:${CPATH} \
LD_LIBRARY_PATH=/triqs/lib:${LD_LIBRARY_PATH} \
PYTHONPATH=/triqs/lib/python3.10/site-packages:${PYTHONPATH} \
CMAKE_PREFIX_PATH=/triqs/share/cmake:${CMAKE_PREFIX_PATH} \
CMAKE_BUILD_PARALLEL_LEVEL=${NCORES} \
CTEST_OUTPUT_ON_FAILURE=1 \
CTEST_PARALLEL_LEVEL=${NCORES} \
TRIQS_ROOT=/triqs

RUN cd /source && git clone -b 3.2.x --depth 1 https://github.com/TRIQS/triqs triqs.src \
Expand All @@ -100,24 +115,21 @@ RUN cd /source && git clone -b 3.2.x --depth 1 https://github.com/TRIQS/cthyb.gi
# hubbardI
RUN cd /source && git clone -b 3.2.x --depth 1 https://github.com/TRIQS/hubbardI.git hubbardI.src \
&& mkdir -p hubbardI.build && cd hubbardI.build \
&& cmake ../hubbardI.src \
&& cmake ../hubbardI.src \
&& make -j$NCORES && ctest -j$NCORES && make install

# Hartree-Fock solver
RUN cd /source && git clone -b 3.2.x --depth 1 https://github.com/TRIQS/hartree_fock.git hartree.src \
&& mkdir -p hartree.build && cd hartree.build \
&& cmake ../hartree.src \
&& cmake ../hartree.src \
&& make -j$NCORES && make install

# maxent needed for doc build
RUN cd /source && git clone -b 1.2.x --depth 1 https://github.com/TRIQS/maxent.git maxent.src \
&& mkdir -p maxent.build && cd maxent.build \
&& cmake ../maxent.src \
&& cmake ../maxent.src \
&& make -j$NCORES && make install

# remove source
RUN cd / && rm -rf source

# make python3 default
RUN `ln -s /usr/bin/python3 /usr/bin/python`

4 changes: 2 additions & 2 deletions Docker/jupyter_start.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash

# start script for jupyterlab
jupyter-lab --no-browser --port 8378 --ip=0.0.0.0
# start script for jupyter notebook
jupyter notebook --no-browser --port 8378 --ip=0.0.0.0
Loading

0 comments on commit 506519a

Please sign in to comment.