@ossy/deployment-tools 0.0.3 → 0.0.6

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/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  # deployment-tools
2
2
 
3
- Collection of scripts and tools to aid deployment of containers and static files
3
+ Command line toolkit to aid deployment of containers and static files
4
4
 
5
5
  ## Getting started
6
6
 
7
- Make sure Docker and Caddy is up and running
7
+ Make sure NodeJs and npm is installed and Docker and Caddy is up and running
8
8
  ```
9
9
  npx @ossy-se/deployment-tools start
10
10
  npx @ossy-se/deployment-tools deploy --ossyfile ./ossy.js
package/dist/index.js CHANGED
@@ -28476,12 +28476,12 @@ class CaddyClient {
28476
28476
  this.serverName = serverName
28477
28477
  }
28478
28478
 
28479
- deploy({ domain, targetPort }) {
28479
+ deploy({ domain, environmentName, targetPort }) {
28480
28480
  return fetch(`http://localhost:2019/config/apps/http/servers/${this.serverName}/routes`, {
28481
28481
  method: 'POST',
28482
28482
  headers: { 'Content-Type': 'application/json' },
28483
28483
  body: JSON.stringify({
28484
- match: [Matchers.host(domain)],
28484
+ match: [Matchers.host(`*.${environmentName}.${domain}`)],
28485
28485
  handle: [
28486
28486
  Handlers.subroute([{ handle: [Handlers.reverseProxy(targetPort)] }])
28487
28487
  ],
@@ -28834,7 +28834,11 @@ class ContainerManagerCommands {
28834
28834
 
28835
28835
  console.log('body', body)
28836
28836
 
28837
- fetch(`http://${targetEnvironment}.ci.${platform.domain}/deploy`, {
28837
+ const ciUrl = targetEnvironment === 'prod'
28838
+ ? `http://${platform.ciSubDomain}.${platform.domain}/deploy`
28839
+ : `http://${platform.ciSubDomain}.${targetEnvironment}.${platform.domain}/deploy`
28840
+
28841
+ fetch(ciUrl, {
28838
28842
  method: 'POST',
28839
28843
  headers: { 'Content-Type': 'application/json' },
28840
28844
  body: JSON.stringify(body)
@@ -28854,6 +28858,7 @@ class ContainerManagerCommands {
28854
28858
 
28855
28859
 
28856
28860
 
28861
+
28857
28862
  const [_, __, command, ...restArgs] = process.argv
28858
28863
 
28859
28864
  const startHandler = () => {
@@ -28874,9 +28879,10 @@ Description=D
28874
28879
  After=network.target
28875
28880
 
28876
28881
  [Service]
28877
- Environment=DEPLOYMENT_TOOLS_PORT=3000
28882
+ Environment=DEPLOYMENT_TOOLS_DOMAIN=${domain}
28883
+ Environment=DEPLOYMENT_TOOLS_SUBDOMAIN=${subdomain}
28884
+ Environment=DEPLOYMENT_TOOLS_PORT=${port}
28878
28885
  User=root
28879
- WorkingDirectory=/%h/deployment-tools
28880
28886
  ExecStart=npx @ossy/deployment-tools start-container-manager
28881
28887
  Restart=on-failure
28882
28888
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ossy/deployment-tools",
3
- "version": "0.0.3",
3
+ "version": "0.0.6",
4
4
  "description": "Collection of scripts and tools to aid deployment of containers and static files",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -80,12 +80,12 @@ class CaddyClient {
80
80
  this.serverName = serverName
81
81
  }
82
82
 
83
- deploy({ domain, targetPort }) {
83
+ deploy({ domain, environmentName, targetPort }) {
84
84
  return fetch(`http://localhost:2019/config/apps/http/servers/${this.serverName}/routes`, {
85
85
  method: 'POST',
86
86
  headers: { 'Content-Type': 'application/json' },
87
87
  body: JSON.stringify({
88
- match: [Matchers.host(domain)],
88
+ match: [Matchers.host(`*.${environmentName}.${domain}`)],
89
89
  handle: [
90
90
  Handlers.subroute([{ handle: [Handlers.reverseProxy(targetPort)] }])
91
91
  ],
@@ -101,7 +101,11 @@ export class ContainerManagerCommands {
101
101
 
102
102
  console.log('body', body)
103
103
 
104
- fetch(`http://${targetEnvironment}.ci.${platform.domain}/deploy`, {
104
+ const ciUrl = targetEnvironment === 'prod'
105
+ ? `http://${platform.ciSubDomain}.${platform.domain}/deploy`
106
+ : `http://${platform.ciSubDomain}.${targetEnvironment}.${platform.domain}/deploy`
107
+
108
+ fetch(ciUrl, {
105
109
  method: 'POST',
106
110
  headers: { 'Content-Type': 'application/json' },
107
111
  body: JSON.stringify(body)
package/src/index.js CHANGED
@@ -5,6 +5,7 @@ import { exec } from 'child_process'
5
5
  import arg from 'arg'
6
6
  import { ContainerManagerServer } from './container-manager-server.js'
7
7
  import { ContainerManagerCommands } from './container-manager-commands.js'
8
+ import * as config from './config.js'
8
9
 
9
10
  const [_, __, command, ...restArgs] = process.argv
10
11
 
@@ -26,9 +27,10 @@ Description=D
26
27
  After=network.target
27
28
 
28
29
  [Service]
29
- Environment=DEPLOYMENT_TOOLS_PORT=3000
30
+ Environment=DEPLOYMENT_TOOLS_DOMAIN=${config.domain}
31
+ Environment=DEPLOYMENT_TOOLS_SUBDOMAIN=${config.subdomain}
32
+ Environment=DEPLOYMENT_TOOLS_PORT=${config.port}
30
33
  User=root
31
- WorkingDirectory=/%h/deployment-tools
32
34
  ExecStart=npx @ossy/deployment-tools start-container-manager
33
35
  Restart=on-failure
34
36