Skip to content

Commit

Permalink
Add GitHub registry upload (#104)
Browse files Browse the repository at this point in the history
* Add build to github registry

* Add ci to build and upload container images

* Update registry_upload.yml

* Remove unused section

* Update metadata context

* Removed more unsed steps

* Update context

* Update context

* Update context

* Update context

* Disable push of ingest docker image, as it is not available yet.

* Change versions of github docker actions.

* Build and publish ARM image.

* Add amd64 build.

* Change platform to arm64 and amd64.

* Update registry_upload.yml

* Update registry_upload.yml

* Fix trailing whitespcae

* Update registry_upload.yml

* Fix trailing whitespcae

* Exclude workflow files from yaml lint, since github support none standard formats in yaml

* Update readme with more env variables

* Enable building of ingest image.

* Fix label on main branch for docker images (YAML scalar cannot contain comments).

* Update registry_upload.yml

---------

Co-authored-by: Jeffrey Vervoort <[email protected]>
  • Loading branch information
Teddy-1000 and Jeffrey-Vervoort-KNMI authored Apr 19, 2024
1 parent 1a3ff81 commit e8de15c
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 0 deletions.
87 changes: 87 additions & 0 deletions .github/workflows/registry_upload.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: Create and publish a Docker image

# Configures this workflow to run on main when testing CI is completed.
on:
workflow_run:
workflows: ["CI"]
branches: [main]
types:
- completed

# Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds.
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
CPU: "arm64"

jobs:

on-failure:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
steps:
- run: echo 'The triggering CI workflow failed'
docker-build-and-publish:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
permissions:
contents: read
packages: write
strategy:
matrix:
include:
- context: ./datastore/datastore/
IMAGE_NAME: datastore
- context: ./api/
IMAGE_NAME: api
- context: ./ingest/
IMAGE_NAME: ingest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: ${{ env.CPU }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

# Uses the `docker/login-action` action to log in to the Container registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here.
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels.
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ github.repository }}/${{ matrix.IMAGE_NAME }}
# Set tag to latest if there is no release tag from git
# Tag the build with the current release
tags: |
type=raw,value=latest,enable={{is_default_branch && !tag}}
type=tag,event=tag,enable={{is_default_branch}}
- name: Copy Protobuf files to Dockerfile directories
run: ./ci/docker/copy-protobuf.sh

# This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages.
# It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of the `docker/build-push-action` repository.
# It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step.
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: ${{ matrix.context }}
platforms: linux/arm64, linux/amd64
file: ${{ matrix.context }}/Dockerfile
pull: true
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
9 changes: 9 additions & 0 deletions api/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
# E-SOH API

## Enviorment variable
These enviorment variables should be set when you are starting the container or be set in the enviorment where you are running the application.
### DSHOST

IP address to datastore

### DSPORT

Port the datastore is available on.

### FORWARDED_ALLOW_IPS

Environment variable used to set the `forwarded-allow-ips` in gunicorn. If this API is set behind a proxy, `FORWARDED_ALLOW_IPS` should be set to the proxy IP. Setting this to `*` is possible, but should only be set if you have ensured the API is only reachable from the proxy, and not directly from the internet. If not using docker compose this have to be passed to docker using the `-e` argument.

1 comment on commit e8de15c

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

API Unit Test Coverage Report
FileStmtsMissCoverMissing
\_\_init\_\_.py00100% 
datastore_pb2.py604820%24–71
datastore_pb2_grpc.py432347%37–52, 85–87, 92–94, 99–101, 106–108, 112–136, 174, 191, 208, 225
grpc_getter.py201145%15–16, 20–23, 27–29, 33–35
locustfile.py15150%1–31
main.py34585%41, 51–52, 62–63
metadata_endpoints.py552555%42–51, 55, 72–151, 155
response_classes.py50100% 
utilities.py771975%15, 33, 40, 62–65, 73–80, 85–92, 112, 116, 118
custom_geo_json
   edr_feature_collection.py60100% 
formatters
   \_\_init\_\_.py110100% 
   covjson.py53198%75
   geojson.py15287%17, 42
routers
   \_\_init\_\_.py00100% 
   edr.py100793%119, 131, 139, 241–242, 297–298
   feature.py461959%75–108, 124–129, 135–157
TOTAL54017568% 

API Unit Test Coverage Summary

Tests Skipped Failures Errors Time
23 0 💤 0 ❌ 0 🔥 1.994s ⏱️

Please sign in to comment.