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

Deduplicates code by using composite action #737

Merged
merged 1 commit into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
85 changes: 85 additions & 0 deletions .github/actions/build_and_push/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Builds and pushes Docker image
description: Action to build and push images to docker


inputs:
dockerfile:
description: Path to the Dockerfile
default: ./Dockerfile
required: false
dockercontext:
description: Path to the Docker context
default: ./
required: false
# image coordinates
image:
description: Name of the image to build
required: true
tags:
description: Image Tag(s)
required: false
default: latest
# OCI metadata annotations
oci_title:
description: Image Title (OCI annotation)
required: true
oci_description:
description: Image Description (OCI annotation)
required: true
# registry credentials
registry_username:
description: The username for Docker hub sign-in
required: true
registry_password:
description: The password for Docker hub sign-in
required: true


runs:
using: "composite"
steps:
-
name: Checkout
uses: actions/checkout@v3
-
uses: dorny/paths-filter@v2
id: changes
with:
filters: |
src:
- '${{ inputs.dockercontext }}/**'
# -
# name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v2
# -
# name: Extract metadata (tags, labels) for Docker
# id: meta
# uses: docker/metadata-action@v4
# with:
# images: ${{ inputs.image }}
# labels: |
# "org.opencontainers.image.vendor=52°North GmbH"
# "org.opencontainers.image.authors=https://52North.org/"
# "org.opencontainers.image.source=https://github.com/52North/geonode"
# "org.opencontainers.image.description=${{ inputs.oci_description }}"
# "org.opencontainers.image.title=${{ inputs.oci_title }}"
# "org.opencontainers.image.licenses=GPL-3.0"
# tags: |
# ${{ inputs.tags }}
# -
# name: Login to Docker registry
# uses: docker/login-action@v2
# with:
# username: ${{ inputs.registry_username }}
# password: ${{ inputs.registry_password }}
# -
# name: Build and push
# uses: docker/build-push-action@v4
# with:
# context: .
# file: ${{ inputs.dockerfile }}
# push: true
# tags: ${{ steps.meta.outputs.tags }}
# labels: ${{ steps.meta.outputs.labels }}
# cache-from: type=registry,ref=${{ inputs.image }}:buildcache
# cache-to: type=registry,ref=${{ inputs.image }}:buildcache,mode=max
140 changes: 39 additions & 101 deletions .github/workflows/52n-build-master.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
name: "[52n_master -> lastest] Builds GeoNode Docker Images"
name: "[52n-master -> latest] Builds GeoNode Docker Images"

concurrency:
group: "geonode_build_master"
cancel-in-progress: true

env:
TITLE: "52°North GeoNode Docker Image"
VENDOR: "52°North GmbH"
AUTHORS: "https://52North.org/"
DESCRIPTION: "Builds and publishes the Docker images GeoNode, GeoServer, Nginx"
LICENSE: "GPL-3.0"
TAG: latest

on:
Expand All @@ -20,114 +15,57 @@ on:
jobs:
build_and_push_geonode:
runs-on: ubuntu-22.04
env:
IMAGE: 52north/geonode
steps:
- name: Checkout
-
name: Checkout
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.IMAGE }}
labels: |
"org.opencontainers.image.authors=${{ env.AUTHORS }}"
"org.opencontainers.image.vendor=${{ env.VENDOR }}"
"org.opencontainers.image.description=${{ env.DESCRIPTION }}"
"org.opencontainers.image.title=${{ env.TITLE }}"
"org.opencontainers.image.licenses=${{ env.LICENSE }}"
tags: |
${{ env.TAG }}
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN_52N_MASTER }}
- name: Build and push
uses: docker/build-push-action@v4
-
name: build and push geonode
uses: ./.github/actions/build_and_push
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=${{ env.IMAGE }}:buildcache
cache-to: type=registry,ref=${{ env.IMAGE }}:buildcache,mode=max

image: 52north/geonode
tags: ${{ env.TAG }}
oci_title: "52°North GeoNode image"
oci_description: "GeoNode built from 52n fork"
registry_username: ${{ secrets.DOCKERHUB_USERNAME }}
registry_password: ${{ secrets.DOCKERHUB_TOKEN_52N_MASTER }}

build_and_push_nginx:
runs-on: ubuntu-22.04
env:
IMAGE: 52north/geonode-nginx
steps:
- name: Checkout
-
name: Checkout
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
-
name: build and push nginx
uses: ./.github/actions/build_and_push
with:
images: ${{ env.IMAGE }}
labels: |
"org.opencontainers.image.authors=${{ env.AUTHORS }}"
"org.opencontainers.image.vendor=${{ env.VENDOR }}"
"org.opencontainers.image.description=${{ env.DESCRIPTION }}"
"org.opencontainers.image.title=${{ env.TITLE }}"
"org.opencontainers.image.licenses=${{ env.LICENSE }}"
tags: |
${{ env.TAG }}
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN_52N_MASTER }}
- name: Build and push
uses: docker/build-push-action@v4
with:
context: ./scripts/docker/nginx/
file: ./scripts/docker/nginx/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=${{ env.IMAGE }}:buildcache
cache-to: type=registry,ref=${{ env.IMAGE }}:buildcache,mode=max
dockerfile: ./scripts/docker/nginx/Dockerfile
dockercontext: ./scripts/docker/nginx/
image: 52north/geonode-nginx
tags: ${{ env.TAG }}
oci_title: "52°North Nginx image for GeoNode"
oci_description: "Nginx built for GeoNode from a 52n fork"
registry_username: ${{ secrets.DOCKERHUB_USERNAME }}
registry_password: ${{ secrets.DOCKERHUB_TOKEN_52N_MASTER }}

build_and_push_geoserver:
runs-on: ubuntu-22.04
env:
IMAGE: 52north/geonode-geoserver
steps:
- name: Checkout
-
name: Checkout
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: "${{ env.IMAGE }}"
labels: |
"org.opencontainers.image.authors=${{ env.AUTHORS }}"
"org.opencontainers.image.vendor=${{ env.VENDOR }}"
"org.opencontainers.image.description=${{ env.DESCRIPTION }}"
"org.opencontainers.image.title=${{ env.TITLE }}"
"org.opencontainers.image.licenses=${{ env.LICENSE }}"
tags: |
${{ env.TAG }}
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN_52N_MASTER }}
- name: Build and push
uses: docker/build-push-action@v4
-
name: build and push geoserver
uses: ./.github/actions/build_and_push
with:
context: ./scripts/docker/geoserver/
file: ./scripts/docker/geoserver/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=${{ env.IMAGE }}:buildcache
cache-to: type=registry,ref=${{ env.IMAGE }}:buildcache,mode=max
dockerfile: ./scripts/docker/geoserver/Dockerfile
dockercontext: ./scripts/docker/geoserver/
image: 52north/geonode-geoserver
tags: ${{ env.TAG }}
oci_title: "52°North GeoServer image for GeoNode"
oci_description: "GeoServer built for GeoNode from a 52n fork"
registry_username: ${{ secrets.DOCKERHUB_USERNAME }}
registry_password: ${{ secrets.DOCKERHUB_TOKEN_52N_MASTER }}
Loading