Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revise Docker image build: #4997

Merged
merged 6 commits into from
Jun 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions .github/workflows/build_and_test_docker_on_pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Test the Docker image on every pull request.
#
# The steps are:
# 1. Build docker image using cached data.
# 2. Start the docker container.
# 3. Check that AiiDA is responsive.

name: build-and-test-image-from-pull-request

on:
pull_request:
path_ignore:
- 'docs/**'

jobs:

build-and-test:

runs-on: ubuntu-latest
timeout-minutes: 30

steps:
-
uses: actions/checkout@v2
-
name: Set up QEMU
uses: docker/setup-qemu-action@v1
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
-
name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
-
name: Build image locally
uses: docker/build-push-action@v2
with:
load: true
push: false
tags: aiida-core:latest
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
-
name: Start and test the container
run: |
export DOCKERID=`docker run -d aiida-core:latest`
docker exec --tty $DOCKERID wait-for-services
docker logs $DOCKERID
docker exec --tty --user aiida $DOCKERID /bin/bash -l -c 'verdi profile show default'
docker exec --tty --user aiida $DOCKERID /bin/bash -l -c 'verdi computer show localhost'
docker exec --tty --user aiida $DOCKERID /bin/bash -l -c 'verdi daemon status'
29 changes: 0 additions & 29 deletions .github/workflows/ci-code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,32 +142,3 @@ jobs:
run: |
verdi devel check-load-time
.github/workflows/verdi.sh

docker:
runs-on: ubuntu-latest
timeout-minutes: 30

steps:
- uses: actions/checkout@v2

- name: Install docker
run: |
sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
sudo apt-get install docker-ce

- name: Build the aiida-core image
run:
docker build -t aiida-core .

- name: Run aiida-core image and test the default aiida profile and localhost computer.
run: |
export DOCKERID=`docker run -d aiida-core`
docker exec --tty $DOCKERID wait-for-services
docker logs $DOCKERID
docker exec --tty --user aiida $DOCKERID /bin/bash -l -c 'verdi profile show default'
docker exec --tty --user aiida $DOCKERID /bin/bash -l -c 'verdi computer show localhost'
docker exec --tty --user aiida $DOCKERID /bin/bash -l -c 'verdi daemon status'
51 changes: 51 additions & 0 deletions .github/workflows/push_image_to_dockerhub.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Build the new Docker image on every commit to master/develop branch and on every new tag.
# No caching is involved for the image build. The new image is then pushed to the Docker Hub.

name: build-and-push-to-dockerhub

on:
push:
branches:
- master
- develop
tags:
- "v[0-9]+.[0-9]+.[0-9]+*"

jobs:

build-and-push:

runs-on: ubuntu-latest
timeout-minutes: 30

steps:
-
uses: actions/checkout@v2
-
name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: ${{ github.repository }}
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
-
name: Set up QEMU
uses: docker/setup-qemu-action@v1
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
-
name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
-
name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
push: true
tags: ${{ steps.meta.outputs.tags }}