Skip to content

Commit ffbfe24

Browse files
committed
Improve pulling and docker logs experience
1 parent 00efba2 commit ffbfe24

File tree

1 file changed

+28
-31
lines changed

1 file changed

+28
-31
lines changed

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

Lines changed: 28 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ const { openRuntimesVersion, systemTools } = 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) });
@@ -83,7 +64,11 @@ async function dockerBuild(func, variables) {
8364

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

8974
buildProcess.stdout.on('data', (data) => {
@@ -104,7 +89,11 @@ async function dockerBuild(func, variables) {
10489

10590
const copyProcess = childProcess.spawn('docker', ['cp', `${id}:/mnt/code/code.tar.gz`, copyPath], {
10691
stdio: 'pipe',
107-
pwd: functionDir
92+
pwd: functionDir,
93+
env: {
94+
...process.env,
95+
DOCKER_CLI_HINTS: 'false'
96+
}
10897
});
10998

11099
await new Promise((res) => { copyProcess.on('close', res) });
@@ -149,7 +138,11 @@ async function dockerStart(func, variables, port) {
149138

150139
const startProcess = childProcess.spawn('docker', params, {
151140
stdio: 'pipe',
152-
pwd: functionDir
141+
pwd: functionDir,
142+
env: {
143+
...process.env,
144+
DOCKER_CLI_HINTS: 'false'
145+
}
153146
});
154147

155148
startProcess.stdout.on('data', (data) => {
@@ -183,6 +176,10 @@ async function dockerCleanup() {
183176
async function dockerStopActive() {
184177
const listProcess = childProcess.spawn('docker', ['ps', '-a', '-q', '--filter', 'label=appwrite-env=dev'], {
185178
stdio: 'pipe',
179+
env: {
180+
...process.env,
181+
DOCKER_CLI_HINTS: 'false'
182+
}
186183
});
187184

188185
const ids = [];

0 commit comments

Comments
 (0)