Skip to content

Commit c064339

Browse files
committed
Distinguish "clean builds" and dev builds
It will save time during rebuilds for the developers, since the current time isn't passed to the go build anymore, which was previously forcing to refresh the docker layers
1 parent ea2650d commit c064339

File tree

5 files changed

+15
-25
lines changed

5 files changed

+15
-25
lines changed

.github/workflows/push_image.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ jobs:
3535
run: echo "short_sha=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
3636
- name: build and push manifest with images
3737
run: |
38-
MULTIARCH_TARGETS="${{ env.WF_MULTIARCH_TARGETS }}" IMAGE_ORG=${{ env.WF_ORG }} VERSION=${{ env.WF_VERSION }} make images
39-
MULTIARCH_TARGETS="${{ env.WF_MULTIARCH_TARGETS }}" IMAGE_ORG=${{ env.WF_ORG }} VERSION=${{ env.short_sha }} OCI_BUILD_OPTS="--label quay.expires-after=2w" make images
38+
MULTIARCH_TARGETS="${{ env.WF_MULTIARCH_TARGETS }}" IMAGE_ORG=${{ env.WF_ORG }} VERSION=${{ env.WF_VERSION }} CLEAN_BUILD=1 make images
39+
MULTIARCH_TARGETS="${{ env.WF_MULTIARCH_TARGETS }}" IMAGE_ORG=${{ env.WF_ORG }} VERSION=${{ env.short_sha }} CLEAN_BUILD=1 OCI_BUILD_OPTS="--label quay.expires-after=2w" make images
4040
if [[ "main" == "$WF_VERSION" ]]; then
41-
MULTIARCH_TARGETS="${{ env.WF_MULTIARCH_TARGETS }}" IMAGE_ORG=${{ env.WF_ORG }} VERSION=latest make images
41+
MULTIARCH_TARGETS="${{ env.WF_MULTIARCH_TARGETS }}" IMAGE_ORG=${{ env.WF_ORG }} VERSION=latest CLEAN_BUILD=1 make images
4242
fi
4343
- name: build and push manifest with images for standalone build
4444
run: |
45-
MULTIARCH_TARGETS="${{ env.WF_MULTIARCH_TARGETS }}" IMAGE_ORG=${{ env.WF_ORG }} VERSION=${{ env.WF_VERSION }} STANDALONE=true make images
45+
MULTIARCH_TARGETS="${{ env.WF_MULTIARCH_TARGETS }}" IMAGE_ORG=${{ env.WF_ORG }} VERSION=${{ env.WF_VERSION }} CLEAN_BUILD=1 STANDALONE=true make images
4646
4747
codecov-back:
4848
name: Codecov backend upload

.github/workflows/push_image_pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
- name: get short sha
3838
run: echo "short_sha=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
3939
- name: build and push manifest with images
40-
run: OCI_BUILD_OPTS="--label quay.expires-after=2w" IMAGE_ORG=${{ env.WF_ORG }} IMAGE=${{ env.WF_REGISTRY }}/${{ env.WF_IMAGE }}:${{ env.short_sha }} make images
40+
run: OCI_BUILD_OPTS="--label quay.expires-after=2w" IMAGE_ORG=${{ env.WF_ORG }} IMAGE=${{ env.WF_REGISTRY }}/${{ env.WF_IMAGE }}:${{ env.short_sha }} CLEAN_BUILD=1 make images
4141
- uses: actions/github-script@v6
4242
with:
4343
github-token: ${{secrets.GITHUB_TOKEN}}

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@ jobs:
4242
password: ${{ secrets.QUAY_SECRET }}
4343
registry: quay.io
4444
- name: build and push manifest with images
45-
run: MULTIARCH_TARGETS="${{ env.WF_MULTIARCH_TARGETS }}" IMAGE_ORG=${{ env.WF_ORG }} VERSION=${{ env.tag }} make images
45+
run: MULTIARCH_TARGETS="${{ env.WF_MULTIARCH_TARGETS }}" IMAGE_ORG=${{ env.WF_ORG }} VERSION=${{ env.tag }} CLEAN_BUILD=1 make images

Dockerfile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,20 @@ RUN npm run build$BUILDSCRIPT
2424

2525
FROM docker.io/library/golang:1.22 as go-builder
2626

27-
ARG TARGETPLATFORM
2827
ARG TARGETARCH=amd64
2928
ARG LDFLAGS
29+
3030
WORKDIR /opt/app-root
3131

3232
COPY go.mod go.mod
3333
COPY go.sum go.sum
3434
COPY vendor/ vendor/
35-
COPY .mk/ .mk/
3635
COPY cmd/ cmd/
3736
COPY pkg/ pkg/
3837

3938
RUN CGO_ENABLED=0 GOARCH=$TARGETARCH go build -ldflags "$LDFLAGS" -mod vendor -o plugin-backend cmd/plugin-backend.go
4039

41-
FROM --platform=linux/$TARGETARCH registry.access.redhat.com/ubi9/ubi-minimal:9.4
40+
FROM --platform=linux/$TARGETARCH registry.access.redhat.com/ubi9/ubi-minimal:9.4
4241

4342
COPY --from=web-builder /opt/app-root/web/dist ./web/dist
4443
COPY --from=go-builder /opt/app-root/plugin-backend ./

Makefile

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,6 @@
44
# - use the VERSION as arg of the bundle target (e.g make bundle VERSION=0.0.2)
55
# - use environment variables to overwrite this value (e.g export VERSION=0.0.2)
66
VERSION ?= main
7-
BUILD_DATE := $(shell date +%Y-%m-%d\ %H:%M)
8-
TAG_COMMIT := $(shell git rev-list --abbrev-commit --tags --max-count=1)
9-
TAG := $(shell git describe --abbrev=0 --tags ${TAG_COMMIT} 2>/dev/null || true)
10-
BUILD_SHA := $(shell git rev-parse --short HEAD)
11-
BUILD_VERSION := $(TAG:v%=%)
12-
ifneq ($(COMMIT), $(TAG_COMMIT))
13-
BUILD_VERSION := $(BUILD_VERSION)-$(BUILD_SHA)
14-
endif
15-
ifneq ($(shell git status --porcelain),)
16-
BUILD_VERSION := $(BUILD_VERSION)-dirty
17-
endif
187

198
# Go architecture and targets images to build
209
GOARCH ?= amd64
@@ -41,18 +30,20 @@ endif
4130
# Image URL to use all building/pushing image targets
4231
IMAGE ?= ${IMAGE_TAG_BASE}:${VERSION}
4332

44-
OCI_BUILD_OPTS ?=
45-
4633
# Image building tool (docker / podman) - docker is preferred in CI
4734
OCI_BIN_PATH = $(shell which docker 2>/dev/null || which podman)
4835
OCI_BIN ?= $(shell basename ${OCI_BIN_PATH})
36+
OCI_BUILD_OPTS ?=
37+
38+
ifneq ($(CLEAN_BUILD),)
39+
BUILD_DATE := $(shell date +%Y-%m-%d\ %H:%M)
40+
BUILD_SHA := $(shell git rev-parse --short HEAD)
41+
LDFLAGS ?= -X 'main.buildVersion=${VERSION}-${BUILD_SHA}' -X 'main.buildDate=${BUILD_DATE}'
42+
endif
4943

5044
GOLANGCI_LINT_VERSION = v1.53.3
5145
NPM_INSTALL ?= install
5246
CMDLINE_ARGS ?= --loglevel trace --config config/config.yaml
53-
LDFLAGS := -X 'main.buildVersion=${BUILD_VERSION}' -X 'main.buildDate=${BUILD_DATE}'
54-
# You can add GO Build flags like -gcflags=all="-N -l" here to remove optimizations for debugging
55-
BUILD_FLAGS ?= -ldflags "${LDFLAGS}"
5647

5748
.DEFAULT_GOAL := help
5849

0 commit comments

Comments
 (0)