Skip to content

Commit 17e595f

Browse files
committed
Eliminate redundant build
1 parent 40bdc4f commit 17e595f

File tree

3 files changed

+15
-31
lines changed

3 files changed

+15
-31
lines changed

.github/workflows/ci.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,6 @@ jobs:
6969
# - name: Run validation
7070
# run: golangci-lint run
7171

72-
- name: Build
73-
run: make build
74-
7572
- name: Package
7673
run: make package
7774

Makefile

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
.PHONY: all build test validate package package-helm clean
22

3-
all: build
3+
# The default target is to build and package everything
4+
all: package
45

6+
# build is now responsible for building the final image AND extracting the binary
57
build:
6-
@echo "--- Building webhook binary ---"
8+
@echo "--- Building Webhook Image & Binary ---"
79
@bash -c 'source scripts/version && \
8-
mkdir -p bin && \
910
docker build \
1011
--file package/Dockerfile \
11-
--target binary \
1212
--build-arg ARCH=$${ARCH} \
1313
--build-arg VERSION=$${VERSION} \
1414
--build-arg COMMIT=$${COMMIT} \
15-
-t rancher/webhook:binary-$${TAG} \
15+
-t rancher/webhook:$${TAG} \
1616
. && \
17-
CONTAINER_ID=$$(docker create rancher/webhook:binary-$${TAG} echo) && \
18-
docker cp $$CONTAINER_ID:/webhook ./bin/webhook && \
17+
mkdir -p bin && \
18+
CONTAINER_ID=$$(docker create rancher/webhook:$${TAG} echo) && \
19+
docker cp $$CONTAINER_ID:/usr/bin/webhook ./bin/webhook && \
1920
docker rm $$CONTAINER_ID'
2021

2122
test:
@@ -27,8 +28,14 @@ validate:
2728
package-helm:
2829
./scripts/package-helm
2930

31+
# package now depends on the build being complete, and just creates release artifacts
3032
package: build package-helm
31-
./scripts/package
33+
@echo "--- Packaging Release Artifacts ---"
34+
@bash -c 'source scripts/version && \
35+
mkdir -p dist && \
36+
chmod a+rwx dist && \
37+
docker save -o dist/rancher-webhook-image.tar rancher/webhook:$${TAG} && \
38+
echo IMAGE_TAG=$${TAG} > dist/image_tag'
3239

3340
clean:
3441
rm -rf bin dist

scripts/package

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)