add layer caching, build args

This commit is contained in:
Jussi Räsänen 2024-05-19 16:36:41 +03:00
parent 2caf947ab4
commit 1275ba1e23
No known key found for this signature in database
GPG key ID: 973AC6ACBE3D307D
2 changed files with 15 additions and 23 deletions

View file

@ -15,6 +15,7 @@ concurrency:
env: env:
REGISTRY: ghcr.io REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }} IMAGE_NAME: ${{ github.repository }}
WRITEFREELY_VERSION: v0.15.0
jobs: jobs:
build: build:
@ -37,13 +38,14 @@ jobs:
- name: Set up Docker Buildx - name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
- name: Get metadata - uses: actions/cache@v3
id: meta
uses: docker/metadata-action@v5
with: with:
images: | path: |
jrasanen/writefreely ~/.cache/go-build
ghcr.io/${{ github.repository }} ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Build and Push - name: Build and Push
uses: docker/build-push-action@v5 uses: docker/build-push-action@v5
@ -52,5 +54,11 @@ jobs:
file: ./Dockerfile file: ./Dockerfile
push: true push: true
labels: ${{ steps.meta.outputs.labels }} labels: ${{ steps.meta.outputs.labels }}
tags: ${{ steps.meta.outputs.tags }} build-args: |
WRITEFREELY_VERSION=${{ env.WRITEFREELY_VERSION }}
tags: |
${{ env.DOCKERHUB_REPO }}:${{ env.WRITEFREELY_VERSION }}
${{ env.DOCKERHUB_REPO }}:latest
platforms: linux/amd64,linux/arm64 platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max

View file

@ -1,19 +1,3 @@
## Writefreely Docker image
## Copyright (C) 2019, 2020 Gergely Nagy
##
## This program is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program. If not, see <http://www.gnu.org/licenses/>.
ARG GOLANG_VERSION=1.22 ARG GOLANG_VERSION=1.22
# Build image # Build image