Skip to content
Permalink
Browse files

Add Github workflow to build Docker images

  • Loading branch information
3nids committed Aug 20, 2020
1 parent f496173 commit 5adcc9fa9f2f35361aee29f7cda44d78152c83a5
Showing with 96 additions and 0 deletions.
  1. +96 −0 .github/workflows/manual.yml
@@ -0,0 +1,96 @@
name: Build QGIS Docker images for current branches

on:
schedule:
# runs every day
# - cron: '0 0 * * *'
# every hour
- cron: '* */1 * * *'

jobs:
build-docker:
# only run this workflow on the master branch !
if: ${{ github.ref == 'refs/heads/master' }}

This comment has been minimized.

Copy link
@sbrunner

sbrunner Aug 21, 2020

Contributor

This will always be true, GitHub runs the cron only on master branch...

This comment has been minimized.

Copy link
@3nids

3nids Aug 21, 2020

Author Member

thanks


runs-on: ubuntu-latest

env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}

strategy:
matrix:
# branch: [master, release-3_10, release-3_14]
branch: [build-docker]

steps:
- name: checkout ${branch}
uses: actions/checkout@v2
with:
ref: ${{ matrix.branch }}

- name: Build QGIS Docker image for branch ${{ matrix.branch }}
env:
branch: ${{ matrix.branch }}
run: |
DOCKER_TAG=${branch//master/latest/}
DOCKER_BUILD_DEPS_FILE=qgis3-build-deps-focal.dockerfile
CC=/usr/lib/ccache/gcc
CXX=/usr/lib/ccache/g++ # Building SIP binding freezes with Clang in Docker, maybe a SIP issue, maybe not
echo "branch: ${branch}"
echo "docker tag: ${DOCKER_TAG}"
echo "##[group] QGIS deps Docker pull/rebuild"
cd .docker
docker --version
docker pull "qgis/qgis3-build-deps:${DOCKER_TAG}" || true
docker build --cache-from "qgis/qgis3-build-deps:${DOCKER_TAG}" -t "qgis/qgis3-build-deps:${DOCKER_TAG}" -f ${DOCKER_BUILD_DEPS_FILE} .
echo "push to qgis/qgis3-build-deps:${DOCKER_TAG}"
docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD"
docker push "qgis/qgis3-build-deps:${DOCKER_TAG}"
echo "##[endgroup]"
echo "##[group] Docker QGIS build"
DOCKER_BUILD_ARGS="--build-arg DOCKER_TAG --build-arg CC --build-arg CXX"
docker build ${DOCKER_BUILD_ARGS} \
--cache-from "qgis/qgis:${DOCKER_TAG}" \
-t "qgis/qgis:BUILDER" \
-f qgis.dockerfile ..
docker run --name qgis_container qgis/qgis:BUILDER /bin/true
# we could copy cache
# docker cp qgis_container:/QGIS/.ccache_image_build/. ${CCACHE_DIR}
echo "##[endgroup]"
echo "##[group] Finalize image"
# enable experimental features in Docker to squash
echo '{ "experimental": true}' | sudo tee /etc/docker/daemon.json
service docker restart
docker build ${DOCKER_BUILD_ARGS} \
--cache-from "qgis/qgis:BUILDER" \
--squash \
-t "qgis/qgis:${DOCKER_TAG}" \
-f qgis.dockerfile ..
echo "##[endgroup]"
echo "##[group] Pushing image to docker hub"
docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD"
docker push "qgis/qgis:${DOCKER_TAG}"
echo "##[endgroup]"
echo "##[group] Trigger build of PyQGIS Documentation"
body='{
"ref": "master",
"inputs": {"qgis_branch": "__QGIS_VERSION_BRANCH__"}
}'
body=$(sed "s/__QGIS_VERSION_BRANCH__/${TRAVIS_BRANCH}/;" <<< $body)
curl -X POST \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token ${GH_TOKEN}" \
https://api.github.com/repos/qgis/pyqgis/actions/workflows/2246440/dispatches \
-d "${body}"
echo "##[endgroup]"

2 comments on commit 5adcc9f

@m-kuhn

This comment has been minimized.

Copy link
Member

@m-kuhn m-kuhn replied Aug 21, 2020

@3nids did this change the published docker images? Several tests have been failing since ~20 hours (qgis libraries not found, import qgis python errors)

@3nids

This comment has been minimized.

Copy link
Member Author

@3nids 3nids replied Aug 21, 2020

@m-kuhn I will try to fix this

Please sign in to comment.
You can’t perform that action at this time.