@wocker/ws 1.0.31-beta.0 → 1.0.32-beta.0

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.
@@ -284,6 +284,7 @@ let ProjectController = class ProjectController {
284
284
  project.addDomain(domain);
285
285
  }
286
286
  project.save();
287
+ await this.eventService.emit("project:add-domain", project, addDomains);
287
288
  }
288
289
  async setDomains(domains, name) {
289
290
  const project = this.projectService.get(name);
@@ -1,10 +1,13 @@
1
- import { AppConfigService, AppFileSystemService, Project, ProjectRepository as CoreProjectRepository, ProjectRepositorySearchParams as SearchParams } from "@wocker/core";
1
+ import { AppConfigService, AppFileSystemService, Project, ProjectRepository as CoreProjectRepository } from "@wocker/core";
2
2
  export declare class ProjectRepository extends CoreProjectRepository {
3
3
  protected readonly appConfigService: AppConfigService;
4
4
  protected readonly fs: AppFileSystemService;
5
5
  constructor(appConfigService: AppConfigService, fs: AppFileSystemService);
6
6
  getByName(name: string): Project;
7
7
  save(project: Project): void;
8
- search(params?: SearchParams): Project[];
9
- searchOne(params?: SearchParams): Project | null;
8
+ search(params?: ProjectRepository.SearchParams): Project[];
9
+ searchOne(params?: ProjectRepository.SearchParams): Project | null;
10
+ }
11
+ export declare namespace ProjectRepository {
12
+ type SearchParams = CoreProjectRepository.SearchParams;
10
13
  }
@@ -1,4 +1,4 @@
1
- import { AppConfigService, EventService, LogService, ProcessService, Project, ProjectService as CoreProjectService, ProjectRepositorySearchParams as SearchParams } from "@wocker/core";
1
+ import { AppConfigService, EventService, LogService, ProcessService, Project, ProjectService as CoreProjectService } from "@wocker/core";
2
2
  import { ComposeService, DockerService } from "@wocker/docker-module";
3
3
  import { PresetRepository, PresetService } from "../../preset";
4
4
  import { ProjectRepository } from "../repositories/ProjectRepository";
@@ -14,8 +14,8 @@ export declare class ProjectService extends CoreProjectService {
14
14
  protected readonly logService: LogService;
15
15
  constructor(appConfigService: AppConfigService, processService: ProcessService, eventService: EventService, dockerService: DockerService, composeService: ComposeService, projectRepository: ProjectRepository, presetService: PresetService, presetRepository: PresetRepository, logService: LogService);
16
16
  get(name?: string): Project;
17
- search(params?: SearchParams): Project[];
18
- searchOne(params?: SearchParams): Project | null;
17
+ search(params?: ProjectRepository.SearchParams): Project[];
18
+ searchOne(params?: ProjectRepository.SearchParams): Project | null;
19
19
  save(project: Project): void;
20
20
  start(project: Project, restart?: boolean, rebuild?: boolean, attach?: boolean): Promise<void>;
21
21
  stop(project: Project): Promise<void>;
@@ -48,12 +48,14 @@ let CertController = class CertController {
48
48
  exports.CertController = CertController;
49
49
  __decorate([
50
50
  (0, core_1.Command)("certs"),
51
+ (0, core_1.Description)("Show certs"),
51
52
  __metadata("design:type", Function),
52
53
  __metadata("design:paramtypes", []),
53
54
  __metadata("design:returntype", Promise)
54
55
  ], CertController.prototype, "list", null);
55
56
  __decorate([
56
57
  (0, core_1.Command)("cert:generate [cert]"),
58
+ (0, core_1.Description)("Generate cert"),
57
59
  __param(0, (0, core_1.Param)("cert")),
58
60
  __param(1, (0, core_1.Option)("dns", {
59
61
  type: "string",
@@ -66,6 +68,7 @@ __decorate([
66
68
  ], CertController.prototype, "createCert", null);
67
69
  __decorate([
68
70
  (0, core_1.Command)("cert:use [cert]"),
71
+ (0, core_1.Description)("Use cert"),
69
72
  __param(0, (0, core_1.Param)("cert")),
70
73
  __param(1, (0, core_1.Option)("name", {
71
74
  type: "string",
@@ -78,6 +81,7 @@ __decorate([
78
81
  ], CertController.prototype, "use", null);
79
82
  __decorate([
80
83
  (0, core_1.Command)("cert:remove"),
84
+ (0, core_1.Description)("Remove cert"),
81
85
  __param(0, (0, core_1.Option)("name", {
82
86
  type: "string",
83
87
  alias: "n",
@@ -89,6 +93,7 @@ __decorate([
89
93
  ], CertController.prototype, "remove", null);
90
94
  __decorate([
91
95
  (0, core_1.Command)("cert:delete <cert>"),
96
+ (0, core_1.Description)("Delete cert"),
92
97
  __param(0, (0, core_1.Param)("cert")),
93
98
  __metadata("design:type", Function),
94
99
  __metadata("design:paramtypes", [String]),
@@ -109,6 +114,7 @@ __decorate([
109
114
  ], CertController.prototype, "existsOtherNames", null);
110
115
  exports.CertController = CertController = __decorate([
111
116
  (0, core_1.Controller)(),
117
+ (0, core_1.Description)("Cert commands"),
112
118
  __metadata("design:paramtypes", [project_1.ProjectService,
113
119
  CertService_1.CertService])
114
120
  ], CertController);
@@ -0,0 +1,16 @@
1
+ import { Project } from "@wocker/core";
2
+ import { ProjectService } from "../../project";
3
+ import { HttpAuthService } from "../services/HttpAuthService";
4
+ import { ProxyService } from "../services/ProxyService";
5
+ export declare class HttpAuthController {
6
+ protected readonly projectService: ProjectService;
7
+ protected readonly httpAuthService: HttpAuthService;
8
+ protected readonly proxyService: ProxyService;
9
+ constructor(projectService: ProjectService, httpAuthService: HttpAuthService, proxyService: ProxyService);
10
+ onAddDomain(project: Project, ...domains: string[]): Promise<void>;
11
+ enable(domain?: string): Promise<void>;
12
+ disable(domain?: string): Promise<void>;
13
+ add(user?: string, password?: string, global?: boolean, algorithm?: HttpAuthService.Algorithm): Promise<void>;
14
+ remove(user?: string): Promise<void>;
15
+ clear(): Promise<void>;
16
+ }
@@ -0,0 +1,125 @@
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 __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.HttpAuthController = void 0;
16
+ const core_1 = require("@wocker/core");
17
+ const utils_1 = require("@wocker/utils");
18
+ const project_1 = require("../../project");
19
+ const HttpAuthService_1 = require("../services/HttpAuthService");
20
+ const ProxyService_1 = require("../services/ProxyService");
21
+ let HttpAuthController = class HttpAuthController {
22
+ constructor(projectService, httpAuthService, proxyService) {
23
+ this.projectService = projectService;
24
+ this.httpAuthService = httpAuthService;
25
+ this.proxyService = proxyService;
26
+ }
27
+ async onAddDomain(project, ...domains) {
28
+ console.log("New domains:", domains);
29
+ }
30
+ async enable(domain) {
31
+ await this.httpAuthService.enableForProject(this.projectService.get(), domain);
32
+ await this.proxyService.start(true);
33
+ }
34
+ async disable(domain) {
35
+ await this.httpAuthService.disableForProject(this.projectService.get(), domain);
36
+ await this.proxyService.start(true);
37
+ }
38
+ async add(user, password, global, algorithm) {
39
+ if (!user) {
40
+ user = await (0, utils_1.promptInput)({
41
+ required: true,
42
+ message: "User",
43
+ type: "text"
44
+ });
45
+ }
46
+ if (!password) {
47
+ password = await (0, utils_1.promptInput)({
48
+ required: true,
49
+ message: "Password",
50
+ type: "password"
51
+ });
52
+ }
53
+ if (global) {
54
+ await this.httpAuthService.addForGlobal(user, password, algorithm);
55
+ }
56
+ else {
57
+ await this.httpAuthService.addForProject(this.projectService.get(), user, password, algorithm);
58
+ }
59
+ await this.proxyService.start(true);
60
+ }
61
+ async remove(user) {
62
+ await this.httpAuthService.removeForProject(this.projectService.get(), user);
63
+ }
64
+ async clear() {
65
+ }
66
+ };
67
+ exports.HttpAuthController = HttpAuthController;
68
+ __decorate([
69
+ (0, core_1.Event)("project:add-domain"),
70
+ __metadata("design:type", Function),
71
+ __metadata("design:paramtypes", [core_1.Project, String]),
72
+ __metadata("design:returntype", Promise)
73
+ ], HttpAuthController.prototype, "onAddDomain", null);
74
+ __decorate([
75
+ (0, core_1.Command)("http-auth:enable"),
76
+ __param(0, (0, core_1.Option)("domain", "d")),
77
+ __param(0, (0, core_1.Description)("Domain to apply authentication to.")),
78
+ __metadata("design:type", Function),
79
+ __metadata("design:paramtypes", [String]),
80
+ __metadata("design:returntype", Promise)
81
+ ], HttpAuthController.prototype, "enable", null);
82
+ __decorate([
83
+ (0, core_1.Command)("http-auth:disable"),
84
+ __param(0, (0, core_1.Option)("domain", "d")),
85
+ __metadata("design:type", Function),
86
+ __metadata("design:paramtypes", [String]),
87
+ __metadata("design:returntype", Promise)
88
+ ], HttpAuthController.prototype, "disable", null);
89
+ __decorate([
90
+ (0, core_1.Command)("http-auth:add-user"),
91
+ (0, core_1.Command)("http-auth:add-user [user]"),
92
+ (0, core_1.Command)("http-auth:add-user [user]:[password]"),
93
+ (0, core_1.Description)("Add a user for HTTP Basic Auth"),
94
+ __param(0, (0, core_1.Param)("user")),
95
+ __param(0, (0, core_1.Description)("Username for Basic Auth. If omitted, you will be prompted.")),
96
+ __param(1, (0, core_1.Param)("password")),
97
+ __param(1, (0, core_1.Description)("Password for Basic Auth. If omitted, you will be prompted.")),
98
+ __param(2, (0, core_1.Option)("global", "g")),
99
+ __param(2, (0, core_1.Description)("")),
100
+ __param(3, (0, core_1.Option)("algorithm", "a")),
101
+ __param(3, (0, core_1.Description)("Password hashing algorithm (e.g. md5, bcrypt, sha1, sha256, sha512).")),
102
+ __metadata("design:type", Function),
103
+ __metadata("design:paramtypes", [String, String, Boolean, String]),
104
+ __metadata("design:returntype", Promise)
105
+ ], HttpAuthController.prototype, "add", null);
106
+ __decorate([
107
+ (0, core_1.Command)("http-auth:remove [user]"),
108
+ __param(0, (0, core_1.Param)("user")),
109
+ __metadata("design:type", Function),
110
+ __metadata("design:paramtypes", [String]),
111
+ __metadata("design:returntype", Promise)
112
+ ], HttpAuthController.prototype, "remove", null);
113
+ __decorate([
114
+ (0, core_1.Command)("http-auth:clear"),
115
+ __metadata("design:type", Function),
116
+ __metadata("design:paramtypes", []),
117
+ __metadata("design:returntype", Promise)
118
+ ], HttpAuthController.prototype, "clear", null);
119
+ exports.HttpAuthController = HttpAuthController = __decorate([
120
+ (0, core_1.Controller)(),
121
+ (0, core_1.Description)("BasicAuth commands"),
122
+ __metadata("design:paramtypes", [project_1.ProjectService,
123
+ HttpAuthService_1.HttpAuthService,
124
+ ProxyService_1.ProxyService])
125
+ ], HttpAuthController);
@@ -13,8 +13,10 @@ exports.CertService = exports.ProxyService = exports.ProxyModule = void 0;
13
13
  const core_1 = require("@wocker/core");
14
14
  const docker_module_1 = __importDefault(require("@wocker/docker-module"));
15
15
  const project_1 = require("../project");
16
+ const HttpAuthController_1 = require("./controllers/HttpAuthController");
16
17
  const CertController_1 = require("./controllers/CertController");
17
18
  const ProxyController_1 = require("./controllers/ProxyController");
19
+ const HttpAuthService_1 = require("./services/HttpAuthService");
18
20
  const CertService_1 = require("./services/CertService");
19
21
  Object.defineProperty(exports, "CertService", { enumerable: true, get: function () { return CertService_1.CertService; } });
20
22
  const ProxyService_1 = require("./services/ProxyService");
@@ -29,10 +31,12 @@ exports.ProxyModule = ProxyModule = __decorate([
29
31
  project_1.ProjectModule
30
32
  ],
31
33
  controllers: [
34
+ HttpAuthController_1.HttpAuthController,
32
35
  CertController_1.CertController,
33
36
  ProxyController_1.ProxyController
34
37
  ],
35
38
  providers: [
39
+ HttpAuthService_1.HttpAuthService,
36
40
  ProxyService_1.ProxyService,
37
41
  CertService_1.CertService
38
42
  ],
@@ -1,9 +1,6 @@
1
1
  import { Project, AppFileSystemService } from "@wocker/core";
2
2
  import { DockerService } from "@wocker/docker-module";
3
3
  import { ProxyService } from "./ProxyService";
4
- type CertMap = {
5
- [name: string]: string[];
6
- };
7
4
  export declare class CertService {
8
5
  protected readonly fs: AppFileSystemService;
9
6
  protected readonly proxyService: ProxyService;
@@ -11,9 +8,13 @@ export declare class CertService {
11
8
  constructor(fs: AppFileSystemService, proxyService: ProxyService, dockerService: DockerService);
12
9
  list(): Promise<string>;
13
10
  generate(certName: string, dns: string[]): Promise<void>;
14
- getCertsMap(): CertMap;
11
+ getCertsMap(): CertService.CertMap;
15
12
  use(project: Project, name: string): Promise<void>;
16
13
  remove(project: Project): Promise<void>;
17
14
  delete(name: string): Promise<void>;
18
15
  }
19
- export {};
16
+ export declare namespace CertService {
17
+ type CertMap = {
18
+ [name: string]: string[];
19
+ };
20
+ }
@@ -96,8 +96,7 @@ let CertService = class CertService {
96
96
  getCertsMap() {
97
97
  const files = this.fs.readdir("certs/projects");
98
98
  return files.reduce((res, file) => {
99
- const ext = Path.extname(file);
100
- const name = Path.basename(file, ext);
99
+ const ext = Path.extname(file), name = Path.basename(file, ext);
101
100
  if (!res[name]) {
102
101
  res[name] = [];
103
102
  }
@@ -0,0 +1,20 @@
1
+ import { AppFileSystemService, Project, ProcessService } from "@wocker/core";
2
+ import { DockerService } from "@wocker/docker-module";
3
+ import { ProxyService } from "./ProxyService";
4
+ export declare class HttpAuthService {
5
+ protected readonly processService: ProcessService;
6
+ protected readonly fs: AppFileSystemService;
7
+ protected readonly dockerService: DockerService;
8
+ protected readonly proxyService: ProxyService;
9
+ constructor(processService: ProcessService, fs: AppFileSystemService, dockerService: DockerService, proxyService: ProxyService);
10
+ add(path: string, user: string, password: string, algorithm?: HttpAuthService.Algorithm): Promise<void>;
11
+ addForProject(project: Project, user: string, password: string, algorithm?: HttpAuthService.Algorithm): Promise<void>;
12
+ addForGlobal(user: string, password: string, algorithm?: HttpAuthService.Algorithm): Promise<void>;
13
+ removeUser(path: string, user: string): Promise<void>;
14
+ removeForProject(project: Project, user: string): Promise<void>;
15
+ enableForProject(project: Project, domain?: string): Promise<void>;
16
+ disableForProject(project: Project, domain?: string): Promise<void>;
17
+ }
18
+ export declare namespace HttpAuthService {
19
+ type Algorithm = "md5" | "sha1" | "sha256" | "sha512" | "bcrypt";
20
+ }
@@ -0,0 +1,118 @@
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.HttpAuthService = void 0;
13
+ const core_1 = require("@wocker/core");
14
+ const docker_module_1 = require("@wocker/docker-module");
15
+ const utils_1 = require("@wocker/utils");
16
+ const ProxyService_1 = require("./ProxyService");
17
+ let HttpAuthService = class HttpAuthService {
18
+ constructor(processService, fs, dockerService, proxyService) {
19
+ this.processService = processService;
20
+ this.fs = fs;
21
+ this.dockerService = dockerService;
22
+ this.proxyService = proxyService;
23
+ }
24
+ async add(path, user, password, algorithm = "md5") {
25
+ const alMap = {
26
+ md5: "-m",
27
+ sha1: "-s",
28
+ sha256: "-2",
29
+ sha512: "-5",
30
+ bcrypt: "-B",
31
+ };
32
+ if (!(algorithm in alMap)) {
33
+ throw new Error(`Unsupported "${algorithm}" algorithm`);
34
+ }
35
+ if (!this.fs.exists(path)) {
36
+ this.fs.writeFile(path, "", {
37
+ mode: 0o640
38
+ });
39
+ }
40
+ const stream = await this.dockerService.exec("wocker-proxy", {
41
+ user: "nginx",
42
+ cmd: ["htpasswd", "-b", alMap[algorithm], `/etc/${path}`, user, password]
43
+ });
44
+ await new Promise((resolve, reject) => {
45
+ stream.on("data", (chunk) => {
46
+ this.processService.stdout.write((0, utils_1.demuxOutput)(chunk));
47
+ });
48
+ stream.on("end", resolve);
49
+ stream.on("error", reject);
50
+ });
51
+ }
52
+ async addForProject(project, user, password, algorithm = "md5") {
53
+ if (!this.fs.exists("nginx/htpasswd/projects")) {
54
+ this.fs.mkdir("nginx/htpasswd/projects", {
55
+ mode: 0o764
56
+ });
57
+ }
58
+ await this.add(`nginx/htpasswd/projects/${project.name}`, user, password, algorithm);
59
+ }
60
+ async addForGlobal(user, password, algorithm = "md5") {
61
+ return this.add(`nginx/htpasswd/_global`, user, password, algorithm);
62
+ }
63
+ async removeUser(path, user) {
64
+ }
65
+ async removeForProject(project, user) {
66
+ if (!this.fs.exists("nginx/htpasswd/projects")) {
67
+ return;
68
+ }
69
+ await this.removeUser(`nginx/htpasswd/projects/${project.name}`, user);
70
+ }
71
+ async enableForProject(project, domain) {
72
+ if (!this.fs.exists(`nginx/htpasswd/projects/${project.name}`)) {
73
+ throw new Error(`No htpasswd for ${project.name}`);
74
+ }
75
+ if (!domain) {
76
+ for (const d of project.domains) {
77
+ await this.enableForProject(project, d);
78
+ }
79
+ return;
80
+ }
81
+ if (!project.domains.includes(domain)) {
82
+ throw new Error("Domain not related to project");
83
+ }
84
+ const filePath = `nginx/htpasswd/${domain}`;
85
+ if (this.fs.exists(filePath)) {
86
+ return;
87
+ }
88
+ this.fs.symlink(`nginx/htpasswd/projects/${project.name}`, filePath, "file");
89
+ }
90
+ async disableForProject(project, domain) {
91
+ if (!domain) {
92
+ for (const d of project.domains) {
93
+ await this.disableForProject(project, d);
94
+ }
95
+ return;
96
+ }
97
+ const filePath = `nginx/htpasswd/${domain}`;
98
+ if (!this.fs.exists(filePath)) {
99
+ return;
100
+ }
101
+ const stat = this.fs.lstat(filePath);
102
+ if (!stat.isSymbolicLink()) {
103
+ return;
104
+ }
105
+ if (`projects/${project.name}` !== this.fs.readlink(filePath)) {
106
+ return;
107
+ }
108
+ this.fs.unlink(filePath);
109
+ }
110
+ };
111
+ exports.HttpAuthService = HttpAuthService;
112
+ exports.HttpAuthService = HttpAuthService = __decorate([
113
+ (0, core_1.Injectable)(),
114
+ __metadata("design:paramtypes", [core_1.ProcessService,
115
+ core_1.AppFileSystemService,
116
+ docker_module_1.DockerService,
117
+ ProxyService_1.ProxyService])
118
+ ], HttpAuthService);
@@ -1,14 +1,15 @@
1
- import { Project, AppConfigService, AppFileSystemService, ProxyService as CoreProxyService } from "@wocker/core";
1
+ import { Project, AppConfigService, AppFileSystemService, ProcessService, ProxyService as CoreProxyService } from "@wocker/core";
2
2
  import { DockerService } from "@wocker/docker-module";
3
3
  export declare class ProxyService extends CoreProxyService {
4
4
  protected readonly appConfigService: AppConfigService;
5
+ protected readonly processService: ProcessService;
5
6
  protected readonly fs: AppFileSystemService;
6
7
  protected readonly dockerService: DockerService;
7
8
  protected containerName: string;
8
9
  protected oldContainerNames: string[];
9
10
  protected imageName: string;
10
11
  protected oldImages: string[];
11
- constructor(appConfigService: AppConfigService, fs: AppFileSystemService, dockerService: DockerService);
12
+ constructor(appConfigService: AppConfigService, processService: ProcessService, fs: AppFileSystemService, dockerService: DockerService);
12
13
  init(project: Project): Promise<void>;
13
14
  start(restart?: boolean, rebuild?: boolean): Promise<void>;
14
15
  stop(): Promise<void>;
@@ -49,16 +49,18 @@ const utils_1 = require("@wocker/utils");
49
49
  const Path = __importStar(require("path"));
50
50
  const env_1 = require("../../../env");
51
51
  let ProxyService = class ProxyService extends core_1.ProxyService {
52
- constructor(appConfigService, fs, dockerService) {
52
+ constructor(appConfigService, processService, fs, dockerService) {
53
53
  super();
54
54
  this.appConfigService = appConfigService;
55
+ this.processService = processService;
55
56
  this.fs = fs;
56
57
  this.dockerService = dockerService;
57
58
  this.containerName = "wocker-proxy";
58
59
  this.oldContainerNames = ["proxy.workspace"];
59
- this.imageName = "wocker-proxy:1.0.1";
60
+ this.imageName = "wocker-proxy:1.0.2";
60
61
  this.oldImages = [
61
- "wocker-proxy:1.0.0"
62
+ "wocker-proxy:1.0.0",
63
+ "wocker-proxy:1.0.1"
62
64
  ];
63
65
  }
64
66
  async init(project) {
@@ -81,7 +83,6 @@ let ProxyService = class ProxyService extends core_1.ProxyService {
81
83
  }
82
84
  console.info("Proxy starting...");
83
85
  await this.build(rebuild);
84
- const fs = this.fs;
85
86
  if (!this.fs.exists("certs/ca")) {
86
87
  this.fs.mkdir("certs/ca", {
87
88
  recursive: true,
@@ -94,20 +95,29 @@ let ProxyService = class ProxyService extends core_1.ProxyService {
94
95
  mode: 0o700
95
96
  });
96
97
  }
97
- if (!fs.exists("nginx/vhost.d")) {
98
- fs.mkdir("nginx/vhost.d", {
98
+ if (!this.fs.exists("nginx/vhost.d")) {
99
+ this.fs.mkdir("nginx/vhost.d", {
99
100
  recursive: true,
100
101
  mode: 0o700
101
102
  });
102
103
  }
103
- const httpPort = this.appConfigService.getMeta("PROXY_HTTP_PORT", "80");
104
- const httpsPort = this.appConfigService.getMeta("PROXY_HTTPS_PORT", "443");
105
- const sshPort = this.appConfigService.getMeta("PROXY_SSH_PORT", "22");
104
+ if (!this.fs.exists("nginx/htpasswd")) {
105
+ this.fs.mkdir("nginx/htpasswd", {
106
+ recursive: true,
107
+ mode: 0o764
108
+ });
109
+ }
110
+ else {
111
+ this.fs.chmod("nginx/htpasswd", 0o764);
112
+ }
113
+ const httpPort = this.appConfigService.getMeta("PROXY_HTTP_PORT", "80"), httpsPort = this.appConfigService.getMeta("PROXY_HTTPS_PORT", "443"), sshPort = this.appConfigService.getMeta("PROXY_SSH_PORT", "22");
106
114
  container = await this.dockerService.createContainer({
107
115
  name: this.containerName,
108
116
  image: this.imageName,
109
117
  restart: "always",
110
118
  env: {
119
+ UID: this.processService.UID,
120
+ GID: this.processService.GID,
111
121
  DEFAULT_HOST: "localhost",
112
122
  TRUST_DOWNSTREAM_PROXY: "true"
113
123
  },
@@ -120,9 +130,10 @@ let ProxyService = class ProxyService extends core_1.ProxyService {
120
130
  ],
121
131
  volumes: [
122
132
  "/var/run/docker.sock:/tmp/docker.sock:ro",
123
- `${fs.path("certs/projects")}:/etc/nginx/certs`,
124
- `${fs.path("certs/ca")}:/etc/nginx/ca-certs`,
125
- `${fs.path("nginx/vhost.d")}:/etc/nginx/vhost.d`
133
+ `${this.fs.path("certs/projects")}:/etc/nginx/certs`,
134
+ `${this.fs.path("certs/ca")}:/etc/nginx/ca-certs`,
135
+ `${this.fs.path("nginx/vhost.d")}:/etc/nginx/vhost.d`,
136
+ `${this.fs.path("nginx/htpasswd")}:/etc/nginx/htpasswd`
126
137
  ],
127
138
  network: "workspace"
128
139
  });
@@ -166,6 +177,7 @@ exports.ProxyService = ProxyService;
166
177
  exports.ProxyService = ProxyService = __decorate([
167
178
  (0, core_1.Injectable)("PROXY_SERVICE"),
168
179
  __metadata("design:paramtypes", [core_1.AppConfigService,
180
+ core_1.ProcessService,
169
181
  core_1.AppFileSystemService,
170
182
  docker_module_1.DockerService])
171
183
  ], ProxyService);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@wocker/ws",
3
3
  "type": "commonjs",
4
- "version": "1.0.31-beta.0",
4
+ "version": "1.0.32-beta.0",
5
5
  "author": "Kris Papercut <krispcut@gmail.com>",
6
6
  "description": "Docker workspace for web projects",
7
7
  "license": "MIT",
@@ -35,7 +35,7 @@
35
35
  "make-coverage-badge": "make-coverage-badge"
36
36
  },
37
37
  "dependencies": {
38
- "@wocker/core": "1.0.31",
38
+ "@wocker/core": "^1.0.32-beta.2",
39
39
  "@wocker/docker-module": "^0.0.6",
40
40
  "@wocker/utils": "^2.0.6",
41
41
  "async-mutex": "^0.4.0",
@@ -66,5 +66,16 @@
66
66
  "ts-node": "^10.9.2",
67
67
  "typescript": "^5.9.3",
68
68
  "unionfs": "^4.5.4"
69
+ },
70
+ "overrides": {
71
+ "@wocker/testing": {
72
+ "@wocker/core": "^1.0.32-beta.2"
73
+ },
74
+ "@wocker/docker-module": {
75
+ "@wocker/core": "^1.0.32-beta.2"
76
+ },
77
+ "@wocker/docker-mock-module": {
78
+ "@wocker/core": "^1.0.32-beta.2"
79
+ }
69
80
  }
70
81
  }
@@ -1,14 +1,21 @@
1
- FROM nginxproxy/nginx-proxy:1.6.4-alpine
1
+ FROM nginxproxy/nginx-proxy:1.10.1-alpine
2
2
 
3
- ARG SSH_PASSWORD=''
3
+ ENV UID=1000 \
4
+ GID=1000
4
5
 
6
+ COPY ./wocker-entrypoint.sh /app/wocker-entrypoint.sh
5
7
  COPY ./bin/wocker-create-ca /usr/local/bin/wocker-create-ca
6
8
  COPY ./bin/wocker-create-cert /usr/local/bin/wocker-create-cert
7
9
  COPY ./bin/wocker-create-domains /usr/local/bin/wocker-create-domains
8
10
 
9
- RUN chmod +x /usr/local/bin/wocker-create-ca && \
11
+ RUN chmod +x /app/wocker-entrypoint.sh && \
12
+ chown root:root /app/wocker-entrypoint.sh && \
13
+ chmod +x /usr/local/bin/wocker-create-ca && \
10
14
  chmod +x /usr/local/bin/wocker-create-cert && \
11
- chmod +x /usr/local/bin/wocker-create-domains
15
+ chmod +x /usr/local/bin/wocker-create-domains && \
16
+ apk add --no-cache apache2-utils shadow
17
+
18
+ ARG SSH_PASSWORD=''
12
19
 
13
20
  RUN if [ -n "$SSH_PASSWORD" ]; then \
14
21
  apk update && apk add --no-cache openssh; \
@@ -21,3 +28,6 @@ RUN if [ -n "$SSH_PASSWORD" ]; then \
21
28
  ssh-keygen -A; \
22
29
  echo "sshd: /usr/sbin/sshd -D" >> /app/Procfile; \
23
30
  fi
31
+
32
+ ENTRYPOINT ["/app/wocker-entrypoint.sh"]
33
+ CMD ["forego", "start", "-r"]
@@ -0,0 +1,11 @@
1
+ #!/bin/sh
2
+
3
+ set -e
4
+
5
+ UID=${UID:-1000}
6
+ GID=${GID:-1000}
7
+
8
+ groupmod -g ${GID} nginx
9
+ usermod -u ${UID} -g ${GID} nginx
10
+
11
+ exec /app/docker-entrypoint.sh "$@"