manu-sapiens commited on
Commit
a044b62
·
1 Parent(s): 64a6a39

simplifying Dockerfile. Updated constant for omnitool space owner

Browse files
Files changed (3) hide show
  1. Dockerfile +7 -21
  2. hf_server.js +11 -16
  3. omnitool_init.sh +30 -53
Dockerfile CHANGED
@@ -3,31 +3,17 @@ FROM node:20.6.1
3
  USER node
4
  WORKDIR /app
5
 
6
- RUN chmod 0777 /app
7
- RUN cd /app
8
  RUN git clone https://github.com/omnitool-ai/omnitool.git
9
- RUN cd omnitool
10
- RUN yarn install
11
- #RUN mkdir -p /app/omnitool/node_modules
12
- RUN cd ..
13
- RUN yarn install
14
- RUN chmod 0777 /app
15
-
16
- #RUN mkdir -p /app/omnitool
17
- #RUN chmod 777 /app/omnitool
18
  RUN mkdir -p /app/omnitool/node_modules
19
- #RUN chmod 777 /app/omnitool/node_modules
20
- #RUN mkdir -p /app/omnitool/packages/omni-server/config.default/models/nsfwjs/mobilenet-v2-quant/
21
- #RUN chmod 777 /app/omnitool/packages/omni-server/config.default/models/nsfwjs/mobilenet-v2-quant/
22
- #RUN curl -L https://github.com/omnitool-ai/omnitool/raw/main/packages/omni-server/config.default/models/nsfwjs/mobilenet-v2-quant/group1-shard1of1 -o /app/omnitool/packages/omni-server/config.default/models/nsfwjs/mobilenet-v2-quant/group1-shard1of1
23
- #RUN chmod 777 /app/omnitool/packages/omni-server/config.default/models/nsfwjs/mobilenet-v2-quant/group1-shard1of1
24
-
25
  RUN chown -Rh $user:$user /app
26
- #RUN chown -Rh $user:$user /app/omnitool
27
-
28
  COPY --chown=node . /app
29
-
30
- #RUN yarn install
31
  EXPOSE 4444
32
 
33
  CMD ["node", "hf_server.js"]
 
3
  USER node
4
  WORKDIR /app
5
 
6
+ #RUN chmod 0777 /app
7
+ #RUN cd /app
8
  RUN git clone https://github.com/omnitool-ai/omnitool.git
9
+ RUN cd omnitool && yarn install
10
+ #RUN yarn install
11
+ #RUN cd ..
12
+ #RUN yarn install
 
 
 
 
 
13
  RUN mkdir -p /app/omnitool/node_modules
14
+ RUN chmod 0777 /app
 
 
 
 
 
15
  RUN chown -Rh $user:$user /app
 
 
16
  COPY --chown=node . /app
 
 
17
  EXPOSE 4444
18
 
19
  CMD ["node", "hf_server.js"]
hf_server.js CHANGED
@@ -3,7 +3,7 @@
3
  * All rights reserved.
4
  */
5
  //@ts-check
6
- const VERSION = '0.6.0.hf.011a';
7
 
8
  const express = require('express');
9
  const http = require('http');
@@ -22,10 +22,11 @@ const CONTAINER_PORT_OMNITOOL = 1688;
22
  const OMNITOOL_HEALTH_PING = '/api/v1/mercenaries/ping';
23
  const FAVICON = 'https://github.com/omnitool-ai/omnitool/raw/main/packages/omni-ui/omni-web/public/favicon.jpg'
24
 
25
- const OMNITOOL_SPACE_NAME = 'omnitool-test-3';
26
- const OMNITOOL_SPACE_OWNER = 'manu-sapiens';
27
- const HF_SPACE_URL = `https://huggingface.co/spaces/${OMNITOOL_SPACE_OWNER}/${OMNITOOL_SPACE_NAME}`;
28
- const HF_SPACE_DUPLICATE_URL = `https://huggingface.co/spaces/manu-sapiens/omnitool_test_3?duplicate=true`;
 
29
 
30
  const DELAY_OMNITOOL_SET_TO_RUNNING = 2000; // 2 seconds
31
  const CHECK_OMNI_INTERVAL = 60000; // 1 minute
@@ -41,7 +42,7 @@ global.PROXY_STARTED = false;
41
  global.logs = [];
42
  global.OMNITOOL_PROXY = null;
43
  global.CONNECTED_TO_MASTER = false;
44
- global.SPACE_OWNER = "";
45
 
46
 
47
  console.log(`************ Omnitool Proxy Server v${VERSION} ************`);
@@ -257,7 +258,7 @@ function getButtonsString(buttonsHTML)
257
  connectionStatusMessage = '<div>You are now connected DIRECTLY to the REFERENCE Omnitool Space on Huggingface.</div><div style="color: red;">It is HIGHLY recommended that you duplicate this space and make it private to secure your keys, recipes and outputs.</div>';
258
  } else
259
  {
260
- connectionStatusMessage = `<div style="color: green;">You are now connected to the space of ${global.SPACE_OWNER}.</div><div>If this is NOT you, it is HIGHLY recommended that you duplicate this space and make it private to secure your keys, recipes and outputs.</div><div>In addition, consider subscribing to the 20GB local storage option from Huggingface to preserve your keys and work between reboot of this server.</div>`;
261
  }
262
 
263
  return `
@@ -270,11 +271,10 @@ function getButtonsString(buttonsHTML)
270
  <h1>Omnitool.ai on Hugging Face</h1>
271
  <p>Version: ${VERSION}</p>
272
  <div>Welcome to Omnitool.ai running on Hugging Face!</div>
273
- <div>This is a fully functional version.</div>
274
- <div>For more details visit us at <a href="https://omnitool.ai" target="_blank" class="button-like-link" id="duplicateRepoButton">omnitool.ai</a></div>
275
  <p>-----------------------------------</p>
276
  <p>This Space URL: ${global.LOCAL_URL}</p>
277
- <p>This Space Owner: ${global.SPACE_OWNER}</p>
278
  <p>Using REFERENCE Space: ${global.CONNECTED_TO_MASTER}</p>
279
  <p>Omnitool SERVER Launched: ${global.ALREADY_STARTING}</p>
280
  <p>Omnitool SERVER Ready: ${global.OMNITOOL_READY}</p>
@@ -412,12 +412,7 @@ function setGlobals(req)
412
 
413
  // New logic to set CONNECTED_TO_MASTER
414
  global.CONNECTED_TO_MASTER = false;
415
- const recreated_string = `-${OMNITOOL_SPACE_NAME}.hf.space`;
416
- // remove the protocol, a possible trailing / and the recreated string from the url
417
- global.SPACE_OWNER = global.LOCAL_URL.replace(/\/$/, '').replace(recreated_string, '');
418
- console.log(`global.SPACE_OWNER = ${global.SPACE_OWNER}`);
419
-
420
- if (global.SPACE_OWNER === OMNITOOL_SPACE_OWNER) { global.CONNECTED_TO_MASTER = true; }
421
  console.log(`global.CONNECTED_TO_MASTER = ${global.CONNECTED_TO_MASTER}`);
422
 
423
  }
 
3
  * All rights reserved.
4
  */
5
  //@ts-check
6
+ const VERSION = '0.6.0.hf.012.a';
7
 
8
  const express = require('express');
9
  const http = require('http');
 
22
  const OMNITOOL_HEALTH_PING = '/api/v1/mercenaries/ping';
23
  const FAVICON = 'https://github.com/omnitool-ai/omnitool/raw/main/packages/omni-ui/omni-web/public/favicon.jpg'
24
 
25
+ //const OMNITOOL_SPACE_NAME = 'omnitool-test-3';
26
+ //const OMNITOOL_SPACE_OWNER = 'manu-sapiens';
27
+ const OMNITOOL_SPACE_URL = "https://omnitool-ai-omnitool-on-hf.hf.space/";
28
+ const HF_SPACE_URL = "https://huggingface.co/spaces/omnitool-ai/omnitool_on_hf";
29
+ const HF_SPACE_DUPLICATE_URL = "https://huggingface.co/spaces/omnitool-ai/omnitool_on_hf?duplicate=true";
30
 
31
  const DELAY_OMNITOOL_SET_TO_RUNNING = 2000; // 2 seconds
32
  const CHECK_OMNI_INTERVAL = 60000; // 1 minute
 
42
  global.logs = [];
43
  global.OMNITOOL_PROXY = null;
44
  global.CONNECTED_TO_MASTER = false;
45
+
46
 
47
 
48
  console.log(`************ Omnitool Proxy Server v${VERSION} ************`);
 
258
  connectionStatusMessage = '<div>You are now connected DIRECTLY to the REFERENCE Omnitool Space on Huggingface.</div><div style="color: red;">It is HIGHLY recommended that you duplicate this space and make it private to secure your keys, recipes and outputs.</div>';
259
  } else
260
  {
261
+ connectionStatusMessage = `<div style="color: green;">You are now connected to the space ${global.LOCAL_URL}.</div><div style="color: red;">If this is NOT yours, it is HIGHLY recommended that you duplicate this space and make it private to secure your keys, recipes and outputs.</div>`;
262
  }
263
 
264
  return `
 
271
  <h1>Omnitool.ai on Hugging Face</h1>
272
  <p>Version: ${VERSION}</p>
273
  <div>Welcome to Omnitool.ai running on Hugging Face!</div>
274
+ <div>This is a fully functional version, but all recipes and outputs are lost when the server is restarted!</div>
275
+ <div>For more details, including how to install omnitool on your own computer, visit us at <a href="https://omnitool.ai" target="_blank" class="button-like-link" id="duplicateRepoButton">omnitool.ai</a></div>
276
  <p>-----------------------------------</p>
277
  <p>This Space URL: ${global.LOCAL_URL}</p>
 
278
  <p>Using REFERENCE Space: ${global.CONNECTED_TO_MASTER}</p>
279
  <p>Omnitool SERVER Launched: ${global.ALREADY_STARTING}</p>
280
  <p>Omnitool SERVER Ready: ${global.OMNITOOL_READY}</p>
 
412
 
413
  // New logic to set CONNECTED_TO_MASTER
414
  global.CONNECTED_TO_MASTER = false;
415
+ if (global.LOCAL_URL === OMNITOOL_SPACE_URL) global.CONNECTED_TO_MASTER = true;
 
 
 
 
 
416
  console.log(`global.CONNECTED_TO_MASTER = ${global.CONNECTED_TO_MASTER}`);
417
 
418
  }
omnitool_init.sh CHANGED
@@ -6,62 +6,39 @@ cd ./omnitool
6
  git pull
7
  cd ..
8
 
9
- # if [ -d "./omnitool" ]; then
10
- # echo "[v] OMNITOOL already present "
11
- # cd ./omnitool
12
- # git pull
13
- # cd ..
14
- # chmod 0777 ./omnitool
15
- # chown -R node:node ./omnitool
16
- # else
17
- # echo "[ERROR] OMNITOOL IS MISSING"
18
- # git clone https://github.com/omnitool-ai/omnitool.git
19
- # chmod 0777 ./omnitool
20
- # chown -R node:node ./omnitool
21
- # fi
22
-
23
- # if [ -d "./omnitool/node_modules" ]; then
24
- # echo "[v] OMNITOOL NODE_MODULES already present "
25
- # else
26
- # mkdir -p ./omnitool/node_modules
27
- # chmod 0777 ./omnitool/node_modules
28
- # chown node ./omnitool/node_modules
29
- # echo "[+] Adding OMNITOOL NODE_MODULES"
30
- # fi
31
-
32
- echo "[->] CHECKING EXISTING /DATA "
33
- if [ -d "/data" ]; then
34
- echo "$(ls -l /data/files)"
35
-
36
- if [ -L "./omnitool/packages/omni-server/data.local" ]; then
37
- echo "[v] DATA.LOCAL symlink already present "
38
- else
39
- if [ -d "./omnitool/packages/omni-server/data.local" ]; then
40
- echo "[v] DATA.LOCAL already present "
41
- # hopefully it got copied over through the symlink in the previous run
42
- rm -rf ./omnitool/packages/omni-server/data.local
43
 
44
- mkdir ./omnitool/packages/omni-server/data.local
45
- chmod 0777 ./omnitool/packages/omni-server/data.local
46
- chown node ./omnitool/packages/omni-server/data.local
47
- else
48
- echo "[v] Creating DATA.LOCAL "
49
- mkdir ./omnitool/packages/omni-server/data.local
50
- chmod 0777 ./omnitool/packages/omni-server/data.local
51
- chown node ./omnitool/packages/omni-server/data.local
52
- fi
53
-
54
- echo "[v] Creating the symlink "
55
- ln -s /data ./omnitool/packages/omni-server/data.local
56
- chown node ./omnitool/packages/omni-server/data.local
57
- fi
58
 
59
- else
60
- echo "[v] NO persistent /DATA DETECTED. You can add 20Gig of persistent storage as a paid option to Hugging Face"
61
- fi
62
 
 
63
  cd omnitool
64
- echo "[x] CD OMNITOOL "
65
 
66
  echo "[->] YARN INSTALL"
67
  yarn
@@ -70,5 +47,5 @@ echo "[->] Updating permissions"
70
  chmod -R 0777 .
71
  chown -Rh node:node .
72
 
73
- echo "[v] YARN START "
74
  yarn start -u -rb -R blocks
 
6
  git pull
7
  cd ..
8
 
9
+ # echo "[->] CHECKING EXISTING /DATA "
10
+ # if [ -d "/data" ]; then
11
+ # echo "$(ls -l /data)"
12
+
13
+ # if [ -L "./omnitool/packages/omni-server/data.local" ]; then
14
+ # echo "[v] DATA.LOCAL symlink already present "
15
+ # else
16
+ # if [ -d "./omnitool/packages/omni-server/data.local" ]; then
17
+ # echo "[v] DATA.LOCAL already present "
18
+ # # hopefully it got copied over through the symlink in the previous run
19
+ # rm -rf ./omnitool/packages/omni-server/data.local
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
+ # mkdir ./omnitool/packages/omni-server/data.local
22
+ # chmod 0777 ./omnitool/packages/omni-server/data.local
23
+ # chown node ./omnitool/packages/omni-server/data.local
24
+ # else
25
+ # echo "[v] Creating DATA.LOCAL "
26
+ # mkdir ./omnitool/packages/omni-server/data.local
27
+ # chmod 0777 ./omnitool/packages/omni-server/data.local
28
+ # chown node ./omnitool/packages/omni-server/data.local
29
+ # fi
30
+
31
+ # echo "[v] Creating the symlink "
32
+ # ln -s /data ./omnitool/packages/omni-server/data.local
33
+ # chown node ./omnitool/packages/omni-server/data.local
34
+ # fi
35
 
36
+ # else
37
+ # echo "[v] NO persistent /DATA DETECTED. You can add 20Gig of persistent storage as a paid option to Hugging Face"
38
+ # fi
39
 
40
+ echo "[->] CD OMNITOOL "
41
  cd omnitool
 
42
 
43
  echo "[->] YARN INSTALL"
44
  yarn
 
47
  chmod -R 0777 .
48
  chown -Rh node:node .
49
 
50
+ echo "[->] YARN START "
51
  yarn start -u -rb -R blocks