Skip to content

Commit

Permalink
Updates Dockerfile layout to support better caching of layers which r…
Browse files Browse the repository at this point in the history
…educed build time (#4)

Dockerfile:

Moved ARG BUILD_DATE and dependend RUNS to the end, becasue this invalidats the cache for every build run

Added Version numbers to every apt package to specify what is installed and be able to update the image if new versions are released. Specifying a new version will invalidate the cache for the layer and all following ones

Added wildcard for some plattform specific versions where version arn't the same overall

Removed upgrade in base envionment, versions should be used from the specified base imae

removed apt-transport-https package, because it's no longer needed

combined COPY to reduce layers created

rearrange dockerfile for improved cache

specified buster als 10.7 to be able to get notified when 10.8 is released via dependabot and start a new build

Use the slim image instead of the full one

build.yml

readded caching, Dockerfile supports now caching
  • Loading branch information
sidey79 committed Jan 2, 2021
1 parent 40e31b5 commit 5337cbe
Show file tree
Hide file tree
Showing 2 changed files with 403 additions and 302 deletions.
48 changes: 22 additions & 26 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,13 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

# cache disabled, becuse the Dockerfile has currently no cache compatible layout
# - 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-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Build for test full blown amd64
uses: docker/build-push-action@v2
Expand All @@ -114,9 +113,8 @@ jobs:
file: ./Dockerfile
platforms: linux/amd64
push: false
# cache disabled, becuse the Dockerfile has currently no cache compatible layout
# cache-from: type=local,src=/tmp/.buildx-cache
# cache-to: type=local,dest=/tmp/.buildx-cache
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
tags: fhem:${{ steps.buildVars.outputs.VARIANT }}
build-args: |
PLATFORM=linux
Expand Down Expand Up @@ -168,8 +166,9 @@ jobs:
- name: Get git vars
shell: bash
run: |
echo "::set-output name=BRANCH::$(echo "${GITHUB_REF#refs/*/}")"
echo "::set-output name=IMAGE_VERSION::$( git describe --tags --dirty --match "v[0-9]*")"
echo "::set-output name=BRANCH::$(echo "${GITHUB_REF#refs/*/}")"
id: gitVars

- name: Get latest svn revision from remote
Expand Down Expand Up @@ -228,14 +227,13 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

# cache disabled, becuse the Dockerfile has currently no cache compatible layout
# - 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-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
Expand All @@ -252,9 +250,8 @@ jobs:
file: ./Dockerfile
platforms: linux/amd64,linux/arm/v7,linux/arm64
push: true
# cache disabled, becuse the Dockerfile has currently no cache compatible layout
# cache-from: type=local,src=/tmp/.buildx-cache
# cache-to: type=local,dest=/tmp/.buildx-cache
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
tags: |
ghcr.io/${{ github.repository_owner }}/fhem-experimental:${{ steps.buildVars.outputs.TAG_ROLLING }}
Expand Down Expand Up @@ -286,9 +283,8 @@ jobs:
file: ./Dockerfile
platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64
push: true
# cache disabled, becuse the Dockerfile has currently no cache compatible layout
# cache-from: type=local,src=/tmp/.buildx-cache
# cache-to: type=local,dest=/tmp/.buildx-cache
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
tags: |
ghcr.io/${{ github.repository_owner }}/fhem-minimal-experimental:${{ steps.buildVars.outputs.TAG_ROLLING }}
Expand Down
Loading

0 comments on commit 5337cbe

Please sign in to comment.