From 1275ba1e23cb79521e250209a2789f45d774a654 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jussi=20R=C3=A4s=C3=A4nen?= Date: Sun, 19 May 2024 16:36:41 +0300 Subject: [PATCH] add layer caching, build args --- .github/workflows/docker-publish.yml | 22 +++++++++++++++------- Dockerfile | 16 ---------------- 2 files changed, 15 insertions(+), 23 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index c0bdb65..c3384e8 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -15,6 +15,7 @@ concurrency: env: REGISTRY: ghcr.io IMAGE_NAME: ${{ github.repository }} + WRITEFREELY_VERSION: v0.15.0 jobs: build: @@ -37,13 +38,14 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: Get metadata - id: meta - uses: docker/metadata-action@v5 + - uses: actions/cache@v3 with: - images: | - jrasanen/writefreely - ghcr.io/${{ github.repository }} + path: | + ~/.cache/go-build + ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- - name: Build and Push uses: docker/build-push-action@v5 @@ -52,5 +54,11 @@ jobs: file: ./Dockerfile push: true 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 + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/Dockerfile b/Dockerfile index e2caa9f..658f9bf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 . - ARG GOLANG_VERSION=1.22 # Build image