@wocker/ws 1.0.20 → 1.0.22

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 (100) hide show
  1. package/README.md +8 -0
  2. package/lib/AppModule.js +17 -39
  3. package/lib/controllers/DebugController.d.ts +2 -1
  4. package/lib/controllers/DebugController.js +13 -5
  5. package/lib/controllers/KeystoreController.d.ts +11 -0
  6. package/lib/controllers/KeystoreController.js +106 -0
  7. package/lib/controllers/PluginController.d.ts +3 -5
  8. package/lib/controllers/PluginController.js +11 -57
  9. package/lib/controllers/PresetController.d.ts +5 -3
  10. package/lib/controllers/PresetController.js +73 -55
  11. package/lib/controllers/ProjectController.d.ts +5 -3
  12. package/lib/controllers/ProjectController.js +71 -46
  13. package/lib/controllers/ProxyController.d.ts +1 -1
  14. package/lib/controllers/ProxyController.js +56 -14
  15. package/lib/controllers/index.d.ts +1 -1
  16. package/lib/controllers/index.js +1 -1
  17. package/lib/env.d.ts +2 -1
  18. package/lib/env.js +20 -9
  19. package/lib/keystore/KeystoreService.d.ts +12 -0
  20. package/lib/keystore/KeystoreService.js +70 -0
  21. package/lib/keystore/index.d.ts +1 -0
  22. package/lib/keystore/index.js +17 -0
  23. package/lib/keystore/providers/FileKeystoreProvider.d.ts +16 -0
  24. package/lib/keystore/providers/FileKeystoreProvider.js +97 -0
  25. package/lib/keystore/providers/KeytarKeystoreProvider.d.ts +9 -0
  26. package/lib/keystore/providers/KeytarKeystoreProvider.js +74 -0
  27. package/lib/keystore/types/Encryption.d.ts +9 -0
  28. package/lib/keystore/types/Encryption.js +81 -0
  29. package/lib/keystore/types/Encryptor.d.ts +10 -0
  30. package/lib/keystore/types/Encryptor.js +59 -0
  31. package/lib/keystore/types/FileKeystore.d.ts +17 -0
  32. package/lib/keystore/types/FileKeystore.js +33 -0
  33. package/lib/keystore/types/Keytar.d.ts +8 -0
  34. package/lib/keystore/types/Keytar.js +2 -0
  35. package/lib/keystore/utils/createEncryptionKey.d.ts +1 -0
  36. package/lib/keystore/utils/createEncryptionKey.js +46 -0
  37. package/lib/keystore/utils/createPasswordHash.d.ts +1 -0
  38. package/lib/keystore/utils/createPasswordHash.js +20 -0
  39. package/lib/keystore/utils/decrypt.d.ts +1 -0
  40. package/lib/keystore/utils/decrypt.js +15 -0
  41. package/lib/keystore/utils/encrypt.d.ts +1 -0
  42. package/lib/keystore/utils/encrypt.js +19 -0
  43. package/lib/keystore/utils/index.d.ts +5 -0
  44. package/lib/keystore/utils/index.js +21 -0
  45. package/lib/keystore/utils/verifyPasswordHash.d.ts +1 -0
  46. package/lib/keystore/utils/verifyPasswordHash.js +9 -0
  47. package/lib/main.js +10 -5
  48. package/lib/makes/FS.d.ts +2 -2
  49. package/lib/makes/FS.js +19 -9
  50. package/lib/makes/GithubClient.d.ts +14 -0
  51. package/lib/makes/GithubClient.js +65 -0
  52. package/lib/makes/Http.js +17 -7
  53. package/lib/makes/Plugin.d.ts +6 -0
  54. package/lib/makes/Plugin.js +16 -0
  55. package/lib/makes/index.d.ts +1 -0
  56. package/lib/makes/index.js +1 -0
  57. package/lib/plugins/MongodbPlugin.js +17 -7
  58. package/lib/plugins/index.d.ts +0 -2
  59. package/lib/plugins/index.js +0 -2
  60. package/lib/repositories/PresetRepository.d.ts +23 -0
  61. package/lib/repositories/PresetRepository.js +115 -0
  62. package/lib/repositories/index.d.ts +1 -0
  63. package/lib/repositories/index.js +17 -0
  64. package/lib/services/AppConfigService.d.ts +16 -1
  65. package/lib/services/AppConfigService.js +88 -62
  66. package/lib/services/AppEventsService.d.ts +4 -4
  67. package/lib/services/AppEventsService.js +14 -10
  68. package/lib/services/CertService.js +18 -8
  69. package/lib/services/DockerService.d.ts +2 -2
  70. package/lib/services/DockerService.js +14 -8
  71. package/lib/services/LogService.d.ts +4 -1
  72. package/lib/services/LogService.js +14 -8
  73. package/lib/services/PluginService.d.ts +8 -2
  74. package/lib/services/PluginService.js +88 -23
  75. package/lib/services/PresetService.d.ts +9 -8
  76. package/lib/services/PresetService.js +144 -248
  77. package/lib/services/ProjectService.d.ts +5 -2
  78. package/lib/services/ProjectService.js +37 -10
  79. package/lib/services/ProxyService.d.ts +3 -2
  80. package/lib/services/ProxyService.js +43 -25
  81. package/lib/utils/index.d.ts +0 -2
  82. package/lib/utils/index.js +0 -2
  83. package/package.json +30 -15
  84. package/plugins/proxy/Dockerfile +17 -1
  85. package/plugins/proxy/Procfile +2 -0
  86. package/lib/controllers/ImageController.d.ts +0 -7
  87. package/lib/controllers/ImageController.js +0 -46
  88. package/lib/makes/Model.d.ts +0 -5
  89. package/lib/makes/Model.js +0 -12
  90. package/lib/plugins/ElasticSearchPlugin.d.ts +0 -15
  91. package/lib/plugins/ElasticSearchPlugin.js +0 -72
  92. package/lib/plugins/ProxmoxPlugin.d.ts +0 -12
  93. package/lib/plugins/ProxmoxPlugin.js +0 -83
  94. package/lib/utils/volumeFormat.d.ts +0 -6
  95. package/lib/utils/volumeFormat.js +0 -8
  96. package/lib/utils/volumeParse.d.ts +0 -2
  97. package/lib/utils/volumeParse.js +0 -13
  98. package/plugins/proxy/config.json +0 -3
  99. package/presets/bun/Dockerfile +0 -11
  100. package/presets/bun/config.json +0 -4
@@ -21,13 +21,23 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
21
21
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
22
22
  return c > 3 && r && Object.defineProperty(target, key, r), r;
23
23
  };
24
- var __importStar = (this && this.__importStar) || function (mod) {
25
- if (mod && mod.__esModule) return mod;
26
- var result = {};
27
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
28
- __setModuleDefault(result, mod);
29
- return result;
30
- };
24
+ var __importStar = (this && this.__importStar) || (function () {
25
+ var ownKeys = function(o) {
26
+ ownKeys = Object.getOwnPropertyNames || function (o) {
27
+ var ar = [];
28
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
29
+ return ar;
30
+ };
31
+ return ownKeys(o);
32
+ };
33
+ return function (mod) {
34
+ if (mod && mod.__esModule) return mod;
35
+ var result = {};
36
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
37
+ __setModuleDefault(result, mod);
38
+ return result;
39
+ };
40
+ })();
31
41
  var __metadata = (this && this.__metadata) || function (k, v) {
32
42
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
33
43
  };
@@ -37,23 +47,26 @@ const core_1 = require("@wocker/core");
37
47
  const utils_1 = require("@wocker/utils");
38
48
  const Path = __importStar(require("path"));
39
49
  const env_1 = require("../env");
40
- const makes_1 = require("../makes");
41
50
  const AppConfigService_1 = require("./AppConfigService");
42
51
  const DockerService_1 = require("./DockerService");
43
- let ProxyService = class ProxyService {
52
+ let ProxyService = class ProxyService extends core_1.ProxyService {
44
53
  constructor(appConfigService, dockerService) {
54
+ super();
45
55
  this.appConfigService = appConfigService;
46
56
  this.dockerService = dockerService;
47
57
  this.containerName = "proxy.workspace";
48
- this.imageName = "wocker-proxy:1.0.0";
58
+ this.imageName = "wocker-proxy:1.0.1";
59
+ this.oldImages = [
60
+ "wocker-proxy:1.0.0"
61
+ ];
49
62
  }
50
63
  async init(project) {
51
- const appPort = await (0, utils_1.promptText)({
52
- message: "App port:",
64
+ const appPort = await (0, utils_1.promptInput)({
65
+ message: "App port",
53
66
  type: "number",
54
- default: project.getEnv("VIRTUAL_PORT", "80")
67
+ default: parseInt(project.getEnv("VIRTUAL_PORT", "80"))
55
68
  });
56
- project.setEnv("VIRTUAL_PORT", appPort);
69
+ project.setEnv("VIRTUAL_PORT", appPort.toString());
57
70
  await project.save();
58
71
  }
59
72
  async start(restart, rebuild) {
@@ -64,7 +77,6 @@ let ProxyService = class ProxyService {
64
77
  if (!container) {
65
78
  console.info("Proxy starting...");
66
79
  await this.build(rebuild);
67
- const certsDir = this.appConfigService.dataPath("certs");
68
80
  if (!this.appConfigService.fs.exists("certs/ca")) {
69
81
  this.appConfigService.fs.mkdir("certs/ca", {
70
82
  recursive: true,
@@ -77,15 +89,10 @@ let ProxyService = class ProxyService {
77
89
  mode: 0o700
78
90
  });
79
91
  }
80
- if (!makes_1.FS.existsSync(certsDir)) {
81
- makes_1.FS.mkdirSync(certsDir, {
82
- recursive: true,
83
- mode: 0o700
84
- });
85
- }
86
- const config = this.appConfigService.getConfig();
92
+ const config = this.appConfigService.config;
87
93
  const httpPort = config.getMeta("PROXY_HTTP_PORT", "80");
88
94
  const httpsPort = config.getMeta("PROXY_HTTPS_PORT", "443");
95
+ const sshPort = config.getMeta("PROXY_SSH_PORT", "22");
89
96
  container = await this.dockerService.createContainer({
90
97
  name: this.containerName,
91
98
  image: this.imageName,
@@ -96,13 +103,17 @@ let ProxyService = class ProxyService {
96
103
  },
97
104
  ports: [
98
105
  `${httpPort}:80`,
99
- `${httpsPort}:443`
106
+ `${httpsPort}:443`,
107
+ ...config.getMeta("PROXY_SSH_PASSWORD") ? [
108
+ `${sshPort}:22`
109
+ ] : []
100
110
  ],
101
111
  volumes: [
102
112
  "/var/run/docker.sock:/tmp/docker.sock:ro",
103
113
  `${this.appConfigService.fs.path("certs/projects")}:/etc/nginx/certs`,
104
114
  `${this.appConfigService.fs.path("certs/ca")}:/etc/nginx/ca-certs`
105
- ]
115
+ ],
116
+ network: "workspace"
106
117
  });
107
118
  }
108
119
  const { State: { Status } } = await container.inspect();
@@ -123,10 +134,17 @@ let ProxyService = class ProxyService {
123
134
  if (exists) {
124
135
  return;
125
136
  }
137
+ for (const oldImage of this.oldImages) {
138
+ await this.dockerService.imageRm(oldImage);
139
+ }
140
+ const config = this.appConfigService.config;
126
141
  await this.dockerService.buildImage({
127
142
  tag: this.imageName,
128
143
  context: Path.join(env_1.PLUGINS_DIR, "proxy"),
129
- src: "./Dockerfile"
144
+ src: "./Dockerfile",
145
+ buildArgs: {
146
+ SSH_PASSWORD: config.getMeta("PROXY_SSH_PASSWORD")
147
+ }
130
148
  });
131
149
  }
132
150
  async logs() {
@@ -6,5 +6,3 @@ export * from "./get-cursor-position";
6
6
  export * from "./injectVariables";
7
7
  export * from "./parse-table";
8
8
  export * from "./spawn";
9
- export * from "./volumeFormat";
10
- export * from "./volumeParse";
@@ -22,5 +22,3 @@ __exportStar(require("./get-cursor-position"), exports);
22
22
  __exportStar(require("./injectVariables"), exports);
23
23
  __exportStar(require("./parse-table"), exports);
24
24
  __exportStar(require("./spawn"), exports);
25
- __exportStar(require("./volumeFormat"), exports);
26
- __exportStar(require("./volumeParse"), exports);
package/package.json CHANGED
@@ -1,11 +1,17 @@
1
1
  {
2
2
  "name": "@wocker/ws",
3
- "version": "1.0.20",
3
+ "version": "1.0.22",
4
4
  "author": "Kris Papercut <krispcut@gmail.com>",
5
5
  "description": "Docker workspace for web projects",
6
6
  "license": "MIT",
7
- "main": "lib/index.js",
8
- "types": "lib/index.d.ts",
7
+ "main": "./lib/index.js",
8
+ "types": "./lib/index.d.ts",
9
+ "keywords": [
10
+ "wocker",
11
+ "workspace",
12
+ "docker",
13
+ "devops"
14
+ ],
9
15
  "bin": {
10
16
  "ws": "./bin/ws.js"
11
17
  },
@@ -18,37 +24,46 @@
18
24
  "url": "https://github.com/kearisp/wocker-ws/issues"
19
25
  },
20
26
  "scripts": {
21
- "prepare": "npm run build",
27
+ "prepublishOnly": "npm run build",
22
28
  "start": "npm run watch",
23
- "build": "tsc",
24
- "watch": "tsc -w"
29
+ "build": "tsc --project tsconfig.build.json",
30
+ "watch": "tsc -w --project tsconfig.build.json",
31
+ "test": "jest --colors",
32
+ "test-watch": "jest --colors --watchAll",
33
+ "make-coverage-badge": "make-coverage-badge"
25
34
  },
26
35
  "dependencies": {
27
- "@wocker/core": "1.0.20",
28
- "@wocker/utils": "^1.0.7",
36
+ "@wocker/core": "1.0.22",
37
+ "@wocker/utils": "^2.0.0",
29
38
  "async-mutex": "^0.4.0",
30
39
  "axios": "^1.6.7",
31
- "chalk": "^2.4.2",
32
40
  "child_process": "^1.0.2",
33
41
  "cli-table3": "^0.6.2",
34
42
  "date-fns": "^2.29.3",
35
43
  "dockerode": "^4.0.2",
36
44
  "fs": "^0.0.1-security",
45
+ "keytar": "^7.9.0",
37
46
  "md5": "^2.3.0",
38
47
  "os": "^0.1.2",
39
48
  "path": "^0.12.7",
40
49
  "readable-stream": "^4.1.0",
41
- "unzipper": "^0.12.3"
50
+ "unzipper": "^0.12.3",
51
+ "yoctocolors-cjs": "^2.1.2"
42
52
  },
43
53
  "devDependencies": {
44
- "@types/dockerode": "3.3.23",
45
- "@types/jest": "^29.5.12",
46
- "@types/lodash": "^4.14.161",
54
+ "@types/dockerode": "^3.3.23",
55
+ "@types/jest": "^29.5.14",
47
56
  "@types/md5": "^2.3.2",
48
- "@types/mute-stream": "^0.0.1",
49
- "@types/node": "^20.11.16",
57
+ "@types/mute-stream": "^0.0.4",
58
+ "@types/node": "^22.14.1",
50
59
  "@types/readable-stream": "^2.3.15",
51
60
  "@types/unzipper": "^0.10.10",
61
+ "@wocker/testing": "^1.0.0",
62
+ "jest": "^29.7.0",
63
+ "make-coverage-badge": "^1.2.0",
64
+ "memfs": "^4.17.0",
65
+ "ts-jest": "^29.3.2",
66
+ "ts-node": "^10.9.2",
52
67
  "typescript": "^5.6.3"
53
68
  }
54
69
  }
@@ -1,4 +1,6 @@
1
- FROM nginxproxy/nginx-proxy:latest
1
+ FROM nginxproxy/nginx-proxy:1.6.4-alpine
2
+
3
+ ARG SSH_PASSWORD=''
2
4
 
3
5
  COPY ./bin/wocker-create-ca /usr/local/bin/wocker-create-ca
4
6
  COPY ./bin/wocker-create-cert /usr/local/bin/wocker-create-cert
@@ -7,3 +9,17 @@ COPY ./bin/wocker-create-domains /usr/local/bin/wocker-create-domains
7
9
  RUN chmod +x /usr/local/bin/wocker-create-ca && \
8
10
  chmod +x /usr/local/bin/wocker-create-cert && \
9
11
  chmod +x /usr/local/bin/wocker-create-domains
12
+
13
+ RUN if [ -n "$SSH_PASSWORD" ]; then \
14
+ apk update && apk add --no-cache openssh; \
15
+ mkdir -p /var/run/sshd; \
16
+ echo "root:$SSH_PASSWORD" | chpasswd; \
17
+ sed -i 's/AllowTcpForwarding no/AllowTcpForwarding yes/' /etc/ssh/sshd_config; \
18
+ sed -i 's/GatewayPorts no/GatewayPorts yes/' /etc/ssh/sshd_config; \
19
+ sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config; \
20
+ sed -i 's/#UsePAM yes/UsePAM no/' /etc/ssh/sshd_config; \
21
+ ssh-keygen -A; \
22
+ echo "sshd: /usr/sbin/sshd -D" >> /app/Procfile; \
23
+ fi
24
+
25
+ EXPOSE 22
@@ -0,0 +1,2 @@
1
+ nginx: nginx -g "daemon off;"
2
+ docker-gen: docker-gen -watch -config /app/docker-gen.conf
@@ -1,7 +0,0 @@
1
- import { AppConfigService, DockerService } from "../services";
2
- export declare class ImageController {
3
- protected readonly appConfigService: AppConfigService;
4
- protected readonly dockerService: DockerService;
5
- constructor(appConfigService: AppConfigService, dockerService: DockerService);
6
- list(): Promise<string>;
7
- }
@@ -1,46 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.ImageController = void 0;
16
- const core_1 = require("@wocker/core");
17
- const cli_table3_1 = __importDefault(require("cli-table3"));
18
- const services_1 = require("../services");
19
- let ImageController = class ImageController {
20
- constructor(appConfigService, dockerService) {
21
- this.appConfigService = appConfigService;
22
- this.dockerService = dockerService;
23
- }
24
- async list() {
25
- const images = await this.dockerService.imageLs({});
26
- const table = new cli_table3_1.default({
27
- head: ["Name"]
28
- });
29
- for (const image of images) {
30
- table.push([image.Id]);
31
- }
32
- return table.toString();
33
- }
34
- };
35
- exports.ImageController = ImageController;
36
- __decorate([
37
- (0, core_1.Command)("images"),
38
- __metadata("design:type", Function),
39
- __metadata("design:paramtypes", []),
40
- __metadata("design:returntype", Promise)
41
- ], ImageController.prototype, "list", null);
42
- exports.ImageController = ImageController = __decorate([
43
- (0, core_1.Controller)(),
44
- __metadata("design:paramtypes", [services_1.AppConfigService,
45
- services_1.DockerService])
46
- ], ImageController);
@@ -1,5 +0,0 @@
1
- export declare class Model {
2
- attributes: {};
3
- constructor(attributes?: any);
4
- save(): Promise<void>;
5
- }
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Model = void 0;
4
- class Model {
5
- constructor(attributes = {}) {
6
- this.attributes = {};
7
- this.attributes = attributes;
8
- }
9
- async save() {
10
- }
11
- }
12
- exports.Model = Model;
@@ -1,15 +0,0 @@
1
- import { FSManager } from "@wocker/core";
2
- import { AppConfigService, DockerService } from "../services";
3
- type StartOptions = {
4
- restart?: boolean;
5
- };
6
- export declare class ElasticSearchPlugin {
7
- protected readonly appConfigService: AppConfigService;
8
- protected readonly dockerService: DockerService;
9
- protected containerName: string;
10
- protected fs: FSManager;
11
- constructor(appConfigService: AppConfigService, dockerService: DockerService);
12
- start(options: StartOptions): Promise<void>;
13
- stop(): Promise<void>;
14
- }
15
- export {};
@@ -1,72 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.ElasticSearchPlugin = void 0;
13
- const core_1 = require("@wocker/core");
14
- const services_1 = require("../services");
15
- let ElasticSearchPlugin = class ElasticSearchPlugin {
16
- constructor(appConfigService, dockerService) {
17
- this.appConfigService = appConfigService;
18
- this.dockerService = dockerService;
19
- this.containerName = "elastic-search.workspace";
20
- this.fs = new core_1.FSManager(this.appConfigService.pluginsPath("elastic-search"), this.appConfigService.dataPath("plugins/elastic-search"));
21
- }
22
- async start(options) {
23
- const { restart } = options;
24
- await this.dockerService.pullImage("docker.elastic.co/elasticsearch/elasticsearch:7.5.2");
25
- let container = await this.dockerService.getContainer(this.containerName);
26
- if (restart && container) {
27
- await this.dockerService.removeContainer(this.containerName);
28
- container = null;
29
- }
30
- if (!container) {
31
- await this.fs.mkdir("data", {
32
- recursive: true
33
- });
34
- container = await this.dockerService.createContainer({
35
- name: this.containerName,
36
- image: "docker.elastic.co/elasticsearch/elasticsearch:7.5.2",
37
- ulimits: {
38
- memlock: {
39
- hard: -1,
40
- soft: -1
41
- }
42
- },
43
- env: {
44
- "node.name": "elasticsearch",
45
- "cluster.name": "elasticsearch",
46
- "cluster.initial_master_nodes": "elasticsearch",
47
- "bootstrap.memory_lock": "false",
48
- ES_JAVA_OPTS: "-Xms512m -Xmx512m"
49
- },
50
- volumes: [
51
- `${this.fs.path("data")}:/usr/share/elasticsearch/data`
52
- ],
53
- ports: [
54
- "9200:9200"
55
- ]
56
- });
57
- }
58
- const { State: { Status } } = await container.inspect();
59
- if (Status === "created" || Status === "exited") {
60
- await container.start();
61
- }
62
- }
63
- async stop() {
64
- await this.dockerService.removeContainer(this.containerName);
65
- }
66
- };
67
- exports.ElasticSearchPlugin = ElasticSearchPlugin;
68
- exports.ElasticSearchPlugin = ElasticSearchPlugin = __decorate([
69
- (0, core_1.Controller)(),
70
- __metadata("design:paramtypes", [services_1.AppConfigService,
71
- services_1.DockerService])
72
- ], ElasticSearchPlugin);
@@ -1,12 +0,0 @@
1
- import { FSManager } from "@wocker/core";
2
- import { AppConfigService, DockerService } from "../services";
3
- export declare class ProxmoxPlugin {
4
- protected readonly appConfigService: AppConfigService;
5
- protected readonly dockerService: DockerService;
6
- protected configDir: string;
7
- protected fs: FSManager;
8
- constructor(appConfigService: AppConfigService, dockerService: DockerService);
9
- pluginPath(...parts: string[]): string;
10
- up(): Promise<void>;
11
- down(): Promise<void>;
12
- }
@@ -1,83 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
19
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
20
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
21
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
22
- return c > 3 && r && Object.defineProperty(target, key, r), r;
23
- };
24
- var __importStar = (this && this.__importStar) || function (mod) {
25
- if (mod && mod.__esModule) return mod;
26
- var result = {};
27
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
28
- __setModuleDefault(result, mod);
29
- return result;
30
- };
31
- var __metadata = (this && this.__metadata) || function (k, v) {
32
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
33
- };
34
- Object.defineProperty(exports, "__esModule", { value: true });
35
- exports.ProxmoxPlugin = void 0;
36
- const core_1 = require("@wocker/core");
37
- const Path = __importStar(require("path"));
38
- const services_1 = require("../services");
39
- const utils_1 = require("../utils");
40
- let ProxmoxPlugin = class ProxmoxPlugin {
41
- constructor(appConfigService, dockerService) {
42
- this.appConfigService = appConfigService;
43
- this.dockerService = dockerService;
44
- this.configDir = this.appConfigService.dataPath("plugins/proxmox");
45
- }
46
- pluginPath(...parts) {
47
- return Path.join(this.appConfigService.pluginsPath("proxmox"), ...parts);
48
- }
49
- async up() {
50
- const container = await this.dockerService.getContainer("proxmox.workspace");
51
- if (container) {
52
- await this.down();
53
- }
54
- await (0, utils_1.exec)(`
55
- docker build \
56
- --tag "ws-proxmox" \
57
- --file "${this.pluginPath("./Dockerfile")}" \
58
- ${this.pluginPath()}
59
- `);
60
- await (0, utils_1.exec)(`
61
- docker run -d \
62
- --name proxmox.workspace \
63
- --network workspace \
64
- -e VIRTUAL_HOST=proxmox.workspace \
65
- -p 8006:8006 \
66
- ws-proxmox
67
- `);
68
- }
69
- async down() {
70
- await (0, utils_1.exec)("docker stop proxmox.workspace").catch(() => {
71
- });
72
- await (0, utils_1.exec)("docker rm proxmox.workspace").catch(() => {
73
- });
74
- await (0, utils_1.exec)("docker image rm ws-proxmox").catch(() => {
75
- });
76
- }
77
- };
78
- exports.ProxmoxPlugin = ProxmoxPlugin;
79
- exports.ProxmoxPlugin = ProxmoxPlugin = __decorate([
80
- (0, core_1.Controller)(),
81
- __metadata("design:paramtypes", [services_1.AppConfigService,
82
- services_1.DockerService])
83
- ], ProxmoxPlugin);
@@ -1,6 +0,0 @@
1
- export type Volume = {
2
- source: string;
3
- destination: string;
4
- options?: string;
5
- };
6
- export declare const volumeFormat: (volume: Volume) => string;
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.volumeFormat = void 0;
4
- const volumeFormat = (volume) => {
5
- const { source, destination, options } = volume;
6
- return `${source}:${destination}` + (options ? `:${options}` : "");
7
- };
8
- exports.volumeFormat = volumeFormat;
@@ -1,2 +0,0 @@
1
- import { Volume } from "./volumeFormat";
2
- export declare const volumeParse: (volume: string) => Volume;
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.volumeParse = void 0;
4
- const volumeParse = (volume) => {
5
- const regVolume = /^([^:]+):([^:]+)(?::([^:]+))?$/;
6
- const [, source, destination, options] = regVolume.exec(volume);
7
- return {
8
- source,
9
- destination,
10
- options
11
- };
12
- };
13
- exports.volumeParse = volumeParse;
@@ -1,3 +0,0 @@
1
- {
2
- "dockerfile": "./Dockerfile"
3
- }
@@ -1,11 +0,0 @@
1
- FROM ubuntu:latest
2
-
3
- RUN apt-get update && \
4
- apt-get -y install wget curl unzip
5
-
6
- RUN curl -fsSL https://bun.sh/install | bash
7
-
8
- ENV BUN_INSTALL="/root/.bun"
9
- ENV PATH="$BUN_INSTALL/bin:$PATH"
10
-
11
- # TODO
@@ -1,4 +0,0 @@
1
- {
2
- "name": "bun",
3
- "dockerfile": "./Dockerfile"
4
- }