@wocker/ws 1.0.13 → 1.0.15
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.
- package/lib/AppModule.js +3 -2
- package/lib/controllers/PresetController.d.ts +2 -1
- package/lib/controllers/PresetController.js +31 -4
- package/lib/controllers/ProjectController.d.ts +12 -3
- package/lib/controllers/ProjectController.js +259 -51
- package/lib/controllers/ProxyController.d.ts +5 -12
- package/lib/controllers/ProxyController.js +25 -220
- package/lib/env.d.ts +1 -0
- package/lib/env.js +2 -1
- package/lib/plugins/index.d.ts +0 -1
- package/lib/plugins/index.js +0 -1
- package/lib/services/DockerService.d.ts +1 -1
- package/lib/services/DockerService.js +20 -15
- package/lib/services/PluginService.js +1 -1
- package/lib/services/PresetService.d.ts +7 -3
- package/lib/services/PresetService.js +158 -21
- package/lib/services/ProjectService.d.ts +4 -6
- package/lib/services/ProjectService.js +34 -45
- package/lib/services/ProxyService.d.ts +14 -0
- package/lib/services/ProxyService.js +87 -0
- package/lib/services/index.d.ts +1 -0
- package/lib/services/index.js +1 -0
- package/package.json +5 -3
- package/presets/bun/config.json +1 -0
- package/presets/go/config.json +1 -0
- package/presets/php-fpm/config.json +1 -0
- package/presets/shopify/config.json +2 -0
- package/lib/plugins/PageKitePlugin.d.ts +0 -30
- package/lib/plugins/PageKitePlugin.js +0 -145
- package/plugins/pagekite/Dockerfile +0 -3
- package/presets/node/Dockerfile +0 -39
- package/presets/node/config.json +0 -39
- package/presets/php-apache/Dockerfile +0 -227
- package/presets/php-apache/bin/compare-version +0 -3
- package/presets/php-apache/config.json +0 -64
- package/presets/php-apache/etc/apache2/apache2.conf +0 -230
- package/presets/php-apache/etc/apache2/mods-available/mpm_prefork.conf +0 -16
- package/presets/php-apache/etc/apache2/sites-available/000-default.conf +0 -21
|
@@ -1,10 +1,33 @@
|
|
|
1
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
|
+
});
|
|
2
18
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
19
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
20
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
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;
|
|
6
22
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
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
|
+
};
|
|
8
31
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
32
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
33
|
};
|
|
@@ -15,10 +38,64 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
38
|
exports.PresetService = void 0;
|
|
16
39
|
const core_1 = require("@wocker/core");
|
|
17
40
|
const md5_1 = __importDefault(require("md5"));
|
|
41
|
+
const axios_1 = __importDefault(require("axios"));
|
|
42
|
+
const unzipper_1 = require("unzipper");
|
|
43
|
+
const Path = __importStar(require("path"));
|
|
18
44
|
const env_1 = require("../env");
|
|
19
45
|
const makes_1 = require("../makes");
|
|
20
46
|
let PresetService = class PresetService {
|
|
21
|
-
constructor() {
|
|
47
|
+
constructor(appConfigService) {
|
|
48
|
+
this.appConfigService = appConfigService;
|
|
49
|
+
}
|
|
50
|
+
toObject(config) {
|
|
51
|
+
const _this = this;
|
|
52
|
+
return new class extends core_1.Preset {
|
|
53
|
+
constructor(data) {
|
|
54
|
+
super(data);
|
|
55
|
+
}
|
|
56
|
+
async save() {
|
|
57
|
+
const { source, path, ...rest } = this.toJSON();
|
|
58
|
+
const config = await _this.appConfigService.getConfig();
|
|
59
|
+
let presetData = config.presets.find((presetData) => {
|
|
60
|
+
return presetData.name === this.name;
|
|
61
|
+
});
|
|
62
|
+
if (!makes_1.FS.existsSync(_this.appConfigService.dataPath("presets", this.name))) {
|
|
63
|
+
makes_1.FS.mkdirSync(_this.appConfigService.dataPath("presets", this.name), {
|
|
64
|
+
recursive: true
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
await makes_1.FS.writeJSON(_this.appConfigService.dataPath("presets", this.name, "config.json"), rest);
|
|
68
|
+
if (!presetData) {
|
|
69
|
+
config.registerPreset(this.name, source);
|
|
70
|
+
await config.save();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
async delete() {
|
|
74
|
+
if (this.source === core_1.PRESET_SOURCE_GITHUB) {
|
|
75
|
+
const config = await _this.appConfigService.getConfig();
|
|
76
|
+
await makes_1.FS.rm(_this.appConfigService.dataPath("presets", this.name), {
|
|
77
|
+
recursive: true
|
|
78
|
+
});
|
|
79
|
+
config.unregisterPreset(this.name);
|
|
80
|
+
await config.save();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}(config);
|
|
84
|
+
}
|
|
85
|
+
async getList() {
|
|
86
|
+
const dirs = await makes_1.FS.readdir(env_1.PRESETS_DIR);
|
|
87
|
+
const { presets } = await this.appConfigService.getConfig();
|
|
88
|
+
return [
|
|
89
|
+
...dirs.map((name) => {
|
|
90
|
+
return {
|
|
91
|
+
name,
|
|
92
|
+
source: core_1.PRESET_SOURCE_INTERNAL,
|
|
93
|
+
path: Path.join(env_1.PRESETS_DIR, name)
|
|
94
|
+
};
|
|
95
|
+
}),
|
|
96
|
+
...presets
|
|
97
|
+
];
|
|
98
|
+
}
|
|
22
99
|
getImageName(preset, buildArgs = {}) {
|
|
23
100
|
const rawValues = [];
|
|
24
101
|
const hashValues = [];
|
|
@@ -34,38 +111,98 @@ let PresetService = class PresetService {
|
|
|
34
111
|
});
|
|
35
112
|
const version = [
|
|
36
113
|
...rawValues,
|
|
37
|
-
(0, md5_1.default)(hashValues.join(",")).
|
|
114
|
+
(0, md5_1.default)(hashValues.join(",")).substring(0, 6)
|
|
38
115
|
].filter((value) => {
|
|
39
116
|
return !!value;
|
|
40
117
|
}).join("-");
|
|
41
118
|
return `ws-preset-${preset.name}:${version}`;
|
|
42
119
|
}
|
|
43
|
-
async save(preset) {
|
|
44
|
-
}
|
|
45
120
|
async get(name) {
|
|
46
|
-
const
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
121
|
+
const list = await this.getList();
|
|
122
|
+
const item = list.find((item) => {
|
|
123
|
+
return item.name === name;
|
|
124
|
+
});
|
|
125
|
+
if (!item) {
|
|
126
|
+
throw new Error(`Preset ${name} not found`);
|
|
127
|
+
}
|
|
128
|
+
if (item.source === core_1.PRESET_SOURCE_GITHUB) {
|
|
129
|
+
item.path = this.appConfigService.dataPath("presets", item.name);
|
|
130
|
+
}
|
|
131
|
+
else if (item.source === core_1.PRESET_SOURCE_INTERNAL) {
|
|
132
|
+
item.path = Path.join(env_1.PRESETS_DIR, item.name);
|
|
133
|
+
}
|
|
134
|
+
const config = await makes_1.FS.readJSON(item.path, "config.json");
|
|
135
|
+
return this.toObject({
|
|
136
|
+
...item,
|
|
56
137
|
...config
|
|
57
138
|
});
|
|
58
139
|
}
|
|
140
|
+
async addPreset(name) {
|
|
141
|
+
let preset = await this.searchOne({
|
|
142
|
+
name
|
|
143
|
+
});
|
|
144
|
+
if (!preset) {
|
|
145
|
+
console.info("Loading...");
|
|
146
|
+
const res = await makes_1.Http.get("https://raw.githubusercontent.com")
|
|
147
|
+
.withHeader("User-Agent", "Wocker")
|
|
148
|
+
.send(`/kearisp/wocker-${name}-preset/master/config.json`);
|
|
149
|
+
preset = this.toObject(res.data);
|
|
150
|
+
preset.source = core_1.PRESET_SOURCE_GITHUB;
|
|
151
|
+
preset.path = this.appConfigService.dataPath("presets", preset.name);
|
|
152
|
+
const zipRes = await axios_1.default.create({
|
|
153
|
+
baseURL: "https://github.com",
|
|
154
|
+
headers: {
|
|
155
|
+
"User-Agent": "Wocker"
|
|
156
|
+
}
|
|
157
|
+
}).get(`/kearisp/wocker-${preset.name}-preset/archive/refs/heads/master.zip`, {
|
|
158
|
+
responseType: "stream"
|
|
159
|
+
});
|
|
160
|
+
makes_1.FS.mkdirSync(preset.path, {
|
|
161
|
+
recursive: true
|
|
162
|
+
});
|
|
163
|
+
zipRes.data.pipe((0, unzipper_1.Parse)()).on("entry", (entry) => {
|
|
164
|
+
const path = entry.path.replace(/^[^\/]+\//, "");
|
|
165
|
+
if (path === "config.json") {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
const fullPath = this.appConfigService.dataPath("presets", preset.name, path);
|
|
169
|
+
if (entry.type === "File") {
|
|
170
|
+
entry.pipe(makes_1.FS.createWriteStream(fullPath));
|
|
171
|
+
}
|
|
172
|
+
else if (entry.type === "Directory") {
|
|
173
|
+
makes_1.FS.mkdirSync(fullPath, {
|
|
174
|
+
recursive: true
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
await preset.save();
|
|
179
|
+
}
|
|
180
|
+
console.log(preset.version);
|
|
181
|
+
}
|
|
59
182
|
async search(options = {}) {
|
|
60
|
-
const { name } = options;
|
|
183
|
+
const { name, source } = options;
|
|
61
184
|
const presets = [];
|
|
62
|
-
const
|
|
63
|
-
for (const
|
|
64
|
-
if (name && name !==
|
|
185
|
+
const presetConfigs = await this.getList();
|
|
186
|
+
for (const presetConfig of presetConfigs) {
|
|
187
|
+
if (name && name !== presetConfig.name) {
|
|
65
188
|
continue;
|
|
66
189
|
}
|
|
67
|
-
|
|
68
|
-
|
|
190
|
+
if (source && source !== presetConfig.source) {
|
|
191
|
+
continue;
|
|
192
|
+
}
|
|
193
|
+
try {
|
|
194
|
+
const fullConfig = await makes_1.FS.readJSON(presetConfig.path, "config.json");
|
|
195
|
+
if (!fullConfig.name) {
|
|
196
|
+
console.log(presetConfig.name);
|
|
197
|
+
}
|
|
198
|
+
const preset = this.toObject({
|
|
199
|
+
...presetConfig,
|
|
200
|
+
...fullConfig
|
|
201
|
+
});
|
|
202
|
+
presets.push(preset);
|
|
203
|
+
}
|
|
204
|
+
catch (err) {
|
|
205
|
+
}
|
|
69
206
|
}
|
|
70
207
|
return presets;
|
|
71
208
|
}
|
|
@@ -77,5 +214,5 @@ let PresetService = class PresetService {
|
|
|
77
214
|
exports.PresetService = PresetService;
|
|
78
215
|
exports.PresetService = PresetService = __decorate([
|
|
79
216
|
(0, core_1.Injectable)(),
|
|
80
|
-
__metadata("design:paramtypes", [])
|
|
217
|
+
__metadata("design:paramtypes", [core_1.AppConfigService])
|
|
81
218
|
], PresetService);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Project,
|
|
1
|
+
import { Project, ProjectProperties } from "@wocker/core";
|
|
2
2
|
import { DockerService, AppConfigService, AppEventsService } from "../services";
|
|
3
3
|
type SearchParams = Partial<{
|
|
4
4
|
id: string;
|
|
@@ -10,13 +10,11 @@ declare class ProjectService {
|
|
|
10
10
|
protected readonly appEventsService: AppEventsService;
|
|
11
11
|
protected readonly dockerService: DockerService;
|
|
12
12
|
constructor(appConfigService: AppConfigService, appEventsService: AppEventsService, dockerService: DockerService);
|
|
13
|
-
fromObject(data: Partial<
|
|
13
|
+
fromObject(data: Partial<ProjectProperties>): Project;
|
|
14
|
+
get(): Promise<Project>;
|
|
14
15
|
getById(id: string): Promise<Project>;
|
|
15
16
|
cdProject(name: string): Promise<void>;
|
|
16
|
-
|
|
17
|
-
getContainer(): Promise<import("dockerode").Container>;
|
|
18
|
-
rebuild(project: Project): Promise<void>;
|
|
19
|
-
start(project: Project, restart?: boolean): Promise<void>;
|
|
17
|
+
start(project: Project, restart?: boolean, rebuild?: boolean): Promise<void>;
|
|
20
18
|
stop(project: Project): Promise<void>;
|
|
21
19
|
save(project: Project): Promise<void>;
|
|
22
20
|
search(params?: Partial<SearchParams>): Promise<Project[]>;
|
|
@@ -44,16 +44,25 @@ let ProjectService = class ProjectService {
|
|
|
44
44
|
this.dockerService = dockerService;
|
|
45
45
|
}
|
|
46
46
|
fromObject(data) {
|
|
47
|
-
const
|
|
47
|
+
const _this = this;
|
|
48
48
|
return new class extends core_1.Project {
|
|
49
49
|
constructor(data) {
|
|
50
50
|
super(data);
|
|
51
51
|
}
|
|
52
52
|
async save() {
|
|
53
|
-
await
|
|
53
|
+
await _this.save(this);
|
|
54
54
|
}
|
|
55
55
|
}(data);
|
|
56
56
|
}
|
|
57
|
+
async get() {
|
|
58
|
+
const project = await this.searchOne({
|
|
59
|
+
path: this.appConfigService.getPWD()
|
|
60
|
+
});
|
|
61
|
+
if (!project) {
|
|
62
|
+
throw new Error("Project not found");
|
|
63
|
+
}
|
|
64
|
+
return project;
|
|
65
|
+
}
|
|
57
66
|
async getById(id) {
|
|
58
67
|
const data = await makes_1.FS.readJSON(this.appConfigService.dataPath("projects", id, "config.json"));
|
|
59
68
|
return this.fromObject(data);
|
|
@@ -67,55 +76,35 @@ let ProjectService = class ProjectService {
|
|
|
67
76
|
}
|
|
68
77
|
this.appConfigService.setPWD(project.path);
|
|
69
78
|
}
|
|
70
|
-
async
|
|
71
|
-
const project = await this.searchOne({
|
|
72
|
-
path: this.appConfigService.getPWD()
|
|
73
|
-
});
|
|
74
|
-
if (!project) {
|
|
75
|
-
throw new Error("Project not found");
|
|
76
|
-
}
|
|
77
|
-
return project;
|
|
78
|
-
}
|
|
79
|
-
async getContainer() {
|
|
80
|
-
const project = await this.get();
|
|
81
|
-
return this.dockerService.getContainer(project.containerName);
|
|
82
|
-
}
|
|
83
|
-
async rebuild(project) {
|
|
84
|
-
await this.stop(project);
|
|
85
|
-
if (project.type === "dockerfile") {
|
|
86
|
-
project.imageName = `project-${project.name}:develop`;
|
|
87
|
-
const images = await this.dockerService.imageLs({
|
|
88
|
-
tag: project.imageName
|
|
89
|
-
});
|
|
90
|
-
if (images.length > 0) {
|
|
91
|
-
await this.dockerService.imageRm(project.imageName);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
await this.appEventsService.emit("project:rebuild", project);
|
|
95
|
-
}
|
|
96
|
-
async start(project, restart) {
|
|
97
|
-
if (project.type === "dockerfile") {
|
|
98
|
-
project.imageName = `project-${project.name}:develop`;
|
|
99
|
-
const images = await this.dockerService.imageLs({
|
|
100
|
-
tag: project.imageName
|
|
101
|
-
});
|
|
102
|
-
if (images.length === 0) {
|
|
103
|
-
await this.dockerService.buildImage({
|
|
104
|
-
tag: project.imageName,
|
|
105
|
-
buildArgs: project.buildArgs,
|
|
106
|
-
context: this.appConfigService.getPWD(),
|
|
107
|
-
src: project.dockerfile
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
await this.appEventsService.emit("project:beforeStart", project);
|
|
79
|
+
async start(project, restart, rebuild) {
|
|
112
80
|
let container = await this.dockerService.getContainer(project.containerName);
|
|
113
|
-
if (container && restart) {
|
|
81
|
+
if (container && (restart || rebuild)) {
|
|
114
82
|
container = null;
|
|
115
83
|
await this.appEventsService.emit("project:stop", project);
|
|
116
84
|
await this.dockerService.removeContainer(project.containerName);
|
|
117
85
|
}
|
|
118
86
|
if (!container) {
|
|
87
|
+
if (project.type === core_1.PROJECT_TYPE_DOCKERFILE) {
|
|
88
|
+
project.imageName = `project-${project.name}:develop`;
|
|
89
|
+
if (rebuild) {
|
|
90
|
+
await this.dockerService.imageRm(project.imageName);
|
|
91
|
+
}
|
|
92
|
+
const images = await this.dockerService.imageLs({
|
|
93
|
+
tag: project.imageName
|
|
94
|
+
});
|
|
95
|
+
if (images.length === 0) {
|
|
96
|
+
await this.dockerService.buildImage({
|
|
97
|
+
tag: project.imageName,
|
|
98
|
+
buildArgs: project.buildArgs,
|
|
99
|
+
context: this.appConfigService.getPWD(),
|
|
100
|
+
src: project.dockerfile
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
if (rebuild) {
|
|
105
|
+
await this.appEventsService.emit("project:rebuild", project);
|
|
106
|
+
}
|
|
107
|
+
await this.appEventsService.emit("project:beforeStart", project);
|
|
119
108
|
const config = await this.appConfigService.getConfig();
|
|
120
109
|
container = await this.dockerService.createContainer({
|
|
121
110
|
name: project.containerName,
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Project } from "@wocker/core";
|
|
2
|
+
import { AppConfigService } from "./AppConfigService";
|
|
3
|
+
import { DockerService } from "./DockerService";
|
|
4
|
+
export declare class ProxyService {
|
|
5
|
+
protected readonly appConfigService: AppConfigService;
|
|
6
|
+
protected readonly dockerService: DockerService;
|
|
7
|
+
protected containerName: string;
|
|
8
|
+
protected imageName: string;
|
|
9
|
+
constructor(appConfigService: AppConfigService, dockerService: DockerService);
|
|
10
|
+
init(project: Project): Promise<void>;
|
|
11
|
+
start(restart?: boolean): Promise<void>;
|
|
12
|
+
stop(): Promise<void>;
|
|
13
|
+
logs(): Promise<void>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
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.ProxyService = void 0;
|
|
13
|
+
const core_1 = require("@wocker/core");
|
|
14
|
+
const utils_1 = require("@wocker/utils");
|
|
15
|
+
const makes_1 = require("../makes");
|
|
16
|
+
const AppConfigService_1 = require("./AppConfigService");
|
|
17
|
+
const DockerService_1 = require("./DockerService");
|
|
18
|
+
let ProxyService = class ProxyService {
|
|
19
|
+
constructor(appConfigService, dockerService) {
|
|
20
|
+
this.appConfigService = appConfigService;
|
|
21
|
+
this.dockerService = dockerService;
|
|
22
|
+
this.containerName = "proxy.workspace";
|
|
23
|
+
this.imageName = "nginxproxy/nginx-proxy";
|
|
24
|
+
}
|
|
25
|
+
async init(project) {
|
|
26
|
+
const appPort = await (0, utils_1.promptText)({
|
|
27
|
+
message: "App port:",
|
|
28
|
+
type: "number",
|
|
29
|
+
default: project.getEnv("VIRTUAL_PORT", "80")
|
|
30
|
+
});
|
|
31
|
+
project.setEnv("VIRTUAL_PORT", appPort);
|
|
32
|
+
await project.save();
|
|
33
|
+
}
|
|
34
|
+
async start(restart) {
|
|
35
|
+
if (restart) {
|
|
36
|
+
await this.stop();
|
|
37
|
+
}
|
|
38
|
+
let container = await this.dockerService.getContainer(this.containerName);
|
|
39
|
+
if (!container) {
|
|
40
|
+
console.info("Proxy starting...");
|
|
41
|
+
await this.dockerService.pullImage(this.imageName);
|
|
42
|
+
const certsDir = this.appConfigService.dataPath("certs");
|
|
43
|
+
if (!makes_1.FS.existsSync(certsDir)) {
|
|
44
|
+
makes_1.FS.mkdirSync(certsDir, {
|
|
45
|
+
recursive: true,
|
|
46
|
+
mode: 0o700
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
const config = await this.appConfigService.getConfig();
|
|
50
|
+
const httpPort = config.getMeta("PROXY_HTTP_PORT", "80");
|
|
51
|
+
const httpsPort = config.getMeta("PROXY_HTTPS_PORT", "443");
|
|
52
|
+
container = await this.dockerService.createContainer({
|
|
53
|
+
name: this.containerName,
|
|
54
|
+
image: this.imageName,
|
|
55
|
+
restart: "always",
|
|
56
|
+
env: {
|
|
57
|
+
DEFAULT_HOST: "index.workspace"
|
|
58
|
+
},
|
|
59
|
+
ports: [
|
|
60
|
+
`${httpPort}:80`,
|
|
61
|
+
`${httpsPort}:443`
|
|
62
|
+
],
|
|
63
|
+
volumes: [
|
|
64
|
+
"/var/run/docker.sock:/tmp/docker.sock:ro",
|
|
65
|
+
`${certsDir}:/etc/nginx/certs`
|
|
66
|
+
]
|
|
67
|
+
});
|
|
68
|
+
const { State: { Status } } = await container.inspect();
|
|
69
|
+
if (["created", "exited"].includes(Status)) {
|
|
70
|
+
await container.start();
|
|
71
|
+
console.info("Started");
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
async stop() {
|
|
76
|
+
await this.dockerService.removeContainer(this.containerName);
|
|
77
|
+
}
|
|
78
|
+
async logs() {
|
|
79
|
+
await this.dockerService.logs(this.containerName);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
exports.ProxyService = ProxyService;
|
|
83
|
+
exports.ProxyService = ProxyService = __decorate([
|
|
84
|
+
(0, core_1.Injectable)("PROXY_SERVICE"),
|
|
85
|
+
__metadata("design:paramtypes", [AppConfigService_1.AppConfigService,
|
|
86
|
+
DockerService_1.DockerService])
|
|
87
|
+
], ProxyService);
|
package/lib/services/index.d.ts
CHANGED
package/lib/services/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wocker/ws",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.15",
|
|
4
4
|
"author": "Kris Papercut <krispcut@gmail.com>",
|
|
5
5
|
"description": "Docker workspace for web projects",
|
|
6
6
|
"license": "MIT",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"lint": "eslint \"**/*.{js,jsx,ts,tsx}\""
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@wocker/core": "^1.0.
|
|
28
|
+
"@wocker/core": "^1.0.14",
|
|
29
29
|
"@wocker/utils": "^1.0.5",
|
|
30
30
|
"async-mutex": "^0.4.0",
|
|
31
31
|
"axios": "^1.6.7",
|
|
@@ -38,7 +38,8 @@
|
|
|
38
38
|
"md5": "^2.3.0",
|
|
39
39
|
"os": "^0.1.2",
|
|
40
40
|
"path": "^0.12.7",
|
|
41
|
-
"readable-stream": "^4.1.0"
|
|
41
|
+
"readable-stream": "^4.1.0",
|
|
42
|
+
"unzipper": "^0.12.3"
|
|
42
43
|
},
|
|
43
44
|
"devDependencies": {
|
|
44
45
|
"@types/dockerode": "3.3.23",
|
|
@@ -48,6 +49,7 @@
|
|
|
48
49
|
"@types/mute-stream": "^0.0.1",
|
|
49
50
|
"@types/node": "^20.11.16",
|
|
50
51
|
"@types/readable-stream": "^2.3.15",
|
|
52
|
+
"@types/unzipper": "^0.10.10",
|
|
51
53
|
"@typescript-eslint/eslint-plugin": "^6.5.0",
|
|
52
54
|
"@typescript-eslint/parser": "^6.5.0",
|
|
53
55
|
"eslint": "^8.48.0",
|
package/presets/bun/config.json
CHANGED
package/presets/go/config.json
CHANGED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { Project } from "@wocker/core";
|
|
2
|
-
import { AppConfigService, AppEventsService, ProjectService, DockerService } from "../services";
|
|
3
|
-
type InitOptions = {};
|
|
4
|
-
type StartOptions = {
|
|
5
|
-
name?: string;
|
|
6
|
-
detach?: boolean;
|
|
7
|
-
restart?: boolean;
|
|
8
|
-
rebuild?: boolean;
|
|
9
|
-
};
|
|
10
|
-
type StopOptions = {
|
|
11
|
-
name?: string;
|
|
12
|
-
};
|
|
13
|
-
type BuildOptions = {
|
|
14
|
-
rebuild?: boolean;
|
|
15
|
-
};
|
|
16
|
-
export declare class PageKitePlugin {
|
|
17
|
-
protected readonly appConfigService: AppConfigService;
|
|
18
|
-
protected readonly appEventsService: AppEventsService;
|
|
19
|
-
protected readonly projectService: ProjectService;
|
|
20
|
-
protected readonly dockerService: DockerService;
|
|
21
|
-
constructor(appConfigService: AppConfigService, appEventsService: AppEventsService, projectService: ProjectService, dockerService: DockerService);
|
|
22
|
-
pluginPath(...parts: string[]): string;
|
|
23
|
-
onProjectStart(project: Project): Promise<void>;
|
|
24
|
-
onProjectStop(project: Project): Promise<void>;
|
|
25
|
-
init(options: InitOptions): Promise<void>;
|
|
26
|
-
start(options: StartOptions): Promise<void>;
|
|
27
|
-
stop(options: StopOptions): Promise<void>;
|
|
28
|
-
build(options?: BuildOptions): Promise<void>;
|
|
29
|
-
}
|
|
30
|
-
export {};
|