|
3 | 3 | # This is a very simple script to build and push the Docker image used by the |
4 | 4 | # Docker volume workspace driver. It's normally run from the "Publish Docker |
5 | 5 | # image dependencies" GitHub Action, but can be run locally if necessary. |
| 6 | +# It reuses Docker's existing authentication, set up by the workflow's OIDC |
| 7 | +# login or by running docker login locally. |
6 | 8 | # |
7 | 9 | # This script requires Python 3.8 or later, and Docker 19.03 (for buildx). You |
8 | 10 | # are strongly encouraged to use Black to format this file after modifying it. |
@@ -87,14 +89,6 @@ def docker_cli_build( |
87 | 89 | run(args, stdin=dockerfile) |
88 | 90 |
|
89 | 91 |
|
90 | | -def docker_cli_login(username: str, password: str): |
91 | | - run( |
92 | | - ["docker", "login", f"-u={username}", "--password-stdin"], |
93 | | - input=password, |
94 | | - text=True, |
95 | | - ) |
96 | | - |
97 | | - |
98 | 92 | def run(args: Sequence[str], /, **kwargs) -> subprocess.CompletedProcess: |
99 | 93 | print(f"+ {' '.join(args)}") |
100 | 94 | return subprocess.run(args, check=True, **kwargs) |
@@ -127,13 +121,6 @@ def main(): |
127 | 121 | tags = calculate_tags(args.ref) |
128 | 122 | print(f"will push tags: {', '.join(tags)}") |
129 | 123 |
|
130 | | - print("logging into Docker Hub") |
131 | | - try: |
132 | | - docker_cli_login(os.environ["DOCKER_USERNAME"], os.environ["DOCKER_PASSWORD"]) |
133 | | - except KeyError as e: |
134 | | - print(f"error retrieving environment variables: {e}") |
135 | | - raise |
136 | | - |
137 | 124 | print("building and pushing image") |
138 | 125 | docker_cli_build(open(args.dockerfile, "rb"), args.platform, args.image, tags) |
139 | 126 |
|
|
0 commit comments