MCPcopy Create free account
hub / github.com/TechJeeper/Printventory / pushImage

Function pushImage

scripts/docker-hub-push.js:92–138  ·  view source on GitHub ↗
(tag = null)

Source from the content-addressed store, hash-verified

90
91 // Tag as latest
92 if (!exec(`${runtime} tag ${fullImageName} ${latestTag}`)) {
93 console.error('Failed to tag image as latest');
94 process.exit(1);
95 }
96
97 console.log('');
98 console.log('✓ Container image tagged successfully');
99}
100
101function printPushAuthHelp() {
102 console.error('');
103 console.error('Docker Hub rejected the push (insufficient_scope or access denied). Try:');
104 console.error(' 1. docker logout');
105 console.error(` 2. docker login -u ${dockerHubUsername}`);
106 console.error(' Use a Personal Access Token as the password (not your account password):');
107 console.error(' https://hub.docker.com/settings/security');
108 console.error(' Token permissions: Read, Write, Delete');
109 console.error(` 3. Confirm DOCKER_HUB_USERNAME matches your Hub account (${dockerHubUsername})`);
110 console.error(' 4. npm run docker:push');
111 console.error('');
112}
113
114// Push image to Docker Hub
115function pushImage(tag = null) {
116 const tagsToPush = tag ? [tag] : [versionTag, latestTag];
117
118 console.log('Pushing Docker image to Docker Hub...');
119 console.log(`Repository: ${fullImageName}`);
120 console.log('');
121
122 const runtime = containerRuntime.getRuntime();
123 // Check if the container runtime is available and responsive
124 try {
125 containerRuntime.runQuiet('info');
126 } catch (error) {
127 console.error(`Error: ${containerRuntime.getRuntimeLabel()} is not running or not logged in to Docker Hub`);
128 console.error(`Please run: ${containerRuntime.loginHint()}`);
129 process.exit(1);
130 }
131
132 if (containerRuntime.isPodmanOnWindows()) {
133 console.log('Syncing Docker Hub credentials into Podman VM...');
134 if (!containerRuntime.syncAuthToPodmanMachine()) {
135 process.exit(1);
136 }
137 console.log('');
138 }
139
140 for (const imageTag of tagsToPush) {
141 console.log(`Pushing ${imageTag}...`);

Callers 1

docker-hub-push.jsFile · 0.85

Calls 1

execFunction · 0.85

Tested by

no test coverage detected