underpost 2.99.8 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/.env.production +1 -0
  2. package/.github/workflows/gitlab.ci.yml +20 -0
  3. package/.github/workflows/publish.ci.yml +18 -38
  4. package/.vscode/extensions.json +8 -50
  5. package/.vscode/settings.json +0 -77
  6. package/CHANGELOG.md +116 -1
  7. package/{cli.md → CLI-HELP.md} +48 -41
  8. package/README.md +3 -3
  9. package/bin/build.js +1 -15
  10. package/bin/deploy.js +4 -133
  11. package/bin/file.js +10 -8
  12. package/bin/zed.js +63 -2
  13. package/jsdoc.json +1 -2
  14. package/manifests/cronjobs/dd-cron/dd-cron-backup.yaml +1 -1
  15. package/manifests/cronjobs/dd-cron/dd-cron-dns.yaml +1 -1
  16. package/manifests/deployment/dd-default-development/deployment.yaml +2 -2
  17. package/manifests/deployment/dd-test-development/deployment.yaml +2 -2
  18. package/manifests/deployment/fastapi/initial_data.sh +4 -52
  19. package/manifests/ipfs/configmap.yaml +57 -0
  20. package/manifests/ipfs/headless-service.yaml +35 -0
  21. package/manifests/ipfs/kustomization.yaml +8 -0
  22. package/manifests/ipfs/statefulset.yaml +149 -0
  23. package/manifests/ipfs/storage-class.yaml +9 -0
  24. package/package.json +9 -5
  25. package/scripts/k3s-node-setup.sh +89 -0
  26. package/scripts/lxd-vm-setup.sh +23 -0
  27. package/scripts/rocky-setup.sh +1 -13
  28. package/src/api/user/user.router.js +0 -47
  29. package/src/cli/baremetal.js +7 -9
  30. package/src/cli/cluster.js +72 -121
  31. package/src/cli/deploy.js +8 -5
  32. package/src/cli/index.js +31 -30
  33. package/src/cli/ipfs.js +184 -0
  34. package/src/cli/lxd.js +192 -237
  35. package/src/cli/repository.js +4 -1
  36. package/src/cli/run.js +3 -2
  37. package/src/client/components/core/Docs.js +92 -6
  38. package/src/client/components/core/VanillaJs.js +36 -25
  39. package/src/client/services/user/user.management.js +0 -5
  40. package/src/client/services/user/user.service.js +1 -1
  41. package/src/index.js +12 -1
  42. package/src/runtime/express/Express.js +3 -2
  43. package/src/server/client-build-docs.js +178 -41
  44. package/src/server/conf.js +1 -1
  45. package/src/server/logger.js +22 -10
  46. package/.vscode/zed.keymap.json +0 -39
  47. package/.vscode/zed.settings.json +0 -20
  48. package/manifests/lxd/underpost-setup.sh +0 -163
package/bin/deploy.js CHANGED
@@ -568,42 +568,6 @@ ${shellExec(`git log | grep Author: | sort -u`, { stdout: true }).split(`\n`).jo
568
568
  break;
569
569
  }
570
570
 
571
- case 'postgresql': {
572
- if (process.argv.includes('install')) {
573
- shellExec(`sudo dnf install -y postgresql-server postgresql`);
574
- shellExec(`sudo postgresql-setup --initdb`);
575
- shellExec(`chown postgres /var/lib/pgsql/data`);
576
- shellExec(`sudo systemctl enable postgresql.service`);
577
- shellExec(`sudo systemctl start postgresql.service`);
578
- } else {
579
- shellExec(`sudo systemctl enable postgresql.service`);
580
- shellExec(`sudo systemctl restart postgresql.service`);
581
- }
582
-
583
- shellExec(`sudo systemctl status postgresql.service`);
584
-
585
- // sudo systemctl stop postgresql
586
- // sudo systemctl disable postgresql
587
-
588
- // psql login
589
- // psql -U <user> -h 127.0.0.1 -W <db-name>
590
-
591
- // gedit /var/lib/pgsql/data/pg_hba.conf
592
- // host <db-name> <db-user> <db-host> md5
593
- // local all postgres trust
594
- // # "local" is for Unix domain socket connections only
595
- // local all all md5
596
- // # IPv4 local connections:
597
- // host all all 127.0.0.1/32 md5
598
- // # IPv6 local connections:
599
- // host all all ::1/128 md5
600
-
601
- // gedit /var/lib/pgsql/data/postgresql.conf
602
- // listen_addresses = '*'
603
-
604
- break;
605
- }
606
-
607
571
  case 'postgresql-17': {
608
572
  if (process.argv.includes('install')) {
609
573
  shellExec(`sudo dnf module reset postgresql -y`);
@@ -635,46 +599,6 @@ ${shellExec(`git log | grep Author: | sort -u`, { stdout: true }).split(`\n`).jo
635
599
  break;
636
600
  }
637
601
 
638
- case 'postgresql-14': {
639
- if (process.argv.includes('install')) {
640
- shellExec(`sudo dnf module reset postgresql -y`);
641
- shellExec(`sudo dnf -qy module disable postgresql`);
642
-
643
- shellExec(`sudo systemctl stop postgresql-14`);
644
- shellExec(`sudo systemctl disable postgresql-14`);
645
-
646
- shellExec(`sudo dnf remove -y postgresql14 postgresql14-server postgresql14-contrib`);
647
- shellExec(`sudo rm -rf /var/lib/pgsql`);
648
-
649
- shellExec(`sudo dnf install postgresql14 postgresql14-server postgresql14-contrib -y`);
650
- }
651
- if (process.argv.includes('uninstall')) {
652
- shellExec(`sudo systemctl stop postgresql-14`);
653
- shellExec(`sudo systemctl disable postgresql-14`);
654
- shellExec(`sudo dnf remove -y postgresql14 postgresql14-server postgresql14-contrib`);
655
- shellExec(`sudo rm -rf /var/lib/pgsql /var/log/pgsql /etc/postgresql`);
656
- } else {
657
- shellExec(`sudo /usr/pgsql-14/bin/postgresql-14-setup initdb`);
658
- shellExec(`sudo systemctl start postgresql-14`);
659
- shellExec(`sudo systemctl enable postgresql-14`);
660
- shellExec(`sudo systemctl status postgresql-14`);
661
- // sudo dnf install postgresql14-contrib
662
- }
663
-
664
- break;
665
- }
666
-
667
- case 'pg-stop': {
668
- shellExec(`sudo systemctl stop postgresql-14`);
669
- shellExec(`sudo systemctl disable postgresql-14`);
670
- break;
671
- }
672
- case 'pg-start': {
673
- shellExec(`sudo systemctl enable postgresql-14`);
674
- shellExec(`sudo systemctl restart postgresql-14`);
675
- break;
676
- }
677
-
678
602
  case 'pg-list-db': {
679
603
  shellExec(`sudo -i -u postgres psql -c "\\l"`);
680
604
  break;
@@ -696,36 +620,6 @@ ${shellExec(`git log | grep Author: | sort -u`, { stdout: true }).split(`\n`).jo
696
620
  break;
697
621
  }
698
622
 
699
- case 'mount': {
700
- const mounts = shellExec(`mount`).split(`\n`);
701
- console.table(
702
- mounts
703
- .filter((l) => l.trim())
704
- .map(
705
- (o) => (
706
- (o = o.split(' ')),
707
- {
708
- path: o[2],
709
- type: o[4],
710
- permissions: o[5],
711
- }
712
- ),
713
- ),
714
- );
715
- break;
716
- }
717
-
718
- case 'create-ports': {
719
- const cmd = [];
720
- const commissioningDeviceIp = Underpost.dns.getLocalIPv4Address();
721
- for (const port of ['5240']) {
722
- const name = 'maas';
723
- cmd.push(`${name}:${port}-${port}:${commissioningDeviceIp}`);
724
- }
725
- pbcopy(`node engine-private/r create-port ${cmd}`);
726
- break;
727
- }
728
-
729
623
  case 'fastapi-models': {
730
624
  shellExec(`chmod +x ../full-stack-fastapi-template/backend/initial_data.sh`);
731
625
  shellExec(`../full-stack-fastapi-template/backend/initial_data.sh`);
@@ -987,22 +881,6 @@ nvidia/gpu-operator \
987
881
  break;
988
882
  }
989
883
 
990
- case 'update-static-guide': {
991
- fs.writeFileSync(
992
- `src/client/public/nexodev/docs/references/Static Site Generator Quick Reference.md`,
993
- fs.readFileSync(`examples/static-page/QUICK-REFERENCE.md`, 'utf8'),
994
- );
995
- fs.writeFileSync(
996
- `src/client/public/nexodev/docs/references/Static Site Generator Examples.md`,
997
- fs.readFileSync(`examples/static-page/README.md`, 'utf8'),
998
- );
999
- fs.writeFileSync(
1000
- `src/client/public/nexodev/docs/references/Static Generator Guide.md`,
1001
- fs.readFileSync(`examples/static-page/STATIC-GENERATOR-GUIDE.md`, 'utf8'),
1002
- );
1003
- break;
1004
- }
1005
-
1006
884
  case 'udpate-version-files': {
1007
885
  const oldNpmVersion = process.argv[3];
1008
886
  const oldNodeVersion = process.argv[4];
@@ -1018,13 +896,6 @@ nvidia/gpu-operator \
1018
896
  .replaceAll(oldNodeVersion, nodeVersion)
1019
897
  .replaceAll(oldNpmVersion, npmVersion),
1020
898
  );
1021
- fs.writeFileSync(
1022
- `manifests/lxd/underpost-setup.sh`,
1023
- fs
1024
- .readFileSync(`manifests/lxd/underpost-setup.sh`, 'utf8')
1025
- .replaceAll(oldNodeVersion, nodeVersion)
1026
- .replaceAll(oldNpmVersion, npmVersion),
1027
- );
1028
899
  fs.writeFileSync(
1029
900
  `src/client/public/nexodev/docs/references/Getting started.md`,
1030
901
  fs
@@ -1106,10 +977,10 @@ nvidia/gpu-operator \
1106
977
  `${key}`.toUpperCase().match('MAC')
1107
978
  ? 'changethis'
1108
979
  : isNaN(parseFloat(privateEnv[key]))
1109
- ? `${privateEnv[key]}`.match(`@`)
1110
- ? 'admin@default.net'
1111
- : 'changethis'
1112
- : privateEnv[key];
980
+ ? `${privateEnv[key]}`.match(`@`)
981
+ ? 'admin@default.net'
982
+ : 'changethis'
983
+ : privateEnv[key];
1113
984
  }
1114
985
  return env;
1115
986
  };
package/bin/file.js CHANGED
@@ -22,26 +22,22 @@ logger.info('argv', process.argv);
22
22
  let [exe, dir, type] = process.argv;
23
23
  let rawPath = process.argv[3].replaceAll(`'`, '');
24
24
  let toPath = process.argv[4].replaceAll(`'`, '');
25
-
26
25
  let path = `${rawPath}`.split('/');
27
26
  path.pop();
28
27
  path = path.join('/');
29
-
30
28
  const file = `${rawPath}`.split('/').pop();
31
29
  const ext = file.split('.')[1];
32
30
  let name = getCapVariableName(file.split('.')[0]);
31
+ let content = '';
33
32
 
34
33
  logger.info('File metadata', { path, file, ext, name });
35
34
 
36
35
  try {
37
- let content = '';
38
36
  switch (type) {
39
37
  case 'update-template':
40
38
  case 'copy-src':
41
39
  console.log({ rawPath, toPath });
42
40
 
43
- // this function returns a promise, but you can also pass a cb
44
- // if you like that approach better.
45
41
  let result = await new Promise((resolve) =>
46
42
  walk(
47
43
  {
@@ -90,7 +86,7 @@ try {
90
86
  // fs.copySync(`./.github`, `../pwa-microservices-template/.github`);
91
87
  fs.copySync(`./src/client/public/default`, `../pwa-microservices-template/src/client/public/default`);
92
88
 
93
- for (const checkoutPath of ['README.md', 'package-lock.json', 'package.json'])
89
+ for (const checkoutPath of ['README.md', 'package.json'])
94
90
  shellExec(`cd ../pwa-microservices-template && git checkout ${checkoutPath}`);
95
91
 
96
92
  for (const deletePath of [
@@ -114,6 +110,7 @@ try {
114
110
  `./.github/workflows/pwa-microservices-template-test.ci.yml`,
115
111
  `./.github/workflows/npmpkg.ci.yml`,
116
112
  `./.github/workflows/ghpkg.ci.yml`,
113
+ `./.github/workflows/gitlab.ci.yml`,
117
114
  `./.github/workflows/publish.ci.yml`,
118
115
  `./.github/workflows/release.cd.yml`,
119
116
  './src/ws/IoInterface.js',
@@ -133,6 +130,7 @@ try {
133
130
  templatePackageJson.devDependencies = originPackageJson.devDependencies;
134
131
  templatePackageJson.version = originPackageJson.version;
135
132
  templatePackageJson.scripts = originPackageJson.scripts;
133
+ templatePackageJson.overrides = originPackageJson.overrides;
136
134
  templatePackageJson.name = name;
137
135
  templatePackageJson.description = description;
138
136
  // templatePackageJson.scripts.dev = dev;
@@ -146,15 +144,17 @@ try {
146
144
  JSON.stringify(templatePackageJson, null, 4),
147
145
  'utf8',
148
146
  );
149
-
150
147
  const originPackageLockJson = JSON.parse(fs.readFileSync('./package-lock.json', 'utf8'));
148
+
151
149
  const templatePackageLockJson = JSON.parse(
152
150
  fs.readFileSync('../pwa-microservices-template/package-lock.json', 'utf8'),
153
151
  );
152
+
154
153
  const originBasePackageLock = newInstance(templatePackageLockJson.packages['']);
154
+ templatePackageLockJson.name = name;
155
155
  templatePackageLockJson.version = originPackageLockJson.version;
156
156
  templatePackageLockJson.packages = originPackageLockJson.packages;
157
- templatePackageLockJson.packages[''].name = originBasePackageLock.name;
157
+ templatePackageLockJson.packages[''].name = name;
158
158
  templatePackageLockJson.packages[''].version = originPackageLockJson.version;
159
159
  templatePackageLockJson.packages[''].hasInstallScript = originBasePackageLock.hasInstallScript;
160
160
  templatePackageLockJson.packages[''].license = originBasePackageLock.license;
@@ -163,6 +163,8 @@ try {
163
163
  JSON.stringify(templatePackageLockJson, null, 4),
164
164
  'utf8',
165
165
  );
166
+ // Regenerate package-lock.json to match the modified package.json
167
+ // shellExec(`cd ../pwa-microservices-template && npm install --package-lock-only --ignore-scripts`);
166
168
  fs.writeFileSync(
167
169
  '../pwa-microservices-template/README.md',
168
170
  fs
package/bin/zed.js CHANGED
@@ -6,9 +6,70 @@ import { getUnderpostRootPath } from '../src/server/conf.js';
6
6
  const logger = loggerFactory(import.meta);
7
7
  const underpostRoot = getUnderpostRootPath();
8
8
 
9
+ const settings = {
10
+ ui_font_size: 16,
11
+ buffer_font_size: 15,
12
+ theme: {
13
+ mode: 'system',
14
+ light: 'One Dark',
15
+ dark: 'One Dark',
16
+ },
17
+
18
+ features: {
19
+ edit_prediction_provider: 'copilot',
20
+ copilot: true,
21
+ },
22
+
23
+ show_edit_predictions: true,
24
+
25
+ edit_predictions: {
26
+ mode: 'eager',
27
+ },
28
+ };
29
+
30
+ const keyMap = [
31
+ {
32
+ context: 'Editor',
33
+ bindings: {
34
+ 'ctrl-c': 'editor::Copy',
35
+ 'ctrl-x': 'editor::Cut',
36
+ 'ctrl-v': 'editor::Paste',
37
+ 'ctrl-shift-c': 'editor::CopyAndTrim',
38
+ 'ctrl-shift-v': 'editor::Paste',
39
+ 'cmd-c': 'editor::Copy',
40
+ 'cmd-x': 'editor::Cut',
41
+ 'cmd-v': 'editor::Paste',
42
+ },
43
+ },
44
+ {
45
+ context: 'Terminal',
46
+ bindings: {
47
+ 'ctrl-shift-c': 'terminal::Copy',
48
+ 'ctrl-shift-v': 'terminal::Paste',
49
+ 'cmd-shift-c': 'terminal::Copy',
50
+ 'cmd-shift-v': 'terminal::Paste',
51
+ },
52
+ },
53
+ {
54
+ context: 'Editor && edit_prediction',
55
+ bindings: {
56
+ tab: 'editor::AcceptEditPrediction',
57
+ 'alt-tab': 'editor::AcceptEditPrediction',
58
+ 'alt-l': null,
59
+ },
60
+ },
61
+ {
62
+ context: 'Editor && edit_prediction_conflict',
63
+ bindings: {
64
+ 'alt-l': 'editor::AcceptEditPrediction',
65
+ tab: 'editor::ComposeCompletion',
66
+ },
67
+ },
68
+ ];
69
+
9
70
  if (!fs.existsSync('/root/.config/zed')) fs.mkdirSync('/root/.config/zed', { recursive: true });
10
- fs.copyFileSync(`${underpostRoot}/.vscode/zed.settings.json`, `/root/.config/zed/settings.json`);
11
- fs.copyFileSync(`${underpostRoot}/.vscode/zed.keymap.json`, `/root/.config/zed/keymap.json`);
71
+ fs.writeFileSync(`/root/.config/zed/settings.json`, JSON.stringify(settings, null, 4), 'utf8');
72
+ fs.writeFileSync(`/root/.config/zed/keymap.json`, JSON.stringify(keyMap, null, 4), 'utf8');
12
73
 
13
74
  shellExec(`ZED_ALLOW_ROOT=true zed ${process.argv[2] ? process.argv[2] : '.'}`);
14
75
 
package/jsdoc.json CHANGED
@@ -3,7 +3,6 @@
3
3
  "allowUnknownTags": true,
4
4
  "dictionaries": ["jsdoc"]
5
5
  },
6
- "categoryfile": "./jsdoc-categories.json",
7
6
  "source": {
8
7
  "include": ["./src", "./package.json", "./README.md", "./CHANGELOG.md"],
9
8
  "includePattern": ".js$",
@@ -26,7 +25,7 @@
26
25
  "favicon": "./public/www.nexodev.org/",
27
26
  "displayModuleHeader": true,
28
27
  "includeFilesListInHomepage": true,
29
- "sections": ["Modules", "Classes", "Namespaces", "Tutorials", "Events", "Interfaces", "Global"],
28
+ "sections": ["Namespaces", "Tutorials"],
30
29
  "meta": [
31
30
  {
32
31
  "name": "author",
@@ -23,7 +23,7 @@ spec:
23
23
  spec:
24
24
  containers:
25
25
  - name: dd-cron-backup
26
- image: underpost/underpost-engine:v2.99.8
26
+ image: underpost/underpost-engine:v3.0.1
27
27
  command:
28
28
  - /bin/sh
29
29
  - -c
@@ -23,7 +23,7 @@ spec:
23
23
  spec:
24
24
  containers:
25
25
  - name: dd-cron-dns
26
- image: underpost/underpost-engine:v2.99.8
26
+ image: underpost/underpost-engine:v3.0.1
27
27
  command:
28
28
  - /bin/sh
29
29
  - -c
@@ -17,7 +17,7 @@ spec:
17
17
  spec:
18
18
  containers:
19
19
  - name: dd-default-development-blue
20
- image: localhost/rockylinux9-underpost:v2.99.8
20
+ image: localhost/rockylinux9-underpost:v3.0.1
21
21
  # resources:
22
22
  # requests:
23
23
  # memory: "124Ki"
@@ -100,7 +100,7 @@ spec:
100
100
  spec:
101
101
  containers:
102
102
  - name: dd-default-development-green
103
- image: localhost/rockylinux9-underpost:v2.99.8
103
+ image: localhost/rockylinux9-underpost:v3.0.1
104
104
  # resources:
105
105
  # requests:
106
106
  # memory: "124Ki"
@@ -18,7 +18,7 @@ spec:
18
18
  spec:
19
19
  containers:
20
20
  - name: dd-test-development-blue
21
- image: localhost/rockylinux9-underpost:v2.99.8
21
+ image: localhost/rockylinux9-underpost:v3.0.1
22
22
 
23
23
  command:
24
24
  - /bin/sh
@@ -103,7 +103,7 @@ spec:
103
103
  spec:
104
104
  containers:
105
105
  - name: dd-test-development-green
106
- image: localhost/rockylinux9-underpost:v2.99.8
106
+ image: localhost/rockylinux9-underpost:v3.0.1
107
107
 
108
108
  command:
109
109
  - /bin/sh
@@ -1,56 +1,8 @@
1
1
  #!/bin/bash
2
+ # FastAPI initial data script
2
3
 
3
- # IMPORTANT: For non-interactive scripts, 'conda activate' can be problematic
4
- # because it relies on the shell's initialization.
5
- # A more robust and recommended way to run commands within a Conda environment
6
- # from a script is to use 'conda run'. This command directly executes a process
7
- # in the specified environment without needing to manually source 'conda.sh'.
4
+ # Dynamically determine the directory of the script and change to that directory
5
+ cd "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
8
6
 
9
- # Navigate to the application's root directory for module discovery.
10
- # This is crucial for Python to correctly find your 'app' module using 'python -m'.
11
- #
12
- # Let's assume a common project structure:
13
- # full-stack-fastapi-template/
14
- # ├── backend/
15
- # │ ├── app/
16
- # │ │ └── initial_data.py (the Python script you want to run)
17
- # │ └── initial_data.sh (this shell script)
18
- # └── ...
19
- #
20
- # If `initial_data.sh` is located in `full-stack-fastapi-template/backend/`,
21
- # and `app` is a subdirectory of `backend/`, then the Python command
22
- # `python -m app.initial_data` needs to be executed from the `backend/` directory.
23
- #
24
- # If you are running this shell script from a different directory (e.g., `engine/`),
25
- # Python's module import system won't automatically find 'app' unless the parent
26
- # directory of 'app' is in the `PYTHONPATH` or you change the current working directory.
27
- #
28
- # The safest way is to change the current working directory to the script's location.
29
-
30
- # Store the current directory to return to it later if needed (good practice for multi-step scripts).
31
- CURRENT_DIR=$(pwd)
32
-
33
- # Get the absolute path of the directory where this script is located.
34
- # This is a robust way to ensure we always navigate to the correct 'backend' directory.
35
- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
36
- cd "$SCRIPT_DIR"
37
-
38
- # Execute your Python script within the specified Conda environment using 'conda run'.
39
- # -n fastapi_env specifies the Conda environment to use.
40
- # This completely avoids the 'source conda.sh' issue and is generally more reliable.
7
+ # Run the initial data script using the conda environment
41
8
  conda run -n fastapi_env python -m app.initial_data
42
-
43
- # Important Note: The 'ModuleNotFoundError: No module named 'sqlmodel'' indicates that
44
- # the 'sqlmodel' package is not installed in your 'fastapi_env' Conda environment.
45
- # After running this script, if you still get the 'sqlmodel' error,
46
- # you will need to activate your environment manually and install it:
47
- #
48
- # conda activate fastapi_env
49
- # pip install sqlmodel
50
- # # or if it's a conda package:
51
- # # conda install sqlmodel
52
- #
53
- # Then try running this script again.
54
-
55
- # Optional Good Practice: Return to the original directory if the script is part of a larger workflow.
56
- cd "$CURRENT_DIR"
@@ -0,0 +1,57 @@
1
+ apiVersion: v1
2
+ kind: ConfigMap
3
+ metadata:
4
+ name: ipfs-cluster-set-bootstrap-conf
5
+ data:
6
+ entrypoint.sh: |
7
+ #!/bin/sh
8
+ set -e
9
+
10
+ user=ipfs
11
+
12
+ # Custom entrypoint for k8s: connects non-bootstrap pods to the bootstrap peer
13
+ # ipfs-cluster-0 acts as the bootstrap node using the pre-generated identity.
14
+
15
+ if [ ! -f /data/ipfs-cluster/service.json ]; then
16
+ ipfs-cluster-service init
17
+ fi
18
+
19
+ PEER_HOSTNAME=$(cat /proc/sys/kernel/hostname)
20
+
21
+ if echo "${PEER_HOSTNAME}" | grep -q "^ipfs-cluster-0"; then
22
+ # Bootstrap node: use the pre-seeded identity and secret
23
+ exec ipfs-cluster-service daemon --upgrade
24
+ else
25
+ BOOTSTRAP_ADDR="/dns4/${SVC_NAME}-0/tcp/9096/ipfs/${BOOTSTRAP_PEER_ID}"
26
+
27
+ if [ -z "${BOOTSTRAP_ADDR}" ]; then
28
+ echo "ERROR: BOOTSTRAP_ADDR could not be constructed." >&2
29
+ exit 1
30
+ fi
31
+
32
+ exec ipfs-cluster-service daemon --upgrade --bootstrap "${BOOTSTRAP_ADDR}" --leave
33
+ fi
34
+
35
+ configure-ipfs.sh: |
36
+ #!/bin/sh
37
+ set -e
38
+ set -x
39
+
40
+ # Custom init script: prepares the IPFS data directory and sets production config.
41
+
42
+ mkdir -p /data/ipfs
43
+ chown -R 1000:100 /data/ipfs
44
+
45
+ if [ -f /data/ipfs/config ]; then
46
+ # Remove stale repo lock if present
47
+ rm -f /data/ipfs/repo.lock
48
+ exit 0
49
+ fi
50
+
51
+ ipfs init --profile=pebbleds,server
52
+ ipfs config Addresses.API /ip4/0.0.0.0/tcp/5001
53
+ ipfs config Addresses.Gateway /ip4/0.0.0.0/tcp/8080
54
+ ipfs config --json Swarm.ConnMgr.HighWater 2000
55
+ ipfs config --json Datastore.BloomFilterSize 1048576
56
+ ipfs config Datastore.StorageMax 100GB
57
+ chown -R 1000:100 /data/ipfs
@@ -0,0 +1,35 @@
1
+ apiVersion: v1
2
+ kind: Service
3
+ metadata:
4
+ name: ipfs-cluster
5
+ labels:
6
+ app: ipfs-cluster
7
+ spec:
8
+ clusterIP: None
9
+ selector:
10
+ app: ipfs-cluster
11
+ ports:
12
+ - name: swarm
13
+ port: 4001
14
+ protocol: TCP
15
+ - name: swarm-udp
16
+ port: 4001
17
+ protocol: UDP
18
+ - name: api
19
+ port: 5001
20
+ protocol: TCP
21
+ - name: ws
22
+ port: 8081
23
+ protocol: TCP
24
+ - name: http
25
+ port: 8080
26
+ protocol: TCP
27
+ - name: api-http
28
+ port: 9094
29
+ protocol: TCP
30
+ - name: proxy-http
31
+ port: 9095
32
+ protocol: TCP
33
+ - name: cluster-swarm
34
+ port: 9096
35
+ protocol: TCP
@@ -0,0 +1,8 @@
1
+ ---
2
+ # kubectl apply -k ipfs/.
3
+ apiVersion: kustomize.config.k8s.io/v1beta1
4
+ kind: Kustomization
5
+ resources:
6
+ - headless-service.yaml
7
+ - configmap.yaml
8
+ - statefulset.yaml