Spaces:
Sleeping
Sleeping
Patrick Rathje
commited on
Commit
·
b1a5ae8
1
Parent(s):
3f5b212
Do not install everytime for new projects
Browse files- Dockerfile +2 -2
- app.py +4 -4
Dockerfile
CHANGED
|
@@ -20,8 +20,8 @@ ENV MC_PROJECT_DIR=/motion-canvas/my-animation
|
|
| 20 |
COPY docker/vite.config.ts ./vite.config.ts
|
| 21 |
|
| 22 |
# if we build here, we have to clean up the project every time before building a new one...
|
| 23 |
-
|
| 24 |
-
|
| 25 |
|
| 26 |
# clone examples
|
| 27 |
ENV MC_EXAMPLE_DIR=/motion-canvas/examples
|
|
|
|
| 20 |
COPY docker/vite.config.ts ./vite.config.ts
|
| 21 |
|
| 22 |
# if we build here, we have to clean up the project every time before building a new one...
|
| 23 |
+
RUN npm install
|
| 24 |
+
RUN npm run build
|
| 25 |
|
| 26 |
# clone examples
|
| 27 |
ENV MC_EXAMPLE_DIR=/motion-canvas/examples
|
app.py
CHANGED
|
@@ -27,6 +27,7 @@ def get_public_path(project_id):
|
|
| 27 |
|
| 28 |
def build_project(code):
|
| 29 |
# TODO: as soon as gradio supports states, we should keep the project_id for some time...
|
|
|
|
| 30 |
yield loading_project_path, "Preparing project...",
|
| 31 |
|
| 32 |
# generate a random uuid for the project
|
|
@@ -34,7 +35,7 @@ def build_project(code):
|
|
| 34 |
|
| 35 |
tmp_dir = os.path.join("/tmp/", project_id)
|
| 36 |
|
| 37 |
-
shutil.copytree(os.environ['MC_PROJECT_DIR'], tmp_dir, dirs_exist_ok=False)
|
| 38 |
acc_logs = ""
|
| 39 |
|
| 40 |
try:
|
|
@@ -45,7 +46,7 @@ def build_project(code):
|
|
| 45 |
f.write(code)
|
| 46 |
|
| 47 |
process = subprocess.Popen(
|
| 48 |
-
"npm
|
| 49 |
stdout=subprocess.PIPE,
|
| 50 |
stderr=subprocess.PIPE,
|
| 51 |
text=True,
|
|
@@ -95,7 +96,7 @@ def build_example(example_name):
|
|
| 95 |
continue
|
| 96 |
|
| 97 |
path = last[0]
|
| 98 |
-
assert path
|
| 99 |
return path
|
| 100 |
|
| 101 |
print("Building examples...")
|
|
@@ -127,7 +128,6 @@ print("Examples built!")
|
|
| 127 |
def load_example(example):
|
| 128 |
return example['project_path'], example['code'], ""
|
| 129 |
|
| 130 |
-
|
| 131 |
with gr.Blocks(theme=gr.themes.Monochrome()) as demo:
|
| 132 |
gr.Markdown("# Motion Canvas MCP Server")
|
| 133 |
with gr.Row():
|
|
|
|
| 27 |
|
| 28 |
def build_project(code):
|
| 29 |
# TODO: as soon as gradio supports states, we should keep the project_id for some time...
|
| 30 |
+
# TODO: In the best case, we start a separate container for each project!
|
| 31 |
yield loading_project_path, "Preparing project...",
|
| 32 |
|
| 33 |
# generate a random uuid for the project
|
|
|
|
| 35 |
|
| 36 |
tmp_dir = os.path.join("/tmp/", project_id)
|
| 37 |
|
| 38 |
+
shutil.copytree(os.environ['MC_PROJECT_DIR'], tmp_dir, dirs_exist_ok=False, symlinks=True)
|
| 39 |
acc_logs = ""
|
| 40 |
|
| 41 |
try:
|
|
|
|
| 46 |
f.write(code)
|
| 47 |
|
| 48 |
process = subprocess.Popen(
|
| 49 |
+
"npm run build",
|
| 50 |
stdout=subprocess.PIPE,
|
| 51 |
stderr=subprocess.PIPE,
|
| 52 |
text=True,
|
|
|
|
| 96 |
continue
|
| 97 |
|
| 98 |
path = last[0]
|
| 99 |
+
assert path, "Failed to build example: " + last[1]
|
| 100 |
return path
|
| 101 |
|
| 102 |
print("Building examples...")
|
|
|
|
| 128 |
def load_example(example):
|
| 129 |
return example['project_path'], example['code'], ""
|
| 130 |
|
|
|
|
| 131 |
with gr.Blocks(theme=gr.themes.Monochrome()) as demo:
|
| 132 |
gr.Markdown("# Motion Canvas MCP Server")
|
| 133 |
with gr.Row():
|