Skip to content

Commit e911585

Browse files
committed
chore(build): build binaries locally and load them into containers
this significantly speeds up build/run time for local e2e
1 parent 9ee66d0 commit e911585

File tree

3 files changed

+20
-8
lines changed

3 files changed

+20
-8
lines changed

Makefile

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,16 @@ build: clean $(CMDS)
4444
build-coverage: build_cmd=test -c -covermode=count -coverpkg ./pkg/controller/...
4545
build-coverage: clean $(CMDS)
4646

47+
build-linux: build_cmd=build
48+
build-linux: arch_flags=GOOS=linux GOARCH=386
49+
build-linux: clean $(CMDS)
50+
4751
$(CMDS): version_flags=-ldflags "-w -X $(PKG)/pkg/version.GitCommit=`git rev-parse --short HEAD` -X $(PKG)/pkg/version.OLMVersion=`cat OLM_VERSION`"
4852
$(CMDS):
49-
CGO_ENABLED=0 go $(build_cmd) $(MOD_FLAGS) $(version_flags) -o $@ $(PKG)/cmd/$(shell basename $@);
53+
CGO_ENABLED=0 $(arch_flags) go $(build_cmd) $(MOD_FLAGS) $(version_flags) -o $@ $(PKG)/cmd/$(shell basename $@);
5054

51-
run-local:
55+
run-local: build-linux
56+
rm -rf build
5257
. ./scripts/build_local.sh
5358
mkdir -p build/resources
5459
. ./scripts/package_release.sh 1.0.0 build/resources Documentation/install/local-values.yaml
@@ -73,7 +78,7 @@ setup-bare: clean e2e.namespace
7378
e2e:
7479
go test -v -failfast -timeout 70m ./test/e2e/... -namespace=openshift-operators -kubeconfig=${KUBECONFIG} -olmNamespace=openshift-operator-lifecycle-manager
7580

76-
e2e-local:
81+
e2e-local: build-linux
7782
. ./scripts/build_local.sh
7883
. ./scripts/run_e2e_local.sh $(TEST)
7984

local.Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM alpine:latest
2+
WORKDIR /
3+
COPY olm /bin/olm
4+
COPY catalog /bin/catalog
5+
COPY package-server /bin/package-server
6+
EXPOSE 8080
7+
EXPOSE 5443
8+
CMD ["/bin/olm"]

scripts/build_local.sh

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,15 @@
55

66
set -e
77

8-
if [ -z "$NO_MINIKUBE" ]; then
8+
if [ -z "$NO_MINIKUBE" ] || [ -x "$(command -v minikube)" ]; then
99
ps x | grep -q [m]inikube || minikube start --kubernetes-version="v1.12.0" --extra-config=apiserver.v=4 || { echo 'Cannot start minikube.'; exit 1; }
1010
eval $(minikube docker-env) || { echo 'Cannot switch to minikube docker'; exit 1; }
1111
kubectl config use-context minikube
1212
fi
13-
docker build -f upstream.Dockerfile .
14-
docker tag $(docker images --filter 'label=stage=olm' --format '{{.CreatedAt}}\t{{.ID}}' | sort -nr | head -n 1 | cut -f2) quay.io/operator-framework/olm:local
15-
docker tag $(docker images --filter 'label=stage=builder' --format '{{.CreatedAt}}\t{{.ID}}' | sort -nr | head -n 1 | cut -f2) quay.io/operator-framework/olm-e2e:local
1613

17-
if [ -x "$(command -v kind)" ]; then
14+
docker build -f local.Dockerfile -t quay.io/operator-framework/olm:local -t quay.io/operator-framework/olm-e2e:local ./bin
15+
16+
if [ -x "$(command -v kind)" ] && [ "kubectl config current-context" -eq "kind" ]; then
1817
kind load docker-image quay.io/operator-framework/olm:local
1918
kind load docker-image quay.io/operator-framework/olm-e2e:local
2019
fi

0 commit comments

Comments
 (0)