@@ -51,6 +51,23 @@ async function dockerBuild(func, variables) {
51
51
52
52
const id = func.$id;
53
53
54
+ const files = getAllFiles(functionDir).map((file) => path.relative(functionDir, file)).filter((file) => !ignorer.ignores(file));
55
+ const tmpBuildPath = path.join(functionDir, '.appwrite/tmp-build');
56
+ if (!fs.existsSync(tmpBuildPath)) {
57
+ fs.mkdirSync(tmpBuildPath, { recursive: true });
58
+ }
59
+
60
+ for(const f of files) {
61
+ const filePath = path.join(tmpBuildPath, f);
62
+ const fileDir = path.dirname(filePath);
63
+ if (!fs.existsSync(fileDir)) {
64
+ fs.mkdirSync(fileDir, { recursive: true });
65
+ }
66
+
67
+ const sourcePath = path.join(functionDir, f);
68
+ fs.copyFileSync(sourcePath, filePath);
69
+ }
70
+
54
71
const params = [ 'run' ];
55
72
params.push('--name', id);
56
73
params.push('-v', `${tmpBuildPath}/:/mnt/code:rw`);
@@ -139,23 +156,6 @@ async function dockerStart(func, variables, port) {
139
156
ignorer.add(fs.readFileSync(path.join(functionDir, '.gitignore')).toString());
140
157
}
141
158
142
- const files = getAllFiles(functionDir).map((file) => path.relative(functionDir, file)).filter((file) => !ignorer.ignores(file));
143
- const tmpBuildPath = path.join(functionDir, '.appwrite/tmp-build');
144
- if (!fs.existsSync(tmpBuildPath)) {
145
- fs.mkdirSync(tmpBuildPath, { recursive: true });
146
- }
147
-
148
- for(const f of files) {
149
- const filePath = path.join(tmpBuildPath, f);
150
- const fileDir = path.dirname(filePath);
151
- if (!fs.existsSync(fileDir)) {
152
- fs.mkdirSync(fileDir, { recursive: true });
153
- }
154
-
155
- const sourcePath = path.join(functionDir, f);
156
- fs.copyFileSync(sourcePath, filePath);
157
- }
158
-
159
159
const runtimeChunks = func.runtime.split("-");
160
160
const runtimeVersion = runtimeChunks.pop();
161
161
const runtimeName = runtimeChunks.join("-");
0 commit comments