Path: blob/main/components/dashboard/src/repositories/detail/variables/EnableDockerdAuthentication.tsx
2502 views
/**1* Copyright (c) 2025 Gitpod GmbH. All rights reserved.2* Licensed under the GNU Affero General Public License (AGPL).3* See License.AGPL.txt in the project root for license information.4*/56import { SwitchInputField } from "@podkit/switch/Switch";7import { Heading3, Subheading } from "@podkit/typography/Headings";8import { FC, useCallback } from "react";9import { InputField } from "../../../components/forms/InputField";10import { useToast } from "../../../components/toasts/Toasts";11import { useId } from "../../../hooks/useId";12import { ConfigurationSettingsField } from "../ConfigurationSettingsField";13import { Configuration } from "@gitpod/public-api/lib/gitpod/v1/configuration_pb";14import { SquareArrowOutUpRight } from "lucide-react";15import { useConfiguration, useConfigurationMutation } from "../../../data/configurations/configuration-queries";16import Alert from "../../../components/Alert";1718type Props = {19configuration: Configuration;20};21export const EnableDockerdAuthentication: FC<Props> = ({ configuration }) => {22const { data } = useConfiguration(configuration.id);23const configurationMutation = useConfigurationMutation();24const { toast } = useToast();2526const updateEnableDockerdAuthentication = useCallback(27async (enable: boolean) => {28await configurationMutation.mutateAsync(29{30configurationId: configuration.id,31workspaceSettings: {32enableDockerdAuthentication: enable,33},34},35{36onError: (error) => {37toast(`Failed to update dockerd authentication: ${error.message}`);38},39},40);41},42[configurationMutation, configuration.id, toast],43);4445const inputId = useId({ prefix: "enable-dockerd-authentication" });46const isEnabled = data?.workspaceSettings?.enableDockerdAuthentication;4748return (49<ConfigurationSettingsField>50<Heading3 className="flex flex-row items-center gap-2">Docker registry authentication</Heading3>51<Subheading className="max-w-lg flex flex-col gap-2">52<span className="flex-1 text-left">53Enable authentication with Docker registries inside of workspaces based on the{" "}54<code>GITPOD_IMAGE_AUTH</code> environment variable.55</span>5657<Alert type={"warning"} closable={false} showIcon={true} className="flex rounded p-2 mb-2 w-full">58By enabling this, credentials specified in <code>GITPOD_IMAGE_AUTH</code> will be visible inside all59workspaces on this project.60</Alert>61<a62className="gp-link flex flex-row items-center gap-1"63href="https://www.gitpod.io/docs/configure/repositories/environment-variables#docker-registry-authentication"64target="_blank"65rel="noreferrer"66>67Learn about using private Docker images with Gitpod68<SquareArrowOutUpRight size={12} />69</a>70</Subheading>71<InputField id={inputId}>72<SwitchInputField73id={inputId}74checked={isEnabled}75disabled={configurationMutation.isLoading}76onCheckedChange={updateEnableDockerdAuthentication}77label={isEnabled ? "Auto-login enabled" : "Auto-login disabled"}78/>79</InputField>80</ConfigurationSettingsField>81);82};838485