Skip to content

Merge pull request #17 from nansencenter/update_geospaas_254 #14

Merge pull request #17 from nansencenter/update_geospaas_254

Merge pull request #17 from nansencenter/update_geospaas_254 #14

Workflow file for this run

---
name: "Build Docker image"
on:
push:
branches: ['**']
release:
types: [prereleased, released]
env:
IMAGE_NAME: "${{ secrets.DOCKER_ORG }}/geospaas_uwsgi"
jobs:
build_docker_image:
runs-on: 'ubuntu-latest'
env:
latest: ${{ matrix.python_version == '3.11' && 'true' || '' }}
BASE_IMAGE: "${{ vars.DOCKER_ORG }}/geospaas:2.5.4-python${{ matrix.python_version }}"
strategy:
matrix:
python_version:
- '3.8'
- '3.9'
- '3.10'
- '3.11'
steps:
- name: 'Checkout repository'
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASS }}
- name: Build docker image
uses: docker/build-push-action@v5
with:
context: .
build-args: |
BASE_IMAGE=${{ env.BASE_IMAGE }}
push: ${{ github.event_name == 'release' }}
tags: |
${{ env.IMAGE_NAME }}:${{ github.ref_name }}-python${{ matrix.python_version }}
${{ env.latest && format('{0}:{1}', env.IMAGE_NAME, github.ref_name) || '' }}
${{ env.IMAGE_NAME }}:latest-python${{ matrix.python_version }}
${{ env.latest && format('{0}:latest', env.IMAGE_NAME) || '' }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
...