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

Add GitHub registry upload #104

Merged
merged 25 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
5e3884d
Add build to github registry
Teddy-1000 Jan 18, 2024
19fd86c
Add ci to build and upload container images
Teddy-1000 Apr 2, 2024
2311b0a
Update registry_upload.yml
Teddy-1000 Apr 8, 2024
ce037f7
Remove unused section
Teddy-1000 Apr 8, 2024
697c22c
Update metadata context
Teddy-1000 Apr 8, 2024
00e4d50
Removed more unsed steps
Teddy-1000 Apr 8, 2024
57273cc
Update context
Teddy-1000 Apr 8, 2024
08fc86b
Update context
Teddy-1000 Apr 8, 2024
7b8024e
Update context
Teddy-1000 Apr 8, 2024
ae92621
Update context
Teddy-1000 Apr 8, 2024
1d300bf
Disable push of ingest docker image, as it is not available yet.
Jeffrey-Vervoort-KNMI Apr 8, 2024
d27f59f
Change versions of github docker actions.
Jeffrey-Vervoort-KNMI Apr 8, 2024
ff4df83
Build and publish ARM image.
Jeffrey-Vervoort-KNMI Apr 8, 2024
715dfd0
Add amd64 build.
Jeffrey-Vervoort-KNMI Apr 8, 2024
fd96ef8
Change platform to arm64 and amd64.
Jeffrey-Vervoort-KNMI Apr 8, 2024
c119a51
Update registry_upload.yml
Teddy-1000 Apr 9, 2024
f2dfb1d
Update registry_upload.yml
Teddy-1000 Apr 9, 2024
f61957f
Fix trailing whitespcae
Teddy-1000 Apr 9, 2024
3c94739
Update registry_upload.yml
Teddy-1000 Apr 10, 2024
a7171d1
Fix trailing whitespcae
Teddy-1000 Apr 10, 2024
6afd041
Exclude workflow files from yaml lint, since github support none stan…
Teddy-1000 Apr 11, 2024
53a6a27
Update readme with more env variables
Teddy-1000 Apr 11, 2024
05fb7ad
Enable building of ingest image.
Jeffrey-Vervoort-KNMI Apr 16, 2024
ff593cc
Fix label on main branch for docker images (YAML scalar cannot contai…
Jeffrey-Vervoort-KNMI Apr 18, 2024
a0bef7b
Update registry_upload.yml
Teddy-1000 Apr 19, 2024
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
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
Jeffrey-Vervoort-KNMI marked this conversation as resolved.
Show resolved Hide resolved

# 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.