PR #801 for #989: GH Workflow - Docker Build+Push to DockerHub and GH Container Registry

* Create ghcr.yml

Create and publish a Docker image to GitHub Container Registry

* Update installation.rst

Add reference to GitHub Container registry

* Update running-with-docker.rst

Add ghcr references

* Make ghcr conditional on main.yml

Updated main.yml run conditions & add on-success condition to ghcr.yml

* Miss aligned

* change workflow name

GHCR

* Update build to Build

Names didn't match GHCR condition

* Remove cog symbol from Build name

* Add paths-ignore

**.md

* Added build & push to DockerHub

* Add authorship & update header

* Tidy yml, add on-success condition

* Add on failure condition

* Remove GHC Tests and Conditional Push

* DockerHub Test - koalageo/pygeoapi

* DockerHub - Revert to geopython/pygeoapi

* Use SECRET for DockerHub repo

* Combined Build & Push

* Update tag function

* Fix tags for latest

* Lastest tag only on `master`

* Use tag on push tag event

* Add latest tag on default branch

* Add unit tests step

* Add separate build & test steps

* Typo in docs

* Move flake8 to before tests - catch errors early

* Add further tags

Co-authored-by: Benjamin Webb <40066515+webb-ben@users.noreply.github.com>

Co-authored-by: Benjamin Webb <40066515+webb-ben@users.noreply.github.com>
This commit is contained in:
KoalaGeo
2022-09-26 22:38:34 +01:00
committed by GitHub
parent e2e12e9bd4
commit 8cd1e737f2
4 changed files with 118 additions and 5 deletions
+85
View File
@@ -0,0 +1,85 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
name: Publish Docker image
on:
workflow_run:
workflows: ["Build"]
types: [completed]
env:
TEST_TAG: ${{ secrets.DOCKER_REPOSITORY }}:test
jobs:
on-success:
name: Build, Test and Push Docker Image to DockerHub
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
permissions:
packages: write
contents: read
steps:
- name: Check out the repo
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: Log in to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Log in to the Container registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and export to Docker
uses: docker/build-push-action@v2
with:
context: .
load: true
tags: ${{ env.TEST_TAG }}
- name: pygeoapi Unit Tests with Docker Image ⚙️
run: |
docker run --entrypoint "/entrypoint.sh" --rm ${{ env.TEST_TAG }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v3
with:
images: |
${{ secrets.DOCKER_REPOSITORY }}
ghcr.io/${{ github.repository }}
tags: |
type=semver,pattern={{version}}
type=raw,value=latest,enable=${{ endsWith(github.ref, github.event.repository.default_branch) }}
- name: Build and push Docker images
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/arm64, linux/amd64
on-failure:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
steps:
- name: Print Test Fail
run: echo Tests Failed
+17 -4
View File
@@ -1,6 +1,19 @@
name: build ⚙️
name: Build
on: [ push, pull_request ]
on:
push:
branches:
- master
paths-ignore:
- '**.md'
pull_request:
branches:
- master
paths-ignore:
- '**.md'
release:
types:
- released
jobs:
main:
@@ -55,6 +68,8 @@ jobs:
pip3 install -r requirements-provider.txt
python3 setup.py install
#pip3 install --upgrade rasterio==1.1.8
- name: run flake8 ⚙️
run: find . -type f -name "*.py" | xargs flake8
- name: setup test data ⚙️
run: |
python3 tests/load_es_data.py tests/data/ne_110m_populated_places_simple.geojson geonameid
@@ -91,8 +106,6 @@ jobs:
pytest tests/test_util.py
pytest tests/test_xarray_netcdf_provider.py
pytest tests/test_xarray_zarr_provider.py
- name: run flake8 ⚙️
run: find . -type f -name "*.py" | xargs flake8
- name: build docs 🏗️
run: cd docs && make html
+12
View File
@@ -49,11 +49,23 @@ pip
Docker
------
Using DockerHub
^^^^^^^^^^^^^^^
`Docker image <https://hub.docker.com/r/geopython/pygeoapi>`_
.. code-block:: bash
docker pull geopython/pygeoapi:latest
Using GitHub Container Registry
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
`Docker image <https://github.com/geopython/pygeoapi/pkgs/container/pygeoapi>`_
.. code-block:: bash
docker pull ghcr.io/geopython/pygeoapi:latest
Conda
-----
+4 -1
View File
@@ -3,7 +3,7 @@
Docker
======
pygeoapi provides an official `Docker`_ image which is made available on the `geopython Docker Hub`_. Additional
pygeoapi provides an official `Docker`_ image which is made available on both the `geopython Docker Hub`_ and our `GitHub Container Registry`_. Additional
Docker examples can be found in the `pygeoapi GitHub repository`_, each with sample configurations, test data,
deployment scenarios and provider backends.
@@ -17,6 +17,8 @@ The basics
The official pygeoapi Docker image will start a pygeoapi Docker container using Gunicorn on internal port 80.
Either ``IMAGE`` can be called with the ``docker`` command, ``geopython/pygeoapi`` from DockerHub or ``ghcr.io/geophython/pygeoapi`` from the GitHub Container Registry. Examples below use ``geopython/pygeoapi``.
To run with the default built-in configuration and data:
.. code-block:: bash
@@ -113,6 +115,7 @@ Docker is an easy and reproducible approach to deploying systems.
.. _`Docker`: https://www.docker.com
.. _`geopython Docker Hub`: https://hub.docker.com/r/geopython/pygeoapi
.. _`GitHub Container Registry`: https://github.com/geopython/pygeoapi/pkgs/container/pygeoapi
.. _`pygeoapi GitHub repository`: https://github.com/geopython/pygeoapi
.. _`pygeoapi demo server`: https://demo.pygeoapi.io
.. _`useful examples`: https://github.com/geopython/demo.pygeoapi.io/tree/master/services