Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Makefile: scripts: Add build args for proxy when using docker build #385

Merged
merged 1 commit into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ IMG ?= controller:latest
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
ENVTEST_K8S_VERSION = 1.24.2

http_proxy := ""
https_proxy := ""

# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
GOBIN=$(shell go env GOPATH)/bin
Expand Down Expand Up @@ -143,9 +146,9 @@ run: manifests generate fmt vet ## Run a controller from your host.
docker-build: test ## Build docker image with the manager.
ifneq (, $(PEERPODS))
@echo PEERPODS is enabled
docker build -t ${IMG} -f Dockerfile.peerpods .
docker build --build-arg http_proxy=$(http_proxy) --build-arg https_proxy=$(https_proxy) -t ${IMG} -f Dockerfile.peerpods .
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a reason why this approach was chosen over the better alternative which just setting the ~/.docker/config.json?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mythi I have the proxies at the config but seems that when building the dockerfile is still failing without those arguments

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't prefer this approach. It'd be good to understand why the best option does not work

else
docker build -t ${IMG} .
docker build --build-arg http_proxy=$(http_proxy) --build-arg https_proxy=$(https_proxy) -t ${IMG} .
endif

.PHONY: docker-push
Expand Down Expand Up @@ -270,7 +273,7 @@ bundle: manifests kustomize operator-sdk## Generate bundle manifests and metadat

.PHONY: bundle-build
bundle-build: ## Build the bundle image.
docker build -f bundle.Dockerfile -t $(BUNDLE_IMG) .
docker build --build-arg http_proxy=$(http_proxy) --build-arg https_proxy=$(https_proxy) -f bundle.Dockerfile -t $(BUNDLE_IMG) .

.PHONY: bundle-push
bundle-push: ## Push the bundle image.
Expand Down
4 changes: 4 additions & 0 deletions install/pre-install-payload/payload.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ vfio_gpu_containerd_repo=${vfio_gpu_containerd_repo:-"https://github.com/confide
nydus_snapshotter_repo=${nydus_snapshotter_repo:-"https://github.com/containerd/nydus-snapshotter"}
containerd_dir="$(mktemp -d -t containerd-XXXXXXXXXX)/containerd"
extra_docker_manifest_flags="${extra_docker_manifest_flags:-}"
http_proxy="${http_proxy:-}"
https_proxy="${https_proxy:-}"

registry="${registry:-quay.io/confidential-containers/reqs-payload}"

Expand Down Expand Up @@ -59,6 +61,8 @@ function build_payload() {

echo "Building containerd payload image for ${arch}"
docker buildx build \
--build-arg HTTP_PROXY="${http_proxy}" \
--build-arg HTTPS_PROXY="${https_proxy}" \
--build-arg ARCH="${golang_arch}" \
--build-arg COCO_CONTAINERD_VERSION="${coco_containerd_version}" \
--build-arg COCO_CONTAINERD_REPO="${coco_containerd_repo}" \
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/run-local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ undo_changes() {

if [ $step_bootstrap_env -eq 1 ]; then
echo "::info:: Undo the bootstrap"
run 5m ansible-playbook -i localhost, -c local --tags undo ansible/main.yaml || true
run 5m sudo -E ansible-playbook -i localhost, -c local --tags undo ansible/main.yaml || true
fi
popd >/dev/null
}
Expand Down Expand Up @@ -102,7 +102,7 @@ main() {
pushd "$script_dir" >/dev/null
echo "::info:: Bootstrap the local machine"
step_bootstrap_env=1
run 10m ansible-playbook -i localhost, -c local --tags untagged ansible/main.yaml
run 10m sudo -E ansible-playbook -i localhost, -c local --tags untagged ansible/main.yaml

echo "::info:: Bring up the test cluster"
step_start_cluster=1
Expand Down
Loading