Skip to content

Commit 550b56a

Browse files
Merge pull request #903 from appwrite/fix-cli-docker-image-pulling
Fix: Docker pulling logic
2 parents c3c060a + 9b01187 commit 550b56a

File tree

1 file changed

+24
-31
lines changed

1 file changed

+24
-31
lines changed

templates/cli/lib/emulation/docker.js.twig

Lines changed: 24 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ const { openRuntimesVersion, systemTools, Queue } = require("./utils");
99
async function dockerStop(id) {
1010
const stopProcess = childProcess.spawn('docker', ['rm', '--force', id], {
1111
stdio: 'pipe',
12+
env: {
13+
...process.env,
14+
DOCKER_CLI_HINTS: 'false'
15+
}
1216
});
1317

1418
await new Promise((res) => { stopProcess.on('close', res) });
@@ -20,37 +24,14 @@ async function dockerPull(func) {
2024
const runtimeName = runtimeChunks.join("-");
2125
const imageName = `openruntimes/${runtimeName}:${openRuntimesVersion}-${runtimeVersion}`;
2226

23-
const checkProcess = childProcess.spawn('docker', ['images', '--format', 'json', imageName], {
24-
stdio: 'pipe',
25-
pwd: path.join(process.cwd(), func.path)
26-
});
27-
28-
let hasImage = false;
29-
30-
checkProcess.stdout.on('data', (data) => {
31-
if(data) {
32-
hasImage = false;
33-
}
34-
});
35-
36-
checkProcess.stderr.on('data', (data) => {
37-
if(data) {
38-
hasImage = false;
39-
}
40-
});
41-
42-
await new Promise((res) => { checkProcess.on('close', res) });
43-
44-
if(hasImage) {
45-
return;
46-
}
47-
48-
log('Pulling Docker image ...');
49-
hint('This may take a few minutes, but we only need to do this once.');
27+
log('Verifying Docker image ...');
5028

5129
const pullProcess = childProcess.spawn('docker', ['pull', imageName], {
5230
stdio: 'pipe',
53-
pwd: path.join(process.cwd(), func.path)
31+
env: {
32+
...process.env,
33+
DOCKER_CLI_HINTS: 'false'
34+
}
5435
});
5536

5637
await new Promise((res) => { pullProcess.on('close', res) });
@@ -82,7 +63,11 @@ async function dockerBuild(func, variables) {
8263

8364
const buildProcess = childProcess.spawn('docker', params, {
8465
stdio: 'pipe',
85-
pwd: functionDir
66+
pwd: functionDir,
67+
env: {
68+
...process.env,
69+
DOCKER_CLI_HINTS: 'false'
70+
}
8671
});
8772

8873
buildProcess.stdout.on('data', (data) => {
@@ -120,7 +105,11 @@ async function dockerBuild(func, variables) {
120105

121106
const copyProcess = childProcess.spawn('docker', ['cp', `${id}:/mnt/code/code.tar.gz`, copyPath], {
122107
stdio: 'pipe',
123-
pwd: functionDir
108+
pwd: functionDir,
109+
env: {
110+
...process.env,
111+
DOCKER_CLI_HINTS: 'false'
112+
}
124113
});
125114

126115
await new Promise((res) => { copyProcess.on('close', res) });
@@ -164,7 +153,11 @@ async function dockerStart(func, variables, port) {
164153

165154
const startProcess = childProcess.spawn('docker', params, {
166155
stdio: 'pipe',
167-
pwd: functionDir
156+
pwd: functionDir,
157+
env: {
158+
...process.env,
159+
DOCKER_CLI_HINTS: 'false'
160+
}
168161
});
169162

170163
startProcess.stdout.on('data', (data) => {

0 commit comments

Comments
 (0)