diff --git a/binderhub/app.py b/binderhub/app.py index 4f6d44a15..3605e32ea 100755 --- a/binderhub/app.py +++ b/binderhub/app.py @@ -297,7 +297,7 @@ def _valid_badge_base_url(self, proposal): ) push_secret = Unicode( - 'binder-build-docker-config', + 'binder-push-secret', allow_none=True, help=""" A kubernetes secret object that provides credentials for pushing built images. @@ -375,22 +375,6 @@ def docker_build_host_validate(self, proposal): raise TraitError("Only unix domain sockets on same node are supported for build_docker_host") return proposal.value - build_docker_config = Dict( - None, - allow_none=True, - help=""" - A dict which will be merged into the .docker/config.json of the build container (repo2docker) - Here, you could for example pass proxy settings as described here: - https://docs.docker.com/network/proxy/#configure-the-docker-client - - Note: if you provide your own push_secret, this values wont - have an effect, as the push_secrets will overwrite - .docker/config.json - In this case, make sure that you include your config in your push_secret - """, - config=True - ) - hub_api_token = Unicode( help="""API token for talking to the JupyterHub API""", config=True, @@ -709,7 +693,6 @@ def initialize(self, *args, **kwargs): "build_memory_limit": self.build_memory_limit, "build_memory_request": self.build_memory_request, "build_docker_host": self.build_docker_host, - "build_docker_config": self.build_docker_config, "base_url": self.base_url, "badge_base_url": self.badge_base_url, "static_path": os.path.join(HERE, "static"), diff --git a/binderhub/build.py b/binderhub/build.py index 235863ab2..7615fbfe6 100644 --- a/binderhub/build.py +++ b/binderhub/build.py @@ -248,9 +248,9 @@ def submit(self): )] if self.push_secret: - volume_mounts.append(client.V1VolumeMount(mount_path="/root/.docker", name='docker-config')) + volume_mounts.append(client.V1VolumeMount(mount_path="/root/.docker", name='docker-push-secret')) volumes.append(client.V1Volume( - name='docker-config', + name='docker-push-secret', secret=client.V1SecretVolumeSource(secret_name=self.push_secret) )) diff --git a/binderhub/builder.py b/binderhub/builder.py index 7f6aa1246..8998aad95 100644 --- a/binderhub/builder.py +++ b/binderhub/builder.py @@ -351,7 +351,7 @@ async def get(self, provider_prefix, _unescaped_spec): # Prepare to build q = Queue() - if self.settings['use_registry'] or self.settings['build_docker_config']: + if self.settings['use_registry']: push_secret = self.settings['push_secret'] else: push_secret = None diff --git a/helm-chart/binderhub/templates/_helpers.tpl b/helm-chart/binderhub/templates/_helpers.tpl index 39780deb0..dce2b26da 100644 --- a/helm-chart/binderhub/templates/_helpers.tpl +++ b/helm-chart/binderhub/templates/_helpers.tpl @@ -16,9 +16,9 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this {{- end -}} {{/* -Render docker config.json for the registry-publishing secret and other docker configuration. +Render docker config.json for the registry-publishing secret. */}} -{{- define "buildDockerConfig" -}} +{{- define "registryDockerConfig" -}} {{- /* default auth url */ -}} {{- $url := (default "https://index.docker.io/v1" .Values.registry.url) }} @@ -36,13 +36,11 @@ Render docker config.json for the registry-publishing secret and other docker co {{- end }} {{- $username := .Values.registry.username -}} -{{- /* initialize a dict to represent a docker config with registry credentials */}} -{{- $dockerConfig := dict "auths" (dict $url (dict "auth" (printf "%s:%s" $username .Values.registry.password | b64enc))) }} - -{{- /* augment our initialized docker config with buildDockerConfig */}} -{{- if .Values.config.BinderHub.buildDockerConfig }} -{{- $dockerConfig := merge $dockerConfig .Values.config.BinderHub.buildDockerConfig }} -{{- end }} - -{{- $dockerConfig | toPrettyJson }} +{ + "auths": { + "{{ $url }}": { + "auth": "{{ printf "%s:%s" $username .Values.registry.password | b64enc }}" + } + } +} {{- end }} diff --git a/helm-chart/binderhub/templates/secret.yaml b/helm-chart/binderhub/templates/secret.yaml index b8d4a8e4d..efb2d8d3c 100644 --- a/helm-chart/binderhub/templates/secret.yaml +++ b/helm-chart/binderhub/templates/secret.yaml @@ -16,12 +16,12 @@ data: {{- end }} values.yaml: {{ $values | toYaml | b64enc | quote }} --- -{{- if or .Values.config.BinderHub.use_registry .Values.config.BinderHub.buildDockerConfig }} +{{- if .Values.config.BinderHub.use_registry }} kind: Secret apiVersion: v1 metadata: - name: binder-build-docker-config + name: binder-push-secret type: Opaque data: - config.json: {{ include "buildDockerConfig" . | b64enc | quote }} + config.json: {{ include "registryDockerConfig" . | b64enc | quote }} {{- end }}