Add caching to build (#369)

* Rename publish workflow

* Add caching to v5

* Updated cache buster
This commit is contained in:
Ween Jiann
2021-07-02 21:42:18 +08:00
committed by GitHub
parent ff897d568f
commit 7a935a0eef
4 changed files with 70 additions and 10 deletions

57
.github/workflows/build-image-v5.yml vendored Normal file
View File

@@ -0,0 +1,57 @@
name: Build Container Image
# When its time to do a release do a full cross platform build for all supported
# architectures and push all of them to Docker Hub.
# Only trigger on semver shaped tags.
# Ref: https://github.com/metcalfc/docker-action-examples/blob/main/.github/workflows/release.yml
on:
pull_request:
paths:
- "alpine/5/**"
push:
paths:
- "alpine/5/**"
branches:
- master
jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
with:
platforms: all
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-5-${{ hashFiles('alpine/5/cache_buster') }}
restore-keys: |
${{ runner.os }}-buildx-5-${{ hashFiles('alpine/5/cache_buster') }}
- name: Build
id: docker_build
uses: docker/build-push-action@v2
with:
builder: ${{ steps.buildx.outputs.name }}
context: ./alpine/5/
build-args: INVOICENINJA_VERSION=5-stable
target: prod
platforms: linux/amd64,linux/arm64
tags: invoiceninja/invoiceninja:cache
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache

View File

@@ -1,4 +1,4 @@
name: Publish Releases to Hub
name: Publish Container Image
# When its time to do a release do a full cross platform build for all supported
# architectures and push all of them to Docker Hub.
@@ -44,13 +44,13 @@ jobs:
id: buildx
uses: docker/setup-buildx-action@v1
# - name: Cache Docker layers
# uses: actions/cache@v2
# with:
# path: /tmp/.buildx-cache
# key: ${{ runner.os }}-buildx-${{ github.sha }}
# restore-keys: |
# ${{ runner.os }}-buildx-
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ steps.prep.outputs.major }}-${{ hashFiles('alpine/${{ steps.prep.outputs.major }}/**') }}
restore-keys: |
${{ runner.os }}-buildx-${{ steps.prep.outputs.major }}-${{ hashFiles('alpine/${{ steps.prep.outputs.major }}/**') }}
- name: Login to DockerHub
if: github.event_name != 'pull_request'
@@ -70,8 +70,8 @@ jobs:
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.prep.outputs.tags }}
cache-from: invoiceninja/invoiceninja:${{ steps.prep.outputs.major }}
cache-to: type=inline
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}

View File

@@ -2,6 +2,8 @@
[![Docker image, latest](https://img.shields.io/docker/image-size/invoiceninja/invoiceninja/latest?label=latest)](https://hub.docker.com/r/invoiceninja/invoiceninja)
[![Docker image, alpine](https://img.shields.io/docker/image-size/invoiceninja/invoiceninja/alpine?label=alpine)](https://hub.docker.com/r/invoiceninja/invoiceninja)
[![Artifact HUB](https://img.shields.io/endpoint?url=https://artifacthub.io/badge/repository/invoiceninja)](https://artifacthub.io/packages/search?repo=invoiceninja)
[![Pusblish Image](https://github.com/invoiceninja/dockerfiles/actions/workflows/publish-image.yaml/badge.svg)](https://github.com/invoiceninja/dockerfiles/actions/workflows/publish-image.yaml) [![Cache v5 Image](https://github.com/invoiceninja/dockerfiles/actions/workflows/build-image-v5.yaml/badge.svg)](https://github.com/invoiceninja/dockerfiles/actions/workflows/build-image-v5.yaml)
# Docker for [Invoice Ninja](https://www.invoiceninja.com/)

1
alpine/5/cache_buster Normal file
View File

@@ -0,0 +1 @@
Fri Jul 2 7:33:22 +00 2021