Skip to content

Commit 763f469

Browse files
hmenkethe-hampel
andauthored
[build] Add GitHub Actions workflow for Docker images (#66)
* 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 <ahampel@flatironinstitute.org>
1 parent 89998a9 commit 763f469

8 files changed

Lines changed: 294 additions & 233 deletions

File tree

.github/dependabot.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
groups:
8+
batch:
9+
patterns:
10+
- "*"

.github/workflows/docker.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Create and publish Docker images
2+
3+
on:
4+
push: { branches: [ unstable ] }
5+
pull_request: { branches: [ unstable ] }
6+
workflow_call:
7+
workflow_dispatch:
8+
9+
jobs:
10+
build-and-push-image:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
packages: write
15+
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
include:
20+
- name: github_ci
21+
- name: openmpi
22+
23+
steps:
24+
- name: Checkout repository
25+
uses: actions/checkout@v4
26+
27+
- name: Setup Docker buildx
28+
uses: docker/setup-buildx-action@v3
29+
30+
- name: Log in to the Container registry
31+
if: github.event_name != 'pull_request'
32+
uses: docker/login-action@v3
33+
with:
34+
registry: ghcr.io
35+
username: ${{ github.actor }}
36+
password: ${{ secrets.GITHUB_TOKEN }}
37+
38+
- name: Extract metadata (tags, labels) for Docker
39+
id: meta
40+
uses: docker/metadata-action@v5
41+
with:
42+
images: ghcr.io/${{ github.repository }}_${{ matrix.name }}
43+
44+
- name: Build and push Docker image
45+
uses: docker/build-push-action@v5
46+
with:
47+
context: ./Docker
48+
file: ./Docker/${{ matrix.name }}_dockerfile
49+
build-args: |
50+
NCORES=2
51+
# cache pkgs layer in dockerfile
52+
no-cache-filters: pkgs
53+
push: ${{ github.event_name != 'pull_request' }}
54+
tags: ${{ steps.meta.outputs.tags }}
55+
labels: ${{ steps.meta.outputs.labels }}
56+
cache-from: type=gha,scope=${{ github.ref_name }}-${{ matrix.name }}
57+
cache-to: type=gha,mode=max,scope=${{ github.ref_name }}-${{ matrix.name }}

Docker/github_ci_dockerfile

Lines changed: 49 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,78 @@
1-
FROM ubuntu:22.04
1+
FROM ubuntu:22.04 AS base
22

33
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
4+
build-essential \
5+
ca-certificates \
46
cmake \
7+
curl \
8+
cython3 \
9+
debhelper \
10+
dh-python \
511
g++-12 \
612
gfortran-12 \
713
git \
814
hdf5-tools \
9-
liblapack-dev \
1015
libboost-dev \
1116
libfftw3-dev \
12-
libnfft3-dev \
1317
libgfortran5 \
1418
libgmp-dev \
1519
libhdf5-dev \
20+
liblapack-dev \
21+
libnfft3-dev \
22+
libomp-dev \
1623
libopenmpi-dev \
17-
cython3 \
24+
libpython3-dev \
1825
openmpi-bin \
1926
openmpi-common \
2027
openmpi-doc \
28+
openssl \
29+
pandoc \
30+
python-is-python3 \
31+
python3-ase \
32+
python3-decorator \
2133
python3-dev \
34+
python3-jinja2 \
2235
python3-mako \
23-
python3-numpy \
24-
python3-scipy \
2536
python3-matplotlib \
37+
python3-monty \
2638
python3-mpi4py \
27-
python3-pip \
28-
python3-sphinx \
39+
python3-myst-parser \
2940
python3-nbsphinx \
30-
python3-skimage \
3141
python3-notebook \
32-
libpython3-dev \
33-
curl \
34-
ca-certificates \
35-
openssl \
36-
wget \
42+
python3-numpy \
43+
python3-pip \
44+
python3-pytest \
45+
python3-scipy \
46+
python3-shapely \
47+
python3-skimage \
48+
python3-sphinx \
49+
python3-sphinx-rtd-theme \
3750
rsync \
38-
libomp-dev \
3951
sudo \
40-
nodejs \
41-
npm \
4252
&& \
4353
apt-get autoremove --purge -y && \
4454
apt-get autoclean -y && \
4555
rm -rf /var/cache/apt/* /var/lib/apt/lists/*
4656

47-
RUN pip3 install --no-cache-dir \
48-
cython \
49-
decorator \
50-
pytest \
51-
shapely \
52-
monty \
53-
mpi4py \
54-
Jinja2 \
55-
Mako \
56-
ase \
57-
tornado \
58-
zmq \
59-
tk \
60-
myst_parser \
61-
sphinx_rtd_theme \
62-
linkify-it-py \
63-
Pandoc
57+
# linkify-it-py (required by sphinx doc build) is not available in Ubuntu 22.04 as package
58+
# the following manually installs it and its only dependency uc-micro-py
59+
RUN mkdir -p /src && cd /src \
60+
&& 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} \
61+
&& dpkg-source -x uc-micro-py_1.0.1-3.dsc \
62+
&& cd uc-micro-py-1.0.1 \
63+
&& DEB_BUILD_OPTIONS=nocheck dpkg-buildpackage -b -d -uc -us \
64+
&& cd - \
65+
&& apt-get install ./python3-uc-micro_1.0.1-3_all.deb \
66+
&& 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} \
67+
&& dpkg-source -x linkify-it-py_2.0.0-1.dsc \
68+
&& cd linkify-it-py-2.0.0/ \
69+
&& DEB_BUILD_OPTIONS=nocheck dpkg-buildpackage -b -d -uc -us \
70+
&& cd - \
71+
&& apt-get install ./python3-linkify-it_2.0.0-1_all.deb \
72+
&& cd / && rm -rf /src
73+
74+
# the above is cached by the github action workflow
75+
FROM base AS pkgs
6476

6577
ENV OMP_NUM_THREADS=1
6678
ENV MKL_NUM_THREADS=1
@@ -81,6 +93,9 @@ ENV CPATH=/triqs/include:${CPATH} \
8193
LD_LIBRARY_PATH=/triqs/lib:${LD_LIBRARY_PATH} \
8294
PYTHONPATH=/triqs/lib/python3.10/site-packages:${PYTHONPATH} \
8395
CMAKE_PREFIX_PATH=/triqs/share/cmake:${CMAKE_PREFIX_PATH} \
96+
CMAKE_BUILD_PARALLEL_LEVEL=${NCORES} \
97+
CTEST_OUTPUT_ON_FAILURE=1 \
98+
CTEST_PARALLEL_LEVEL=${NCORES} \
8499
TRIQS_ROOT=/triqs
85100

86101
RUN cd /source && git clone -b unstable --depth 1 https://github.com/TRIQS/triqs \
@@ -121,6 +136,3 @@ RUN cd /source && git clone -b unstable --depth 1 https://github.com/TRIQS/maxen
121136
# remove source
122137
RUN cd / && rm -rf source
123138

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

Docker/jupyter_start.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/bin/bash
22

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

0 commit comments

Comments
 (0)