Merge pull request #254 from sbe-arg/docker/caches

Speedup docker builds with a cache, thanks @sbe-arg !
This commit is contained in:
jokob-sk
2023-06-17 08:02:01 +10:00
committed by GitHub
4 changed files with 43 additions and 8 deletions

View File

@@ -0,0 +1,25 @@
name: ci-package-cleaner
on:
workflow_dispatch: # manual option
schedule:
- cron: '15 22 * * 1' # every Monday 10.15pm UTC (~11.15am Tuesday NZT)
jobs:
package-cleaner:
name: package-cleaner
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
packages: write
steps:
- uses: actions/delete-package-versions@v4
with:
package-name: pi.alert
package-type: container
min-versions-to-keep: 0
delete-only-untagged-versions: true

View File

@@ -14,6 +14,10 @@ on:
jobs:
docker_dev:
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
contents: read
packages: write
if: contains(github.event.head_commit.message, 'PUSHPROD') != 'True'
steps:
- name: Checkout
@@ -62,3 +66,5 @@ jobs:
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=ghcr.io/jokob-sk/pi.alert:buildcache
cache-to: type=registry,ref=ghcr.io/jokob-sk/pi.alert:buildcache,mode=max

View File

@@ -17,6 +17,10 @@ on:
jobs:
docker:
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v3
@@ -47,12 +51,6 @@ jobs:
type=ref,event=pr
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') }}
- name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
@@ -68,3 +66,5 @@ jobs:
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=ghcr.io/jokob-sk/pi.alert:buildcache
cache-to: type=registry,ref=ghcr.io/jokob-sk/pi.alert:buildcache,mode=max

View File

@@ -2,9 +2,13 @@ version: "3"
services:
pialert:
privileged: true
build: .
build:
dockerfile: Dockerfile
context: .
cache_from:
- type=registry,ref=ghcr.io/jokob-sk/pi.alert:buildcache
container_name: pialert
network_mode: "host"
network_mode: host
restart: unless-stopped
volumes:
- ${APP_DATA_LOCATION}/pialert_dev/config:/home/pi/pialert/config