Allow the usage of mirror registries/repositories in all/most places#984
Allow the usage of mirror registries/repositories in all/most places#984mozesl-nokia wants to merge 9 commits into
Conversation
Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
There was a problem hiding this comment.
Pull request overview
This PR adds environment-variable-driven registry/mirror overrides for development builds, deployment scripts, kpt functions, and DB tests so contributors can work behind registry/proxy restrictions.
Changes:
- Adds
.env/environment support for GHCR, Docker Hub, and Maven mirror configuration. - Replaces hardcoded kpt function and Docker base image registries with configurable prefixes.
- Extends DB tests and dev setup scripts to consume mirror-related environment variables.
Reviewed changes
Copilot reviewed 24 out of 25 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
.env.template |
Documents mirror-related environment variables. |
Makefile |
Exports registry mirror defaults and adds dump-env. |
build/Dockerfile |
Makes Docker Hub base images configurable. |
build/Dockerfile.apiserver |
Adds usage TODO comment. |
build/Dockerfile.etcd |
Adds usage TODO comment. |
build/Makefile |
Passes Docker Hub mirror build args. |
controllers/Dockerfile |
Makes builder base image configurable. |
controllers/Makefile |
Passes Docker Hub mirror build args. |
func/Dockerfile |
Makes kpt function and base image registries configurable. |
func/Dockerfile-wrapperserver |
Makes base images configurable. |
func/Makefile |
Passes mirror-related build args. |
go.mod |
Adds godotenv dependency. |
go.sum |
Adds checksums for godotenv. |
make/deploy.mk |
Adjusts setup-dev-env help placement. |
pkg/cache/dbcache/dbcache_test.go |
Loads .env and applies Maven mirror to embedded Postgres. |
scripts/common.sh |
Loads .env and centralizes mirror defaults. |
scripts/create-deployment-blueprint.sh |
Uses configurable kpt function images and env-based Docker Hub mirror. |
scripts/create-deployment-config.sh |
Passes GHCR prefix to deployment blueprint generation. |
scripts/create-deployment-kpt.sh |
Uses configurable kpt function images. |
scripts/install-dev-gitea-setup.sh |
Sources common config and applies mirrors to Gitea setup. |
scripts/remove-controller-from-deployment-config.sh |
Uses configurable kpt function image prefix. |
scripts/remove-porch-server-from-deployment-config.sh |
Uses configurable kpt function image prefix. |
scripts/run-load-test.sh |
Uses configurable kpt function image prefix. |
test/Dockerfile |
Adds usage TODO comment. |
test/Makefile |
Adds usage TODO comment. |
Comments suppressed due to low confidence (1)
scripts/create-deployment-kpt.sh:136
- This is another
PORCH_GHCR_PREFIX_URLuse in aset -uscript that never initializes the variable. A direct run without the env var fails here before deployment customization can proceed.
--image "${PORCH_GHCR_PREFIX_URL}/starlark:v0.5.5" \
Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 25 out of 26 changed files in this pull request and generated 8 comments.
Comments suppressed due to low confidence (4)
func/Makefile:55
- Same issue in the push target: the continued lines of this recipe need to be tab-indented as well, otherwise
makewill not parse this rule correctly.
docker buildx build --push --tag $(IMAGE_REPO)/$(IMAGE_NAME):$(IMAGE_TAG) \
--build-arg ALPINE_VERSION=$(ALPINE_VERSION) \
--build-arg GOLANG_ALPINE_VERSION=$(GOLANG_ALPINE_VERSION) \
$$(if [ -n "${DOCKERHUB_MIRROR}" ]; then echo "--build-arg DOCKERHUB_MIRROR=${DOCKERHUB_MIRROR}"; fi) \
$$(if [ -n "${PORCH_GHCR_PREFIX_URL}" ]; then echo "--build-arg PORCH_GHCR_PREFIX_URL=${PORCH_GHCR_PREFIX_URL}"; fi) \
-f ./Dockerfile "$(PORCHDIR)"
controllers/Makefile:33
- Same parsing issue in
push-image docker-push: the continuation lines must start with a tab to be part of the recipe.
docker buildx build --push --tag $(IMAGE_REPO)/$(IMAGE_NAME):$(IMAGE_TAG) \
--build-arg ALPINE_VERSION=$(ALPINE_VERSION) \
--build-arg GOLANG_BOOKWORM_VERSION=$(GOLANG_BOOKWORM_VERSION) \
$$(if [ -n "${DOCKERHUB_MIRROR}" ]; then echo "--build-arg DOCKERHUB_MIRROR=${DOCKERHUB_MIRROR}"; fi) \
-f Dockerfile ..
build/Makefile:35
- Same parsing issue in
push-image docker-push: continuation lines must begin with a tab, otherwise this target won't run.
docker buildx build --push --tag $(IMAGE_REPO)/$(IMAGE_NAME):$(IMAGE_TAG) \
--build-arg ALPINE_VERSION=$(ALPINE_VERSION) \
--build-arg GOLANG_BOOKWORM_VERSION=$(GOLANG_BOOKWORM_VERSION) \
$$(if [ -n "${DOCKERHUB_MIRROR}" ]; then echo "--build-arg DOCKERHUB_MIRROR=${DOCKERHUB_MIRROR}"; fi) \
-f ./Dockerfile "$(PORCHDIR)"
test/Makefile:33
- Same parsing issue in
push-image docker-push: the continueddocker buildx buildlines must be tab-indented to be part of the recipe.
docker buildx build --push --tag $(IMAGE_REPO)/$(IMAGE_NAME):$(IMAGE_TAG) \
--build-arg GOLANG_BOOKWORM_VERSION=$(GOLANG_BOOKWORM_VERSION) \
$$(if [ -n "${DOCKERHUB_MIRROR}" ]; then echo "--build-arg DOCKERHUB_MIRROR=${DOCKERHUB_MIRROR}"; fi) \
-f Dockerfile ..
| ARG ALPINE_VERSION=latest | ||
| ARG GOLANG_BOOKWORM_VERSION=latest | ||
| ARG DOCKERHUB_MIRROR=docker.io | ||
|
|
||
| FROM golang:1.25.7-bookworm AS builder | ||
| FROM ${DOCKERHUB_MIRROR}/golang:${GOLANG_BOOKWORM_VERSION} AS builder | ||
|
|
There was a problem hiding this comment.
@aravindtga was this kept intentionally pinned, or was this just an oversight before?
| # PORCH_GHCR_PREFIX_URL=<custom registry>/kptdev/krm-functions-catalog | ||
| # DOCKERHUB_MIRROR=<mirror registry url> |
There was a problem hiding this comment.
That has been the name so far, but if the rest of the team wants to change it, sure
There was a problem hiding this comment.
I have no strong opinion, whatever you decide is fine.
|
Want to point this out from Copilot's comments: Do we want to rename the PORCH_GHCR_PREFIX_URL env var? |
Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
| _env_trim() { | ||
| local s="$1" | ||
| s="${s#"${s%%[![:space:]]*}"}" | ||
| s="${s%"${s##*[![:space:]]}"}" | ||
| printf '%s' "$s" | ||
| } | ||
| while IFS= read -r line || [[ -n "$line" ]]; do | ||
| [[ "$line" =~ ^[[:space:]]*# ]] && continue | ||
| [[ -z "${line//[[:space:]]/}" ]] && continue | ||
| [[ "$line" != *=* ]] && continue | ||
| key="${line%%=*}" | ||
| value="${line#*=}" | ||
| key="$(_env_trim "$key")" | ||
| value="$(_env_trim "$value")" | ||
| [[ -z "$key" ]] && continue | ||
| [[ -n "${!key+x}" ]] && continue | ||
| export "${key}=${value}" | ||
| done < "${PORCHDIR}/.env" | ||
| unset -f _env_trim | ||
| unset -v key value line |
Title
Allow the usage of mirror registries/repositories in all/most places
Description
Related Issue(s)
(I thought we opened (and fixed) an issue for this, but I cannot find it.)
Type of Change
Checklist
Testing Instructions (Optional)
make setup-dev-envmake run-in-kind-db-cachereload-serverandreload-function-runner, but please try your favourite make targets and scripts too to make sure they all work.Additional Notes (Optional)
AI Disclosure
I used Cursor CLI on Auto to generate the script to import .env vars in common.sh