kopia lustrzana https://github.com/kartoza/docker-postgis
Modify GH Action for caching
rodzic
dd0613f56e
commit
3773f1f25a
|
@ -1,29 +1,49 @@
|
||||||
name: build-latest
|
name: build-latest
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
# workflow_dispatch:
|
||||||
inputs:
|
# inputs:
|
||||||
distro:
|
# distro:
|
||||||
description: Base image distro
|
# description: Base image distro
|
||||||
required: true
|
# required: true
|
||||||
default: debian
|
# default: debian
|
||||||
imageVersion:
|
# imageVersion:
|
||||||
description: Base distro image version/release
|
# description: Base distro image version/release
|
||||||
required: true
|
# required: true
|
||||||
default: bullseye
|
# default: bullseye
|
||||||
imageVariant:
|
# imageVariant:
|
||||||
description: Base image variant
|
# description: Base image variant
|
||||||
required: true
|
# required: true
|
||||||
default: slim
|
# default: slim
|
||||||
push:
|
push:
|
||||||
|
pull_request:
|
||||||
jobs:
|
jobs:
|
||||||
build-base:
|
build-image:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
latest-ref: refs/heads/develop
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
postgresMajorVersion:
|
||||||
|
- 13
|
||||||
|
postgresMinorRelease:
|
||||||
|
- 1
|
||||||
|
include:
|
||||||
|
- distro: debian
|
||||||
|
imageVersion: bullseye
|
||||||
|
imageVariant: slim
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Set up QEMU
|
- name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v1
|
uses: docker/setup-qemu-action@v1
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v1
|
uses: docker/setup-buildx-action@v1
|
||||||
|
- name: Get build cache
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: /tmp/.buildx-cache
|
||||||
|
key: buildx-${{ matrix.distro }}-${{ matrix.imageVersion }}-${{ matrix.imageVariant }}-${{ github.sha }}
|
||||||
|
restore-keys: |
|
||||||
|
buildx-${{ matrix.distro }}-${{ matrix.imageVersion }}-${{ matrix.imageVariant }}-
|
||||||
- name: Login to DockerHub
|
- name: Login to DockerHub
|
||||||
uses: docker/login-action@v1
|
uses: docker/login-action@v1
|
||||||
with:
|
with:
|
||||||
|
@ -31,10 +51,163 @@ jobs:
|
||||||
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
||||||
|
|
||||||
- name: Build base image
|
- name: Build base image
|
||||||
id: docker_build
|
id: docker_build_base
|
||||||
uses: docker/build-push-action@v2
|
uses: docker/build-push-action@v2
|
||||||
with:
|
with:
|
||||||
context: base_build
|
context: base_build
|
||||||
file: Dockerfile
|
file: Dockerfile
|
||||||
push: true
|
push: false
|
||||||
tags: ${{ secrets.DOCKERHUB_REPO }}/postgis:${{ github.event.inputs.distro }}-${{ github.event.inputs.imageVersion }}-${{ github.event.inputs.imageVariant }}
|
tags: ${{ secrets.DOCKERHUB_REPO }}/postgis:base-${{ matrix.distro }}-${{ matrix.imageVersion }}-${{ matrix.imageVariant }}
|
||||||
|
build-args: |
|
||||||
|
DISTRO=${{ matrix.distro }}
|
||||||
|
IMAGE_VERSION=${{ matrix.imageVersion }}
|
||||||
|
IMAGE_VARIANT=${{ matrix.imageVariant }}
|
||||||
|
cache-from: type=local,src=/tmp/.buildx-cache
|
||||||
|
cache-to: type=local,dest=/tmp/.buildx-cache
|
||||||
|
|
||||||
|
- name: Build prod image
|
||||||
|
id: docker_build_prod
|
||||||
|
uses: docker/build-push-action@v2
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
file: Dockerfile
|
||||||
|
push: false
|
||||||
|
tags: ${{ secrets.DOCKERHUB_REPO }}/postgis:${{ matrix.postgresMajorVersion }}.${{ matrix.postgresMinorRelease }}
|
||||||
|
build-args: |
|
||||||
|
DISTRO=${{ matrix.distro }}
|
||||||
|
IMAGE_VERSION=${{ matrix.imageVersion }}
|
||||||
|
IMAGE_VARIANT=${{ matrix.imageVariant }}
|
||||||
|
cache-from: type=local,src=/tmp/.buildx-cache
|
||||||
|
cache-to: type=local,dest=/tmp/.buildx-cache
|
||||||
|
|
||||||
|
run-scenario-tests:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: [ build-image ]
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
postgresMajorVersion:
|
||||||
|
- 13
|
||||||
|
postgresMinorRelease:
|
||||||
|
- 1
|
||||||
|
scenario:
|
||||||
|
- datadir_init
|
||||||
|
- streaming_replication
|
||||||
|
- collations
|
||||||
|
- extensions
|
||||||
|
- logical_replication
|
||||||
|
include:
|
||||||
|
- distro: debian
|
||||||
|
imageVersion: bullseye
|
||||||
|
imageVariant: slim
|
||||||
|
steps:
|
||||||
|
- 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: Get build cache
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: /tmp/.buildx-cache
|
||||||
|
key: buildx-${{ matrix.distro }}-${{ matrix.imageVersion }}-${{ matrix.imageVariant }}-${{ github.sha }}
|
||||||
|
restore-keys: |
|
||||||
|
buildx-${{ matrix.distro }}-${{ matrix.imageVersion }}-${{ matrix.imageVariant }}-
|
||||||
|
|
||||||
|
- name: Build base image for testing
|
||||||
|
id: docker_build_base
|
||||||
|
uses: docker/build-push-action@v2
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
file: Dockerfile
|
||||||
|
push: false
|
||||||
|
tags: ${{ secrets.DOCKERHUB_REPO }}/postgis:manual-build
|
||||||
|
build-args: |
|
||||||
|
DISTRO=${{ matrix.distro }}
|
||||||
|
IMAGE_VERSION=${{ matrix.imageVersion }}
|
||||||
|
IMAGE_VARIANT=${{ matrix.imageVariant }}
|
||||||
|
cache-from: type=local,src=/tmp/.buildx-cache
|
||||||
|
|
||||||
|
- name: Build image for testing
|
||||||
|
id: docker_build_testing_image
|
||||||
|
uses: docker/build-push-action@v2
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
file: Dockerfile.test
|
||||||
|
push: false
|
||||||
|
tags: ${{ secrets.DOCKERHUB_REPO }}/postgis:manual-build
|
||||||
|
load: true
|
||||||
|
- name: Run scenario test
|
||||||
|
run: |
|
||||||
|
pushd scenario_tests/${{ matrix.scenario }}
|
||||||
|
./test.sh
|
||||||
|
popd
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
deploy-image:
|
||||||
|
# Identical to the build-image step, but now push to registry
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
latest-ref: refs/heads/develop
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
postgresMajorVersion:
|
||||||
|
- 13
|
||||||
|
postgresMinorRelease:
|
||||||
|
- 1
|
||||||
|
include:
|
||||||
|
- distro: debian
|
||||||
|
imageVersion: bullseye
|
||||||
|
imageVariant: slim
|
||||||
|
needs: [ build-image, run-scenario-tests ]
|
||||||
|
steps:
|
||||||
|
- 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: Get build cache
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: /tmp/.buildx-cache
|
||||||
|
key: buildx-${{ matrix.distro }}-${{ matrix.imageVersion }}-${{ matrix.imageVariant }}-${{ github.sha }}
|
||||||
|
restore-keys: |
|
||||||
|
buildx-${{ matrix.distro }}-${{ matrix.imageVersion }}-${{ matrix.imageVariant }}-
|
||||||
|
- name: Login to DockerHub
|
||||||
|
uses: docker/login-action@v1
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
||||||
|
|
||||||
|
- name: Build base image
|
||||||
|
id: docker_build_base
|
||||||
|
uses: docker/build-push-action@v2
|
||||||
|
with:
|
||||||
|
context: base_build
|
||||||
|
file: Dockerfile
|
||||||
|
push: ${{ github.ref == env.latest-ref }}
|
||||||
|
tags: ${{ secrets.DOCKERHUB_REPO }}/postgis:base-${{ matrix.distro }}-${{ matrix.imageVersion }}-${{ matrix.imageVariant }}
|
||||||
|
build-args: |
|
||||||
|
DISTRO=${{ matrix.distro }}
|
||||||
|
IMAGE_VERSION=${{ matrix.imageVersion }}
|
||||||
|
IMAGE_VARIANT=${{ matrix.imageVariant }}
|
||||||
|
cache-from: type=local,src=/tmp/.buildx-cache
|
||||||
|
cache-to: type=local,dest=/tmp/.buildx-cache
|
||||||
|
|
||||||
|
- name: Build prod image
|
||||||
|
id: docker_build_prod
|
||||||
|
uses: docker/build-push-action@v2
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
file: Dockerfile
|
||||||
|
push: ${{ github.ref == env.latest-ref }}
|
||||||
|
tags: ${{ secrets.DOCKERHUB_REPO }}/postgis:${{ matrix.postgresMajorVersion }}.${{ matrix.postgresMinorRelease }}
|
||||||
|
build-args: |
|
||||||
|
DISTRO=${{ matrix.distro }}
|
||||||
|
IMAGE_VERSION=${{ matrix.imageVersion }}
|
||||||
|
IMAGE_VARIANT=${{ matrix.imageVariant }}
|
||||||
|
cache-from: type=local,src=/tmp/.buildx-cache
|
||||||
|
cache-to: type=local,dest=/tmp/.buildx-cache
|
||||||
|
|
Ładowanie…
Reference in New Issue