Skip to content

Commit e5b8857

Browse files
Update docker workflow
1 parent 8185875 commit e5b8857

File tree

4 files changed

+143
-57
lines changed

4 files changed

+143
-57
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Docker image
2+
3+
on:
4+
push:
5+
branches:
6+
- 'main'
7+
8+
jobs:
9+
push_to_registry:
10+
name: Push Docker image to Docker Hub
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Check out the repo
14+
uses: actions/checkout@v3
15+
16+
- name: Log in to Docker Hub
17+
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
18+
with:
19+
username: ${{ secrets.DOCKER_USERNAME }}
20+
password: ${{ secrets.DOCKER_PASSWORD }}
21+
logout: true
22+
23+
- name: Extract metadata (tags, labels) for Docker
24+
id: meta
25+
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
26+
with:
27+
images: ingeborggjerde/graphnics
28+
29+
- name: Build and push Docker image
30+
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
31+
with:
32+
context: .
33+
push: true
34+
tags: ${{ steps.meta.outputs.tags }}
35+
labels: latest
36+

.github/workflows/docker-image.yml

Lines changed: 39 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,57 @@
1-
name: Docker image
1+
# This workflow uses actions that are not certified by GitHub.
2+
# They are provided by a third-party and are governed by
3+
# separate terms of service, privacy policy, and support
4+
# documentation.
5+
6+
name: Create and publish a Docker image
27

38
on:
49
push:
510
branches:
6-
- 'main'
11+
- "!*"
12+
tags:
13+
- "v*"
14+
15+
env:
16+
REGISTRY: ghcr.io
17+
IMAGE_NAME: ${{ github.repository }}
718

819
jobs:
9-
push_to_registry:
10-
name: Push Docker image to Docker Hub
20+
build-and-push-image:
1121
runs-on: ubuntu-latest
22+
permissions:
23+
contents: read
24+
packages: write
25+
1226
steps:
13-
- name: Check out the repo
27+
- name: Checkout repository
1428
uses: actions/checkout@v3
15-
16-
- name: Log in to Docker Hub
17-
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
29+
30+
- name: Set up QEMU
31+
uses: docker/setup-qemu-action@v2
32+
33+
- name: Set up Docker Buildx
34+
uses: docker/setup-buildx-action@v2
35+
36+
- name: Log in to the Container registry
37+
uses: docker/login-action@v2
1838
with:
19-
username: ${{ secrets.DOCKER_USERNAME }}
20-
password: ${{ secrets.DOCKER_PASSWORD }}
21-
logout: true
22-
39+
registry: ${{ env.REGISTRY }}
40+
username: ${{ github.actor }}
41+
password: ${{ secrets.GITHUB_TOKEN }}
42+
2343
- name: Extract metadata (tags, labels) for Docker
2444
id: meta
25-
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
45+
uses: docker/metadata-action@v4
2646
with:
27-
images: ingeborggjerde/graphnics
28-
47+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
48+
2949
- name: Build and push Docker image
30-
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
50+
uses: docker/build-push-action@v3
3151
with:
3252
context: .
3353
push: true
54+
platforms: linux/amd64,linux/arm64
3455
tags: ${{ steps.meta.outputs.tags }}
35-
labels: latest
36-
56+
labels: ${{ steps.meta.outputs.labels }}
57+
file: docker/Dockerfile

Dockerfile

100755100644
Lines changed: 15 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,19 @@
1-
# Builds a Docker image containing the mixed-dimensional features of FEniCS
2-
# found in
3-
# - fenics_mixed_dimensional
4-
# - fenics_ii
1+
# Use github pages for docker image
2+
FROM ghcr.io/ingeborggjerde/graphnics:v0.1.0
53

6-
FROM ceciledc/fenics_mixed_dimensional:21-06-22
4+
# Create user with a home directory
5+
ARG NB_USER
6+
ARG NB_UID=1000
7+
ENV USER ${NB_USER}
8+
ENV HOME /home/${NB_USER}
79

8-
USER root
9-
10-
RUN apt-get -qq update && \
11-
apt-get clean && \
12-
apt-get -y install python3-h5py && \
13-
pip install --upgrade pip && \
14-
pip install networkx && \
15-
pip install pandas && \
16-
pip install tqdm && \
17-
pip install jupyter && \
18-
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*- && \
19-
pip install -U setuptools
20-
21-
# Get fenics_ii
22-
RUN git clone https://github.com/MiroK/fenics_ii.git && \
23-
cd fenics_ii && \
24-
python3 setup.py install && \
25-
cd ..
26-
27-
28-
# cbc.block
29-
RUN git clone https://bitbucket.org/fenics-apps/cbc.block && \
30-
cd cbc.block && \
31-
python3 setup.py install && \
32-
cd ..
33-
34-
# Get graphnics
35-
RUN git clone https://github.com/IngeborgGjerde/graphnics.git && \
36-
cd graphnics && \
37-
python3 setup.py install && \
38-
cd ..
39-
40-
# fix decorator error by reinstalling scipy
41-
RUN pip uninstall -y scipy && pip install scipy
10+
# Copy current directory
11+
WORKDIR ${HOME}
12+
COPY . ${HOME}
4213

14+
# Change ownership of home directory
15+
USER root
16+
RUN chown -R ${NB_UID} ${HOME}
4317

18+
USER ${NB_USER}
19+
ENTRYPOINT []

docker/Dockerfile

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Builds a Docker image containing the mixed-dimensional features of FEniCS
2+
# found in
3+
# - fenics_mixed_dimensional
4+
# - fenics_ii
5+
6+
FROM ceciledc/fenics_mixed_dimensional:21-06-22
7+
8+
USER root
9+
10+
RUN apt-get -y install python3-h5py && \
11+
pip install --upgrade pip && \
12+
pip install networkx && \
13+
pip install pandas && \
14+
pip install tqdm && \
15+
pip install --no-cache-dir notebook jupyterlab jupyterhub && \
16+
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*- && \
17+
pip install -U setuptools
18+
19+
# Get fenics_ii
20+
RUN git clone https://github.com/MiroK/fenics_ii.git && \
21+
cd fenics_ii && \
22+
python3 -m pip install -e . && \
23+
cd ..
24+
25+
26+
# cbc.block
27+
RUN git clone https://bitbucket.org/fenics-apps/cbc.block && \
28+
cd cbc.block && \
29+
python3 -m pip install . && \
30+
cd ..
31+
32+
33+
# fix decorator error by reinstalling scipy
34+
RUN pip uninstall -y scipy && pip install scipy
35+
36+
37+
# Create user with a home directory
38+
ARG NB_USER
39+
ARG NB_UID=1000
40+
ENV USER ${NB_USER}
41+
ENV HOME /home/${NB_USER}
42+
43+
RUN echo $NB_USER
44+
45+
# Copy home directory for usage with Binder
46+
WORKDIR ${HOME}
47+
COPY . ${HOME}
48+
USER root
49+
RUN chown -R ${NB_UID} ${HOME}
50+
51+
USER ${NB_USER}
52+
#ENTRYPOINT []
53+

0 commit comments

Comments
 (0)