@@ -72,7 +72,6 @@ async function dockerBuild(func, variables) {
72
72
params.push('-e', 'APPWRITE_ENV=development');
73
73
params.push('-e', 'OPEN_RUNTIMES_ENV=development');
74
74
params.push('-e', 'OPEN_RUNTIMES_SECRET=');
75
- params.push('-l', 'appwrite-env=dev');
76
75
params.push('-e', `OPEN_RUNTIMES_ENTRYPOINT=${func.entrypoint}`);
77
76
78
77
for(const k of Object.keys(variables)) {
@@ -133,7 +132,6 @@ async function dockerStart(func, variables, port) {
133
132
params.push('--rm');
134
133
params.push('--name', id);
135
134
params.push('-p', `${port}:3000`);
136
- params.push('-l', 'appwrite-env=dev');
137
135
params.push('-e', 'APPWRITE_ENV=development');
138
136
params.push('-e', 'OPEN_RUNTIMES_ENV=development');
139
137
params.push('-e', 'OPEN_RUNTIMES_SECRET=');
@@ -163,50 +161,18 @@ async function dockerStart(func, variables, port) {
163
161
success(`Visit http://localhost:${port}/ to execute your function.`);
164
162
}
165
163
166
- async function dockerCleanup() {
167
- await dockerStopActive( );
164
+ async function dockerCleanup(functionId ) {
165
+ await dockerStop(functionId );
168
166
169
- const functions = localConfig.getFunctions();
170
- for(const func of functions) {
171
- const appwritePath = path.join(process.cwd(), func.path, '.appwrite');
172
- if (fs.existsSync(appwritePath)) {
173
- fs.rmSync(appwritePath, { recursive: true, force: true });
174
- }
175
-
176
- const tempPath = path.join(process.cwd(), func.path, 'code.tar.gz');
177
- if (fs.existsSync(tempPath)) {
178
- fs.rmSync(tempPath, { force: true });
179
- }
180
- }
181
- }
182
-
183
- async function dockerStopActive() {
184
- const listProcess = childProcess.spawn('docker', ['ps', '-a', '-q', '--filter', 'label=appwrite-env=dev'], {
185
- stdio: 'pipe',
186
- });
187
-
188
- const ids = [];
189
- function handleOutput(data) {
190
- const list = data.toString().split('\n');
191
- for(const id of list) {
192
- if(id && !id.includes(' ')) {
193
- ids.push(id);
194
- }
195
- }
167
+ const func = localConfig.getFunction(functionId);
168
+ const appwritePath = path.join(process.cwd(), func.path, '.appwrite');
169
+ if (fs.existsSync(appwritePath)) {
170
+ fs.rmSync(appwritePath, { recursive: true, force: true });
196
171
}
197
172
198
- listProcess.stdout.on('data', (data) => {
199
- handleOutput(data);
200
- });
201
-
202
- listProcess.stderr.on('data', (data) => {
203
- handleOutput(data);
204
- });
205
-
206
- await new Promise((res) => { listProcess.on('close', res) });
207
-
208
- for(const id of ids) {
209
- await dockerStop(id);
173
+ const tempPath = path.join(process.cwd(), func.path, 'code.tar.gz');
174
+ if (fs.existsSync(tempPath)) {
175
+ fs.rmSync(tempPath, { force: true });
210
176
}
211
177
}
212
178
@@ -215,6 +181,5 @@ module.exports = {
215
181
dockerBuild,
216
182
dockerStart,
217
183
dockerCleanup,
218
- dockerStopActive,
219
184
dockerStop,
220
185
}
0 commit comments