mirror of https://github.com/0xERR0R/blocky.git
Build Cache Optimization (#1402)
* don't copy if we mount the files anyway * use newer alpine version * cache apk pkgs * changeing workdir is not needed in ziggoimg * cache some more * preload go modules
This commit is contained in:
parent
ca7497897e
commit
7eef4bf6e2
|
@ -55,6 +55,10 @@ jobs:
|
||||||
with:
|
with:
|
||||||
go-version-file: go.mod
|
go-version-file: go.mod
|
||||||
|
|
||||||
|
- name: Download dependencies
|
||||||
|
run: go mod download
|
||||||
|
if: matrix.go == true
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
if: matrix.docker == true
|
if: matrix.docker == true
|
||||||
|
|
22
Dockerfile
22
Dockerfile
|
@ -2,8 +2,10 @@
|
||||||
|
|
||||||
# ----------- stage: ca-certs
|
# ----------- stage: ca-certs
|
||||||
# get newest certificates in seperate stage for caching
|
# get newest certificates in seperate stage for caching
|
||||||
FROM --platform=$BUILDPLATFORM alpine:3.16 AS ca-certs
|
FROM --platform=$BUILDPLATFORM alpine:3 AS ca-certs
|
||||||
RUN apk add --no-cache ca-certificates
|
RUN --mount=type=cache,target=/var/cache/apk \
|
||||||
|
apk update && \
|
||||||
|
apk add ca-certificates
|
||||||
|
|
||||||
# update certificates and use the apk ones if update fails
|
# update certificates and use the apk ones if update fails
|
||||||
RUN --mount=type=cache,target=/etc/ssl/certs \
|
RUN --mount=type=cache,target=/etc/ssl/certs \
|
||||||
|
@ -16,17 +18,15 @@ FROM --platform=$BUILDPLATFORM ghcr.io/kwitsch/ziggoimg AS build
|
||||||
ARG VERSION
|
ARG VERSION
|
||||||
ARG BUILD_TIME
|
ARG BUILD_TIME
|
||||||
|
|
||||||
# set working directory
|
|
||||||
WORKDIR /go/src
|
|
||||||
|
|
||||||
# download packages
|
# download packages
|
||||||
COPY go.mod go.sum ./
|
# bind mount go.mod and go.sum
|
||||||
RUN --mount=type=cache,target=/go/pkg \
|
# use cache for go packages
|
||||||
|
RUN --mount=type=bind,source=go.sum,target=go.sum \
|
||||||
|
--mount=type=bind,source=go.mod,target=go.mod \
|
||||||
|
--mount=type=cache,target=/root/.cache/go-build \
|
||||||
|
--mount=type=cache,target=/go/pkg \
|
||||||
go mod download
|
go mod download
|
||||||
|
|
||||||
# add source
|
|
||||||
COPY . .
|
|
||||||
|
|
||||||
# setup go
|
# setup go
|
||||||
ENV GO_SKIP_GENERATE=1\
|
ENV GO_SKIP_GENERATE=1\
|
||||||
GO_BUILD_FLAGS="-tags static -v " \
|
GO_BUILD_FLAGS="-tags static -v " \
|
||||||
|
@ -35,6 +35,8 @@ ENV GO_SKIP_GENERATE=1\
|
||||||
BIN_OUT_DIR="/bin"
|
BIN_OUT_DIR="/bin"
|
||||||
|
|
||||||
# build binary
|
# build binary
|
||||||
|
# bind mount source code
|
||||||
|
# use cache for go packages
|
||||||
RUN --mount=type=bind,target=. \
|
RUN --mount=type=bind,target=. \
|
||||||
--mount=type=cache,target=/root/.cache/go-build \
|
--mount=type=cache,target=/root/.cache/go-build \
|
||||||
--mount=type=cache,target=/go/pkg \
|
--mount=type=cache,target=/go/pkg \
|
||||||
|
|
Loading…
Reference in New Issue