@wocker/ws 1.0.20 → 1.0.21

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 (40) hide show
  1. package/lib/AppModule.js +21 -7
  2. package/lib/controllers/PresetController.d.ts +1 -1
  3. package/lib/controllers/PresetController.js +24 -12
  4. package/lib/controllers/ProjectController.d.ts +4 -3
  5. package/lib/controllers/ProjectController.js +26 -10
  6. package/lib/controllers/ProxyController.d.ts +1 -1
  7. package/lib/controllers/ProxyController.js +38 -2
  8. package/lib/env.js +17 -7
  9. package/lib/makes/FS.d.ts +2 -2
  10. package/lib/makes/FS.js +19 -9
  11. package/lib/makes/Http.js +17 -7
  12. package/lib/plugins/MongodbPlugin.js +17 -7
  13. package/lib/plugins/elastic-search/controllers/ElasticSearchController.d.ts +10 -0
  14. package/lib/plugins/{ElasticSearchPlugin.js → elastic-search/controllers/ElasticSearchController.js} +32 -13
  15. package/lib/plugins/elastic-search/index.d.ts +2 -0
  16. package/lib/plugins/elastic-search/index.js +22 -0
  17. package/lib/plugins/index.d.ts +2 -2
  18. package/lib/plugins/index.js +2 -2
  19. package/lib/plugins/proxmox/controllers/ProxmoxController.d.ts +14 -0
  20. package/lib/plugins/proxmox/controllers/ProxmoxController.js +127 -0
  21. package/lib/plugins/proxmox/index.d.ts +2 -0
  22. package/lib/plugins/proxmox/index.js +23 -0
  23. package/lib/services/AppConfigService.js +17 -7
  24. package/lib/services/CertService.js +18 -8
  25. package/lib/services/DockerService.d.ts +2 -2
  26. package/lib/services/DockerService.js +8 -5
  27. package/lib/services/LogService.d.ts +1 -0
  28. package/lib/services/LogService.js +4 -0
  29. package/lib/services/PluginService.js +17 -7
  30. package/lib/services/PresetService.d.ts +1 -1
  31. package/lib/services/PresetService.js +18 -8
  32. package/lib/services/ProxyService.d.ts +3 -2
  33. package/lib/services/ProxyService.js +38 -20
  34. package/package.json +10 -5
  35. package/plugins/proxy/Dockerfile +17 -1
  36. package/plugins/proxy/Procfile +2 -0
  37. package/lib/plugins/ElasticSearchPlugin.d.ts +0 -15
  38. package/lib/plugins/ProxmoxPlugin.d.ts +0 -12
  39. package/lib/plugins/ProxmoxPlugin.js +0 -83
  40. package/plugins/proxy/config.json +0 -3
@@ -0,0 +1,127 @@
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 () {
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
+ })();
41
+ var __metadata = (this && this.__metadata) || function (k, v) {
42
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
43
+ };
44
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
45
+ return function (target, key) { decorator(target, key, paramIndex); }
46
+ };
47
+ Object.defineProperty(exports, "__esModule", { value: true });
48
+ exports.ProxmoxController = void 0;
49
+ const core_1 = require("@wocker/core");
50
+ const Path = __importStar(require("path"));
51
+ let ProxmoxController = class ProxmoxController {
52
+ constructor(appConfigService, dockerService) {
53
+ this.appConfigService = appConfigService;
54
+ this.dockerService = dockerService;
55
+ this.containerName = "proxmox.workspace";
56
+ this.imageName = "wocker-proxmox:1.0.0";
57
+ this.configDir = this.appConfigService.dataPath("plugins/proxmox");
58
+ }
59
+ pluginPath(...parts) {
60
+ return Path.join(this.appConfigService.pluginsPath("proxmox"), ...parts);
61
+ }
62
+ async start(restart, rebuild) {
63
+ if (restart || rebuild) {
64
+ await this.dockerService.removeContainer(this.containerName);
65
+ }
66
+ let container = await this.dockerService.getContainer(this.containerName);
67
+ if (!container) {
68
+ await this.build(rebuild);
69
+ container = await this.dockerService.createContainer({
70
+ name: this.containerName,
71
+ image: this.imageName,
72
+ env: {
73
+ VIRTUAL_HOST: this.containerName,
74
+ VIRTUAL_PORT: "8006"
75
+ }
76
+ });
77
+ }
78
+ const { State: { Running } } = await container.inspect();
79
+ if (!Running) {
80
+ await container.start();
81
+ }
82
+ }
83
+ async stop() {
84
+ await this.dockerService.removeContainer(this.containerName);
85
+ }
86
+ async build(rebuild) {
87
+ if (rebuild) {
88
+ await this.dockerService.imageRm(this.imageName);
89
+ }
90
+ else {
91
+ if (await this.dockerService.imageExists(this.imageName)) {
92
+ return;
93
+ }
94
+ }
95
+ await this.dockerService.buildImage({
96
+ tag: this.imageName,
97
+ context: this.pluginPath(),
98
+ src: "./Dockerfile"
99
+ });
100
+ }
101
+ };
102
+ exports.ProxmoxController = ProxmoxController;
103
+ __decorate([
104
+ (0, core_1.Command)("proxmox:start"),
105
+ (0, core_1.Description)("Starting proxmox"),
106
+ __param(0, (0, core_1.Option)("restart", {
107
+ alias: "r"
108
+ })),
109
+ __param(1, (0, core_1.Option)("rebuild", {
110
+ alias: "b"
111
+ })),
112
+ __metadata("design:type", Function),
113
+ __metadata("design:paramtypes", [Boolean, Boolean]),
114
+ __metadata("design:returntype", Promise)
115
+ ], ProxmoxController.prototype, "start", null);
116
+ __decorate([
117
+ (0, core_1.Command)("proxmox:stop"),
118
+ (0, core_1.Description)("Stopping proxmox"),
119
+ __metadata("design:type", Function),
120
+ __metadata("design:paramtypes", []),
121
+ __metadata("design:returntype", Promise)
122
+ ], ProxmoxController.prototype, "stop", null);
123
+ exports.ProxmoxController = ProxmoxController = __decorate([
124
+ (0, core_1.Controller)(),
125
+ __metadata("design:paramtypes", [core_1.AppConfigService,
126
+ core_1.DockerService])
127
+ ], ProxmoxController);
@@ -0,0 +1,2 @@
1
+ export declare class ProxmoxPlugin {
2
+ }
@@ -0,0 +1,23 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.ProxmoxPlugin = void 0;
10
+ const core_1 = require("@wocker/core");
11
+ const ProxmoxController_1 = require("./controllers/ProxmoxController");
12
+ let ProxmoxPlugin = class ProxmoxPlugin {
13
+ };
14
+ exports.ProxmoxPlugin = ProxmoxPlugin;
15
+ exports.ProxmoxPlugin = ProxmoxPlugin = __decorate([
16
+ (0, core_1.Plugin)({
17
+ name: "proxmox",
18
+ controllers: [
19
+ ProxmoxController_1.ProxmoxController
20
+ ],
21
+ providers: []
22
+ })
23
+ ], ProxmoxPlugin);
@@ -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
  };
@@ -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
  };
@@ -127,7 +137,7 @@ let CertService = class CertService {
127
137
  return;
128
138
  }
129
139
  for (const ext of certs[name]) {
130
- this.appConfigService.fs.rm(`certs/projects/${name}${ext}`);
140
+ await this.appConfigService.fs.rm(`certs/projects/${name}${ext}`);
131
141
  }
132
142
  console.info(`Cert ${name} deleted`);
133
143
  }
@@ -1,7 +1,7 @@
1
- import { DockerServiceParams as Params } from "@wocker/core";
1
+ import { DockerService as CoreDockerService, DockerServiceParams as Params } from "@wocker/core";
2
2
  import Docker, { Container, Volume, VolumeCreateResponse } from "dockerode";
3
3
  import { LogService } from "./LogService";
4
- export declare class DockerService {
4
+ export declare class DockerService extends CoreDockerService {
5
5
  protected readonly logService: LogService;
6
6
  protected docker: Docker;
7
7
  constructor(logService: LogService);
@@ -18,8 +18,9 @@ const dockerode_1 = __importDefault(require("dockerode"));
18
18
  const utils_1 = require("../utils");
19
19
  const makes_1 = require("../makes");
20
20
  const LogService_1 = require("./LogService");
21
- let DockerService = class DockerService {
21
+ let DockerService = class DockerService extends core_1.DockerService {
22
22
  constructor(logService) {
23
+ super();
23
24
  this.logService = logService;
24
25
  this.docker = new dockerode_1.default({
25
26
  socketPath: "/var/run/docker.sock"
@@ -49,15 +50,15 @@ let DockerService = class DockerService {
49
50
  await volume.remove();
50
51
  }
51
52
  async createContainer(params) {
52
- const { name, user, entrypoint, tty, image, projectId, restart, ulimits, extraHosts, networkMode = "bridge", links = [], env = {}, volumes = [], ports = [], cmd = [] } = params;
53
- const network = this.docker.getNetwork("workspace");
53
+ const { name, user, entrypoint, tty, image, projectId, restart, memory, memorySwap, ulimits, extraHosts, networkMode = "bridge", links = [], env = {}, volumes = [], ports = [], cmd = [], network: networkName = "workspace", aliases } = params;
54
+ const network = this.docker.getNetwork(networkName);
54
55
  try {
55
56
  await network.inspect();
56
57
  }
57
58
  catch (err) {
58
59
  if (err.statusCode === 404) {
59
60
  await this.docker.createNetwork({
60
- Name: "workspace"
61
+ Name: networkName
61
62
  });
62
63
  }
63
64
  }
@@ -91,6 +92,8 @@ let DockerService = class DockerService {
91
92
  return res;
92
93
  }, {}),
93
94
  HostConfig: {
95
+ Memory: memory,
96
+ MemorySwap: memorySwap,
94
97
  NetworkMode: networkMode,
95
98
  ExtraHosts: extraHosts,
96
99
  Ulimits: ulimits ? Object.keys(ulimits).reduce((res, name) => {
@@ -126,7 +129,7 @@ let DockerService = class DockerService {
126
129
  EndpointsConfig: networkMode === "host" ? {} : {
127
130
  workspace: {
128
131
  Links: links,
129
- Aliases: env.VIRTUAL_HOST ? env.VIRTUAL_HOST.split(",") : undefined
132
+ Aliases: aliases || (env.VIRTUAL_HOST ? env.VIRTUAL_HOST.split(",") : undefined)
130
133
  }
131
134
  }
132
135
  }
@@ -8,5 +8,6 @@ export declare class LogService extends CoreLogService {
8
8
  info(...data: any[]): void;
9
9
  warn(...data: any[]): void;
10
10
  error(...data: any[]): void;
11
+ clear(): void;
11
12
  protected _log(type: string, ...data: any[]): void;
12
13
  }
@@ -38,6 +38,10 @@ let LogService = class LogService extends core_1.LogService {
38
38
  error(...data) {
39
39
  this._log("error", ...data);
40
40
  }
41
+ clear() {
42
+ const logPath = this.appConfigService.dataPath("ws.log");
43
+ makes_1.FS.writeFileSync(logPath, "");
44
+ }
41
45
  _log(type, ...data) {
42
46
  const config = this.appConfigService.getConfig();
43
47
  if (type === "debug" && !config.debug) {
@@ -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
  };
@@ -17,7 +17,7 @@ export declare class PresetService {
17
17
  init(): Promise<void>;
18
18
  deinit(): Promise<void>;
19
19
  get(name: string): Promise<Preset>;
20
- addPreset(name: string): Promise<void>;
20
+ addPreset(name: string, version?: string): Promise<void>;
21
21
  search(options?: SearchOptions): Promise<Preset[]>;
22
22
  searchOne(options?: SearchOptions): Promise<Preset | null>;
23
23
  }
@@ -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
  };
@@ -267,7 +277,7 @@ let PresetService = class PresetService {
267
277
  ...config
268
278
  });
269
279
  }
270
- async addPreset(name) {
280
+ async addPreset(name, version) {
271
281
  let preset = await this.searchOne({
272
282
  name
273
283
  });
@@ -1,11 +1,12 @@
1
- import { Project } from "@wocker/core";
1
+ import { Project, ProxyService as CoreProxyService } from "@wocker/core";
2
2
  import { AppConfigService } from "./AppConfigService";
3
3
  import { DockerService } from "./DockerService";
4
- export declare class ProxyService {
4
+ export declare class ProxyService extends CoreProxyService {
5
5
  protected readonly appConfigService: AppConfigService;
6
6
  protected readonly dockerService: DockerService;
7
7
  protected containerName: string;
8
8
  protected imageName: string;
9
+ protected oldImages: string[];
9
10
  constructor(appConfigService: AppConfigService, dockerService: DockerService);
10
11
  init(project: Project): Promise<void>;
11
12
  start(restart?: boolean, rebuild?: boolean): Promise<void>;
@@ -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,15 +47,18 @@ 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
64
  const appPort = await (0, utils_1.promptText)({
@@ -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
92
  const config = this.appConfigService.getConfig();
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.getConfig();
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() {
package/package.json CHANGED
@@ -1,11 +1,17 @@
1
1
  {
2
2
  "name": "@wocker/ws",
3
- "version": "1.0.20",
3
+ "version": "1.0.21",
4
4
  "author": "Kris Papercut <krispcut@gmail.com>",
5
5
  "description": "Docker workspace for web projects",
6
6
  "license": "MIT",
7
7
  "main": "lib/index.js",
8
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
  },
@@ -24,11 +30,11 @@
24
30
  "watch": "tsc -w"
25
31
  },
26
32
  "dependencies": {
27
- "@wocker/core": "1.0.20",
33
+ "@wocker/core": "1.0.21",
28
34
  "@wocker/utils": "^1.0.7",
29
35
  "async-mutex": "^0.4.0",
30
36
  "axios": "^1.6.7",
31
- "chalk": "^2.4.2",
37
+ "chalk": "^4.1.2",
32
38
  "child_process": "^1.0.2",
33
39
  "cli-table3": "^0.6.2",
34
40
  "date-fns": "^2.29.3",
@@ -41,9 +47,8 @@
41
47
  "unzipper": "^0.12.3"
42
48
  },
43
49
  "devDependencies": {
44
- "@types/dockerode": "3.3.23",
50
+ "@types/dockerode": "^3.3.23",
45
51
  "@types/jest": "^29.5.12",
46
- "@types/lodash": "^4.14.161",
47
52
  "@types/md5": "^2.3.2",
48
53
  "@types/mute-stream": "^0.0.1",
49
54
  "@types/node": "^20.11.16",
@@ -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,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,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
- }