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