Skip to content

Commit

Permalink
- Upgrade nodejs to version 14
Browse files Browse the repository at this point in the history
-   Upgrade other dependencies
-   Release all artifacts to GitHub Container Registry (instead of docker.io & https://charts.magda.io)
-   Upgrade magda-common chart version to v2.1.1
-   Build multi-arch docker images
  • Loading branch information
t83714 committed Jan 24, 2023
1 parent 1726586 commit 98b4dc5
Show file tree
Hide file tree
Showing 11 changed files with 526 additions and 591 deletions.
41 changes: 31 additions & 10 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,47 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js 12
- name: Use Node.js 14
uses: actions/setup-node@v1
with:
node-version: 12
node-version: 14

- name: Login to GitHub Container Registry
run: |
REPO_OWNER=`echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]'`
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- run: yarn install
- run: yarn build
- run: yarn test

- name: helm-build-dependencies
run: yarn update-all-charts

- run: yarn update-all-charts
- run: yarn helm-lint

- name: Check Helm Chart Document
run: |
code=0
docker run --rm -v "$(pwd):/helm-docs" -u $(id -u) jnorwood/helm-docs:v1.5.0 -t ./README.md.gotmpl -o ../../README.md || code=$?;
if [ "$code" != "0" ]; then
echo "Failed to run helm-docs!";
exit 1;
fi;
cd deploy
code=0
git ls-files -m | grep -i readme.md || code=$?;
if [ "$code" == "0" ]; then
echo -e "Some of helm chart docs are required to be updated using the [helm-docs](https://github.com/norwoodj/helm-docs) tool. \n
Please run helm-docs (v1.5.0) at project root, review & commit docs changes and push a new commit.";
exit 1;
else
echo -e "helm docs check passed. helm docs update is not required.";
fi;
- name: Set up QEMU
uses: docker/setup-qemu-action@v1

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

- name: Login to GitHub Package Repository
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin

- name: Build Docker Image & Push to Github Container Registry
run: yarn docker-build-prod --repository=ghcr.io/${{ github.repository_owner }} --name=${REPO_NAME} --version=${GITHUB_SHA} --platform=linux/amd64,linux/arm64
- name: Build Docker Image & Push
run: |
REPO_OWNER=`echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]'`
yarn docker-build-prod --repository=ghcr.io/${REPO_OWNER} --name=${REPO_NAME} --version=${GITHUB_SHA} --platform=linux/amd64,linux/arm64
90 changes: 41 additions & 49 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,7 @@ on:
types: [published]

env:
# [avoid issue when Github action upgraded from 18.04 default to 20.04](https://github.com/aws/aws-cli/issues/5262)
AWS_EC2_METADATA_DISABLED: true
REPO_NAME: magda-function-esri-url-processor
# Github account username (used for access github registry)
GH_USERNAME: magdabot
# Github Orgnisation name or user name for this repo
GH_ORGNAME: magda-io
#Docker Hub username
DH_USERNAME: magdabot
#S3 bucket name: this s3 bucket will be used to store published helm chart and index
S3_BUCKET: magda-charts

jobs:
release-helm-chart:
Expand All @@ -24,65 +14,67 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Use Node.js 12
- name: Use Node.js 14
uses: actions/setup-node@v1
with:
node-version: 12
node-version: 14

- name: Login to GitHub Container Registry
run: |
REPO_OWNER=`echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]'`
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- run: yarn install
- run: yarn build
- run: yarn test

- name: helm-build-dependencies
run: yarn update-all-charts

- name: helm-check
run: yarn helm-lint
- run: yarn update-all-charts
- run: yarn helm-lint

- name: Check Helm Chart Document
run: |
code=0
docker run --rm -v "$(pwd):/helm-docs" -u $(id -u) jnorwood/helm-docs:v1.5.0 -t ./README.md.gotmpl -o ../../README.md || code=$?;
if [ "$code" != "0" ]; then
echo "Failed to run helm-docs!";
exit 1;
fi;
cd deploy
code=0
git ls-files -m | grep -i readme.md || code=$?;
if [ "$code" == "0" ]; then
echo -e "Some of helm chart docs are required to be updated using the [helm-docs](https://github.com/norwoodj/helm-docs) tool. \n
Please run helm-docs (v1.5.0) at project root, review & commit docs changes and push a new commit.";
exit 1;
else
echo -e "helm docs check passed. helm docs update is not required.";
fi;
- name: helm-chart-version-check
run: yarn check-helm-chart-version deploy/${REPO_NAME}/Chart.yaml

- name: Set up QEMU
uses: docker/setup-qemu-action@v1

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

- name: Login to GitHub Package Repository
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin

- name: Build Docker Image & Push to Github Container Registry
run: yarn docker-build-prod --repository=ghcr.io/${{ github.repository_owner }} --name=${REPO_NAME} --version=${GITHUB_SHA} --platform=linux/amd64,linux/arm64

- name: Login to Docker Hub
env:
DH_TOKEN: ${{ secrets.DOCKER_HUB_PASSWORD }}
run: docker login -u ${DH_USERNAME} -p ${DH_TOKEN}

- name: Re-tag & Push Docker Image to Docker Hub
- name: Build Docker Image & Push
run: |
REPO_OWNER=`echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]'`
yarn docker-build-prod --repository=ghcr.io/${REPO_OWNER} --name=${REPO_NAME} --version=${GITHUB_SHA} --platform=linux/amd64,linux/arm64
- name: Re-tag & Push Docker Images
run: |
PACKAGE_JSON_VERSION=$(jq -r ".version" package.json)
REPO_OWNER=`echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]'`
PACKAGE_JSON_VERSION=$(jq -r ".version" ./package.json)
chmod +r $HOME/.docker/config.json
# Re-push to ghcr.io
docker container run --rm --net host \
-v regctl-conf:/home/appuser/.regctl/ \
-v $HOME/.docker/config.json:/home/appuser/.docker/config.json \
regclient/regctl:v0.3.9 image copy ghcr.io/${{ github.repository_owner }}/${REPO_NAME}:${GITHUB_SHA} docker.io/data61/${REPO_NAME}:${PACKAGE_JSON_VERSION}
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
regclient/regctl:v0.3.9 image copy ghcr.io/${REPO_OWNER}/${REPO_NAME}:${GITHUB_SHA} ghcr.io/${REPO_OWNER}/${REPO_NAME}:${PACKAGE_JSON_VERSION}
- name: Release Helm Chart
env:
CR_TOKEN: "${{ secrets.GH_ACCESS_TOKEN }}"
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: |
REPO_OWNER=`echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]'`
cd deploy
mkdir -p sync_dir
mkdir -p index_dir
if ! aws s3 cp s3://${S3_BUCKET}/index.yaml index_dir/index.yaml; then echo "failed to copy current repo index" && exit 1; fi
helm package -d sync_dir ${REPO_NAME}
helm repo index --merge "index_dir/index.yaml" sync_dir
mv -f sync_dir/index.yaml index_dir/index.yaml
aws s3 sync sync_dir s3://${S3_BUCKET}/
aws s3 cp index_dir/index.yaml s3://${S3_BUCKET}/index.yaml
helm package ${REPO_NAME}
PKG_NAME=`ls *.tgz`
helm push ${PKG_NAME} oci://ghcr.io/${REPO_OWNER}/charts
8 changes: 8 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# 2.0.0

- Upgrade nodejs to version 14
- Upgrade other dependencies
- Release all artifacts to GitHub Container Registry (instead of docker.io & https://charts.magda.io)
- Upgrade magda-common chart version to v2.1.1
- Build multi-arch docker images

# 1.1.0

- Remove label from metadata to avoid crd validation error (with openfaas helm chart 5.5.5-magda.1)
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM openfaas/of-watchdog:0.7.6 as watchdog

FROM node:12-alpine3.11 as ship
FROM node:14-alpine3.11 as ship

COPY --from=watchdog /fwatchdog /usr/bin/fwatchdog
RUN chmod +x /usr/bin/fwatchdog && addgroup -S app && adduser app -S -G app
Expand Down
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,16 @@ yarn install

```yaml
- name: magda-function-esri-url-processor
version: 0.0.57-0
repository: https://charts.magda.io
version: "2.0.0" # or put latest version number here
repository: "oci://ghcr.io/magda-io/charts"
tags:
- all
- url-processors
- ckan-connector-functions
- magda-function-esri-url-processor
```
> Since v2.0.0, we use [Github Container Registry](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry) as our official Helm Chart & Docker Image release registry.
- Run `helm dep build` to pull the dependency
- Deploy Magda

Expand Down Expand Up @@ -90,17 +92,17 @@ This repo comes with script to build, test & release script to release docker im

Kubernetes: `>= 1.14.0-0`

| Repository | Name | Version |
| ----------------------- | ------------ | ------------- |
| https://charts.magda.io | magda-common | 1.0.0-alpha.4 |
| Repository | Name | Version |
| ----------------------------- | ------------ | ------- |
| oci://ghcr.io/magda-io/charts | magda-common | 2.1.1 |

## Values

| Key | Type | Default | Description |
| ---------------------------- | ------ | ------------------------------------- | ----------- |
| defaultImage.imagePullSecret | bool | `false` | |
| defaultImage.pullPolicy | string | `"IfNotPresent"` | |
| defaultImage.repository | string | `"docker.io/data61"` | |
| defaultImage.repository | string | `"ghcr.io/magda-io"` | |
| global.image | object | `{}` | |
| global.openfaas | object | `{}` | |
| global.urlProcessors.image | object | `{}` | |
Expand Down
8 changes: 5 additions & 3 deletions README.md.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,16 @@ yarn install

```yaml
- name: magda-function-esri-url-processor
version: 0.0.57-0
repository: https://charts.magda.io
version: "2.0.0" # or put latest version number here
repository: "oci://ghcr.io/magda-io/charts"
tags:
- all
- url-processors
- ckan-connector-functions
- magda-function-esri-url-processor
```

> Since v2.0.0, we use [Github Container Registry](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry) as our official Helm Chart & Docker Image release registry.

- Run `helm dep build` to pull the dependency
- Deploy Magda

Expand Down
8 changes: 4 additions & 4 deletions deploy/magda-function-esri-url-processor/Chart.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
dependencies:
- name: magda-common
repository: https://charts.magda.io
version: 1.0.0-alpha.4
digest: sha256:a5dcf2df16ca5a3972f92d91434c2e78be0ce411994d2a3cb89c674a711ddc24
generated: "2021-10-11T22:02:04.486075+11:00"
repository: oci://ghcr.io/magda-io/charts
version: 2.1.1
digest: sha256:ec6c98cd98ef7a74e919a4b87b8700658c4d4b66a063f2462a237234ebd00e10
generated: "2023-01-24T16:00:31.545792+11:00"
6 changes: 3 additions & 3 deletions deploy/magda-function-esri-url-processor/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v2
name: magda-function-esri-url-processor
description: A Helm chart for Magda Openfaas function
version: "1.1.0"
version: "2.0.0"
kubeVersion: ">= 1.14.0-0"
home: "https://github.com/magda-io/magda-function-esri-url-processor"
sources:
Expand All @@ -12,5 +12,5 @@ annotations:
magdaModuleType: "urlProcessor"
dependencies:
- name: magda-common
version: "1.0.0-alpha.4"
repository: "https://charts.magda.io"
version: "2.1.1"
repository: "oci://ghcr.io/magda-io/charts"
2 changes: 1 addition & 1 deletion deploy/magda-function-esri-url-processor/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ image:
# imagePullSecret:

defaultImage:
repository: docker.io/data61
repository: ghcr.io/magda-io
pullPolicy: IfNotPresent
imagePullSecret: false

Expand Down
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "magda-function-esri-url-processor",
"version": "1.1.0",
"version": "2.0.0",
"description": "An Openfass Serverless Function template for Magda",
"repository": "https://github.com/magda-io/magda-function-esri-url-processor.git",
"author": "Jacky Jiang <t83714@gmail.com>",
Expand Down Expand Up @@ -30,27 +30,27 @@
"@types/chai": "^4.2.8",
"@types/express": "^4.0.37",
"@types/is-url": "^1.2.28",
"@types/mocha": "^7.0.1",
"@types/mocha": "^9.1.1",
"@types/nock": "^11.1.0",
"@types/proj4": "^2.5.0",
"chai": "^4.2.0",
"husky": "^3.1.0",
"mocha": "^7.0.1",
"mocha": "^10.0.0",
"nock": "^12.0.3",
"prettier": "^1.19.1",
"pretty-quick": "^2.0.1",
"rimraf": "^3.0.0",
"ts-loader": "^6.2.1",
"ts-node": "^9.0.0",
"typescript": "^3.9.5"
"ts-node": "^10.9.1",
"typescript": "^4.2.4"
},
"dependencies": {
"@magda/registry-client": "^1.1.0-alpha.4",
"@magda/registry-client": "^2.1.1",
"express": "^4.15.4",
"is-url": "^1.2.4",
"isomorphic-fetch": "^2.2.1",
"proj4": "^2.6.2",
"urijs": "^1.19.2"
"urijs": "^1.19.11"
},
"config": {
"docker": {
Expand Down
Loading

0 comments on commit 98b4dc5

Please sign in to comment.