@ossy/deployment-tools 1.17.4 → 1.17.5

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 (77) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +86 -86
  3. package/package.json +3 -4
  4. package/src/index.cli.js +0 -2
  5. package/src/infrastructure/cli.js +0 -5
  6. package/src/infrastructure/container-deployment-target/caddy.service.js +28 -10
  7. package/src/infrastructure/container-deployment-target/container-deployment-target.js +10 -24
  8. package/src/infrastructure/container-deployment-target/ossy-api.service.js +43 -0
  9. package/src/infrastructure/container-deployment-target/ossy-runtime.service.js +37 -0
  10. package/jsdoc/AwsCredentialsService.html +0 -166
  11. package/jsdoc/AwsProfile.html +0 -166
  12. package/jsdoc/CaddyService.html +0 -293
  13. package/jsdoc/ContainerServer.html +0 -265
  14. package/jsdoc/DeploymentQueueService.html +0 -166
  15. package/jsdoc/DeploymentToolsService.html +0 -166
  16. package/jsdoc/DockerService.html +0 -166
  17. package/jsdoc/EstablishTrustStack.html +0 -268
  18. package/jsdoc/PlatformConfigService.html +0 -166
  19. package/jsdoc/PlatformDeploymentService.html +0 -166
  20. package/jsdoc/PlatformServerService.html +0 -166
  21. package/jsdoc/PlatformStack.html +0 -166
  22. package/jsdoc/PlatformTemplateService.html +0 -502
  23. package/jsdoc/RestApiService.html +0 -166
  24. package/jsdoc/aws-credentials_aws-credentials.js.html +0 -138
  25. package/jsdoc/config_platform-config.js.html +0 -113
  26. package/jsdoc/deploy_platform-deployment.js.html +0 -155
  27. package/jsdoc/deployment-queue_deployment-queue.js.html +0 -132
  28. package/jsdoc/fonts/OpenSans-Bold-webfont.eot +0 -0
  29. package/jsdoc/fonts/OpenSans-Bold-webfont.svg +0 -1830
  30. package/jsdoc/fonts/OpenSans-Bold-webfont.woff +0 -0
  31. package/jsdoc/fonts/OpenSans-BoldItalic-webfont.eot +0 -0
  32. package/jsdoc/fonts/OpenSans-BoldItalic-webfont.svg +0 -1830
  33. package/jsdoc/fonts/OpenSans-BoldItalic-webfont.woff +0 -0
  34. package/jsdoc/fonts/OpenSans-Italic-webfont.eot +0 -0
  35. package/jsdoc/fonts/OpenSans-Italic-webfont.svg +0 -1830
  36. package/jsdoc/fonts/OpenSans-Italic-webfont.woff +0 -0
  37. package/jsdoc/fonts/OpenSans-Light-webfont.eot +0 -0
  38. package/jsdoc/fonts/OpenSans-Light-webfont.svg +0 -1831
  39. package/jsdoc/fonts/OpenSans-Light-webfont.woff +0 -0
  40. package/jsdoc/fonts/OpenSans-LightItalic-webfont.eot +0 -0
  41. package/jsdoc/fonts/OpenSans-LightItalic-webfont.svg +0 -1835
  42. package/jsdoc/fonts/OpenSans-LightItalic-webfont.woff +0 -0
  43. package/jsdoc/fonts/OpenSans-Regular-webfont.eot +0 -0
  44. package/jsdoc/fonts/OpenSans-Regular-webfont.svg +0 -1831
  45. package/jsdoc/fonts/OpenSans-Regular-webfont.woff +0 -0
  46. package/jsdoc/global.html +0 -800
  47. package/jsdoc/index.html +0 -65
  48. package/jsdoc/infrastructure_container-server_aws-profile.js.html +0 -76
  49. package/jsdoc/infrastructure_container-server_caddy.service.js.html +0 -123
  50. package/jsdoc/infrastructure_container-server_container-server.js.html +0 -229
  51. package/jsdoc/infrastructure_container-server_deployment-tools.service.js.html +0 -91
  52. package/jsdoc/infrastructure_establish-trust-stack.js.html +0 -119
  53. package/jsdoc/infrastructure_platform-stack.js.html +0 -107
  54. package/jsdoc/scripts/linenumber.js +0 -25
  55. package/jsdoc/scripts/prettify/Apache-License-2.0.txt +0 -202
  56. package/jsdoc/scripts/prettify/lang-css.js +0 -2
  57. package/jsdoc/scripts/prettify/prettify.js +0 -28
  58. package/jsdoc/server_caddy.js.html +0 -165
  59. package/jsdoc/server_docker.js.html +0 -133
  60. package/jsdoc/server_platform-server.js.html +0 -91
  61. package/jsdoc/server_rest-api.js.html +0 -82
  62. package/jsdoc/styles/jsdoc-default.css +0 -358
  63. package/jsdoc/styles/prettify-jsdoc.css +0 -111
  64. package/jsdoc/styles/prettify-tomorrow.css +0 -132
  65. package/jsdoc/template_platform-template.js.html +0 -134
  66. package/jsdoc.config.js +0 -15
  67. package/src/deploy/cli.js +0 -60
  68. package/src/deploy/index.js +0 -1
  69. package/src/deploy/platform-deployment.js +0 -122
  70. package/src/deployment-queue/deployment-queue.js +0 -81
  71. package/src/deployment-queue/index.js +0 -1
  72. package/src/docker/docker-service.js +0 -136
  73. package/src/docker/docker-service.playground.js +0 -15
  74. package/src/docker/index.js +0 -1
  75. package/src/infrastructure/ecr-stack.js +0 -53
  76. package/src/server/cli.js +0 -34
  77. package/src/server/platform-server.js +0 -42
package/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## 1.17.5 (2026-05-25)
7
+
8
+ **Note:** Version bump only for package @ossy/deployment-tools
9
+
10
+
11
+
12
+
13
+
6
14
  ## 1.17.4 (2026-05-23)
7
15
 
8
16
  **Note:** Version bump only for package @ossy/deployment-tools
package/README.md CHANGED
@@ -1,125 +1,125 @@
1
1
  # @ossy/deployment-tools
2
2
 
3
- Collection of scripts and tools to aid deployment of
4
- containers and static files to Amazon Web Services (typically from CI).
3
+ Infrastructure and CDK tooling for the Ossy platform EC2 host.
5
4
 
6
- ## Server
5
+ The host runs three services: **Caddy** (TLS + reverse proxy), **ossy-api** (the platform API), and **ossy-runtime** (the multi-tenant SSR server). Apps are deployed by running `ossy app publish`
7
6
 
8
- ### start
9
- Starts a node server in the background that polls an deployment queue for container deployment requests.
10
- Make sure NodeJs and npm is installed and Docker and Caddy is up and running.
11
- ```bash
12
- npx @ossy/deployment-tools server start
13
- ```
7
+ ## Architecture
14
8
 
15
- ### stop
16
- Stops the deployment-tools systemd service
17
- ```bash
18
- npx @ossy/deployment-tools server stop
19
9
  ```
20
-
21
- ### status
22
- Prints the status of the deployment-tools systemd service
23
- ```bash
24
- npx @ossy/deployment-tools server status
10
+ Internet → Caddy (:443)
11
+ ├── api.ossy.se → ossy-api (:3001)
12
+ └── *.* (on-demand TLS) ossy-runtime (:3000)
13
+ └── loads build from CMS on first request
25
14
  ```
26
15
 
27
- ## Deployment
16
+ Caddy uses **on-demand TLS**: before issuing a certificate for any domain, it calls `GET http://localhost:3001/api/v0/apps/ask?domain=<domain>`. If the domain is registered (i.e. `ossy app publish` has been run for it), Caddy issues the cert and proxies to the runtime.
28
17
 
29
- The first argument after the package name is the **handler** (`deployment`). Commands are **`deployment deploy`** (one site) and **`deployment deploy-all`** (every deployment entry for a platform).
18
+ ## Services
30
19
 
31
- Deployments are read from a **glob** of JSON files (e.g. `deployments.json`), and platform definitions from a **platforms** JSON file. Domain and platform for a given site are **not** taken from `ossy.json`; they live in those deployment records (and, in app workflows, mirror **`domain` / `platform` in `src/config.js`** when you use **`@ossy/cli publish`**).
20
+ All services run as Docker containers managed by systemd. Service files are written to the EC2 host by CDK user data at instance creation.
32
21
 
33
- **Container images must live in Amazon ECR.** Each `CONTAINER` row needs a **`registry`** field with your ECR API endpoint (for example `123456789012.dkr.ecr.eu-north-1.amazonaws.com`). Both the **CLI** (`deployment deploy`) and the **worker** (`server start`) require this. The worker **always** runs **`aws ecr get-login-password | docker login`** before **`docker pull`**, using the host IAM role (or environment AWS credentials). Do not put registry passwords on the queue.
22
+ | Service | Unit file | Port | Auto-start |
23
+ |---|---|---|---|
24
+ | Caddy | `caddy-route53.service` | 80, 443 | Yes |
25
+ | Ossy API | `ossy-api.service` | 3001 | Manual |
26
+ | Ossy Runtime | `ossy-runtime.service` | 3000 | Manual |
34
27
 
35
- ### deploy (single domain)
28
+ The API and runtime are **not** auto-started because their Docker images must be built on the host first. After SSHing in and building the images, enable them once:
36
29
 
37
30
  ```bash
38
- npx --yes @ossy/deployment-tools deployment deploy \
39
- --domain example.com \
40
- --platform my-platform \
41
- --platforms-path packages/infrastructure/bin/deployment-platforms.json \
42
- --deployments-path "packages/infrastructure/deployments/**/*.json"
31
+ sudo systemctl enable --now ossy-api ossy-runtime
43
32
  ```
44
33
 
45
- | Flag | Alias | Description |
46
- |------|--------|-------------|
47
- | `--domain` | `-d` | Target site domain (must match an entry under that platform in the deployments glob) |
48
- | `--platform` | `-p` | Target deployment platform name |
49
- | `--platforms-path` | `-pp` | Path to platforms JSON (AWS / queue config) |
50
- | `--deployments-path` | `-dp` | Glob of deployment JSON files |
34
+ ## Bootstrapping a new host
51
35
 
52
- ### deploy-all (whole platform)
36
+ After CDK provisions the EC2 instance (Caddy starts automatically), SSH in and:
53
37
 
54
38
  ```bash
55
- npx --yes @ossy/deployment-tools deployment deploy-all \
56
- --platform my-platform \
57
- --platforms-path packages/infrastructure/bin/deployment-platforms.json \
58
- --deployments-path "packages/infrastructure/deployments/**/*.json"
59
- ```
39
+ # Clone the repo
40
+ git clone <repo-url> ~/ossy
41
+ cd ~/ossy
60
42
 
61
- ### Apps: use @ossy/cli publish
43
+ # Build the API image
44
+ docker build -t ossy-api:latest -f api/Dockerfile api
62
45
 
63
- For Ossy apps, prefer **`npx @ossy/cli publish`** from the website package: it resolves **`--domain` / `--platform`** from **`src/config.js`** (or **`--config`**) when possible, calls **`deployment deploy`** (or **`deploy-all`** with **`--all`**), then can upload **resource templates** from the same config. See **`packages/cli/README.md`**.
46
+ # Build the runtime image
47
+ docker build -t ossy-runtime:latest \
48
+ -f packages/runtime/Dockerfile packages/runtime
64
49
 
65
- ## Useful commands
50
+ # Start both services
51
+ sudo systemctl enable --now ossy-api ossy-runtime
52
+ ```
66
53
 
54
+ ## Redeploying after a code change
67
55
 
68
- **SSH into instance**
69
- ```
70
- ssh -i path/to/keys ubuntu@<ip>
71
- ```
56
+ ```bash
57
+ cd ~/ossy && git pull
72
58
 
73
- **View running containers**
74
- ```
75
- docker ps
76
- ```
59
+ # Rebuild whichever image changed
60
+ docker build -t ossy-api:latest -f api/Dockerfile api
61
+ # or
62
+ docker build -t ossy-runtime:latest \
63
+ -f packages/runtime/Dockerfile packages/runtime
77
64
 
78
- **View logs from docker container**
79
- ```
80
- docker logs <id|alias>
65
+ # Restart the service
66
+ sudo systemctl restart ossy-api
67
+ # or
68
+ sudo systemctl restart ossy-runtime
81
69
  ```
82
70
 
83
- **View logs from deployment-tools service**
84
- ```
85
- // With last 200 lines and follow new logs
86
- journalctl -u deployment-tools.service -n 200 -f
87
- ```
71
+ ## Environment variables
88
72
 
89
- **View logs from caddy service**
90
- ```
91
- // With last 200 lines and follow new logs
92
- journalctl -u caddy-route53.service -n 200 -f
93
- ```
73
+ Service env vars are read from `/etc/environment` on the host. Set these before starting the services:
94
74
 
95
- **View logs from docker service**
96
- ```
97
- // With last 200 lines and follow new logs
98
- journalctl -u docker.service -n 200 -f
99
- ```
75
+ | Variable | Used by | Description |
76
+ |---|---|---|
77
+ | `DB_URL` | API | Atlas MongoDB connection string |
78
+ | `DB_NAME` | API | MongoDB database name |
79
+ | `TOKEN_SECRET` | API | JWT signing secret |
80
+ | `MEDIA_REPOSITORY` | API | S3 bucket name for media uploads |
81
+ | `MEDIA_CDN_DOMAIN_NAME` | API | CloudFront domain for public media |
82
+ | `AWS_ACCESS_KEY_ID` | API | AWS credentials for S3 |
83
+ | `AWS_SECRET_ACCESS_KEY` | API | AWS credentials for S3 |
84
+ | `OSSY_API_KEY` | Runtime | API JWT for CMS reads |
85
+
86
+ ## Infrastructure (CDK)
100
87
 
101
- **Upgrade deployment-tools server version**
88
+ CDK stacks are defined in `src/infrastructure/`. Run from `src/infrastructure/cli.js` via `cdk deploy`.
102
89
 
103
- - 1 release new version of the npm package with `npm publish`
104
- - 2 ssh into the instance with `ssh -i path/to/keys ubuntu@<ip>`
105
- - 3 stop the deployment-tools services with `sudo systemctl stop deployment-tools.service`
106
- - 4 remove the old version of the tool with `rm -rf ~/.npm/_npx`
107
- - 5 start the deployment-tools services again with `sudo systemctl start deployment-tools.service`
90
+ | Stack | Description |
91
+ |---|---|
92
+ | `trust-ci` | IAM role for CI to deploy infrastructure |
93
+ | `deployment-target` | EC2 host, S3 bucket, CloudFront CDN for media |
94
+ | `dns` | Route53 records |
95
+ | `ses` | SES email sending |
108
96
 
109
- That's it, the service will download the latest version of the package.
97
+ ## Useful commands
98
+
99
+ **SSH into instance**
100
+ ```bash
101
+ ssh -i path/to/keys ubuntu@<ip>
102
+ ```
110
103
 
111
- **Update Nodejs on the server**
104
+ **View service logs**
105
+ ```bash
106
+ journalctl -u ossy-runtime.service -n 200 -f
107
+ journalctl -u ossy-api.service -n 200 -f
108
+ journalctl -u caddy-route53.service -n 200 -f
112
109
  ```
113
- # Remove old NodeSource repository if it exists
114
- sudo rm -f /etc/apt/sources.list.d/nodesource.list
115
110
 
116
- # Download and run the Node.js 24.x setup script
117
- curl -fsSL https://deb.nodesource.com/setup_24.x | sudo -E bash -
111
+ **View running containers**
112
+ ```bash
113
+ docker ps
114
+ ```
118
115
 
119
- # Install Node.js 24
120
- sudo apt-get install -y nodejs
116
+ **View container logs**
117
+ ```bash
118
+ docker logs ossy-runtime
119
+ docker logs ossy-api
120
+ ```
121
121
 
122
- # Verify the installation
123
- node --version
124
- npm --version
122
+ **Reload Caddy config**
123
+ ```bash
124
+ sudo systemctl reload caddy-route53.service
125
125
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ossy/deployment-tools",
3
- "version": "1.17.4",
3
+ "version": "1.17.5",
4
4
  "description": "Collection of scripts and tools to aid deployment of containers and static files to Amazon Web Services through GitHub Actions",
5
5
  "source": "./src/index.js",
6
6
  "main": "./src/index.js",
@@ -28,8 +28,7 @@
28
28
  "node-fetch": "^2.6.7"
29
29
  },
30
30
  "devDependencies": {
31
- "jest": "^27.5.1",
32
- "jsdoc": "^4.0.2"
31
+ "jest": "^27.5.1"
33
32
  },
34
- "gitHead": "45251429b7b1f4cdf7f81a5046419905c3c118c9"
33
+ "gitHead": "81baa12dad845ec3f48438d2c4ba139a3a271770"
35
34
  }
package/src/index.cli.js CHANGED
@@ -5,9 +5,7 @@ const [_, __, handlerName, ...restArgs] = process.argv
5
5
 
6
6
  const loadHandler = {
7
7
  aws: () => require('./aws-credentials/cli.js'),
8
- deployment: () => require('./deploy/cli.js'),
9
8
  template: () => require('./template/cli.js'),
10
- server: () => require('./server/cli.js'),
11
9
  }[handlerName]
12
10
 
13
11
  !!loadHandler && loadHandler().handler(restArgs)
@@ -5,7 +5,6 @@ const { TrustCiStack } = require('./trust-ci-stack')
5
5
  const { DeploymentTargetStack } = require('./deployment-target-stack')
6
6
  const { DnsStack } = require('./dns-stack')
7
7
  const { SesStack } = require('./ses-stack')
8
- const { EcrStack } = require('./ecr-stack')
9
8
  const { PlatformTemplateService, DeploymentTemplateService } = require('../template')
10
9
  const { PlatformConfigService } = require('../config')
11
10
 
@@ -29,10 +28,6 @@ Promise.all([
29
28
  }
30
29
 
31
30
  new TrustCiStack(app, `${config.platformName}-trust-ci`, stackProps)
32
- new EcrStack(app, `${config.platformName}-ecr`, {
33
- ...stackProps,
34
- deployments: deploymentMap[config.platformName] || []
35
- })
36
31
 
37
32
  const deploymentTarget = new DeploymentTargetStack(app, `${config.platformName}-deployment-target`, stackProps)
38
33
 
@@ -1,12 +1,25 @@
1
+ const caddyfile = `
2
+ {
3
+ on_demand_tls {
4
+ ask http://localhost:3001/api/v0/apps/ask
5
+ }
6
+ }
7
+
8
+ api.ossy.se {
9
+ reverse_proxy localhost:3001
10
+ }
11
+
12
+ :443 {
13
+ tls {
14
+ on_demand
15
+ }
16
+ reverse_proxy localhost:3000
17
+ }
18
+ `
19
+
1
20
  const systemdServiceFile = `
2
- # caddy-api.service
3
- #
4
- # For using Caddy with its API.
5
- #
6
- # This unit is "durable" in that it will automatically resume
7
- # the last active configuration if the service is restarted.
8
- #
9
- # See https://caddyserver.com/docs/install for instructions.
21
+ # caddy-route53.service — Caddy with Route53 DNS plugin for on-demand TLS.
22
+ # Configured via /etc/caddy/Caddyfile.
10
23
 
11
24
  [Unit]
12
25
  Description=Caddy
@@ -18,7 +31,7 @@ Requires=network-online.target
18
31
  Type=notify
19
32
  User=caddy
20
33
  Group=caddy
21
- ExecStart=/usr/bin/caddy.route53 run --environ --resume
34
+ ExecStart=/usr/bin/caddy.route53 run --config /etc/caddy/Caddyfile
22
35
  TimeoutStopSec=5s
23
36
  LimitNOFILE=1048576
24
37
  LimitNPROC=512
@@ -37,7 +50,12 @@ class CaddyService {
37
50
 
38
51
  static install() {
39
52
  return [
40
- `sudo echo "${systemdServiceFile}" >> /etc/systemd/system/caddy-route53.service`,
53
+ // Write Caddyfile
54
+ 'sudo mkdir -p /etc/caddy',
55
+ `sudo tee /etc/caddy/Caddyfile > /dev/null << 'CADDYEOF'\n${caddyfile}\nCADDYEOF`,
56
+ // Write systemd unit
57
+ `sudo tee /etc/systemd/system/caddy-route53.service > /dev/null << 'UNITEOF'\n${systemdServiceFile}\nUNITEOF`,
58
+ // Install Caddy + xcaddy + Route53 plugin
41
59
  'sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https',
42
60
  'sudo curl -1sLf \'https://dl.cloudsmith.io/public/caddy/stable/gpg.key\' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg',
43
61
  'sudo curl -1sLf \'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt\' | sudo tee /etc/apt/sources.list.d/caddy-stable.list',
@@ -1,4 +1,3 @@
1
- const { Duration, RemovalPolicy } = require('aws-cdk-lib')
2
1
  const { Construct } = require('constructs')
3
2
  const {
4
3
  Instance,
@@ -15,11 +14,11 @@ const {
15
14
  BlockDeviceVolume
16
15
  } = require('aws-cdk-lib/aws-ec2')
17
16
  const { Role, ServicePrincipal, Policy, PolicyStatement, Effect } = require('aws-cdk-lib/aws-iam')
18
- const { Queue } = require('aws-cdk-lib/aws-sqs')
19
17
  const { Source, BucketDeployment } = require('aws-cdk-lib/aws-s3-deployment')
20
18
  const { getInstallNodeJs, getInstallNpm, getInstallDocker } = require('./user-data-commands')
21
19
  const { CaddyService } = require('./caddy.service')
22
- const { DeploymentToolsService } = require('./deployment-tools.service')
20
+ const { OssyRuntimeService } = require('./ossy-runtime.service')
21
+ const { OssyApiService } = require('./ossy-api.service')
23
22
  const { AwsProfile } = require('./aws-profile')
24
23
  const { SupportedRegions } = require('../../config')
25
24
 
@@ -69,11 +68,6 @@ class ContainerDeploymentTarget extends Construct {
69
68
  'allow HTTPS traffic from anywhere'
70
69
  )
71
70
 
72
- const deploymentQueue = new Queue(this, 'DeploymentQueue', {
73
- queueName: `${props.config.awsDeploymentSqsName}`,
74
- receiveMessageWaitTime: Duration.seconds(20)
75
- })
76
-
77
71
  const platformConfigDeployment = new BucketDeployment(this, 'PlatformConfigDeployment', {
78
72
  sources: [Source.jsonData('platform-config.json', { ...props.config, awsRoleToAssume: undefined })],
79
73
  destinationBucket: props.bucket,
@@ -107,16 +101,6 @@ class ContainerDeploymentTarget extends Construct {
107
101
  ],
108
102
  resources: ['*']
109
103
  }),
110
- new PolicyStatement({
111
- effect: Effect.ALLOW,
112
- actions: [
113
- 'ecr:GetAuthorizationToken',
114
- 'ecr:BatchGetImage',
115
- 'ecr:GetDownloadUrlForLayer',
116
- 'ecr:BatchCheckLayerAvailability'
117
- ],
118
- resources: ['*']
119
- })
120
104
  ]
121
105
  }))
122
106
 
@@ -132,8 +116,11 @@ class ContainerDeploymentTarget extends Construct {
132
116
  ...getInstallDocker(),
133
117
  'sudo apt-get install awscli --yes',
134
118
  ...AwsProfile.writeFile(role.roleArn, SupportedRegions.North),
119
+ // Create shared Docker network for inter-container communication
120
+ 'docker network create ossy-network || true',
135
121
  ...CaddyService.install(),
136
- ...DeploymentToolsService.install()
122
+ ...OssyRuntimeService.install(),
123
+ ...OssyApiService.install()
137
124
  )
138
125
 
139
126
  userData.addS3DownloadCommand({
@@ -145,9 +132,9 @@ class ContainerDeploymentTarget extends Construct {
145
132
  userData.addCommands(
146
133
  'sudo systemctl daemon-reload',
147
134
  ...CaddyService.enable(),
148
- ...DeploymentToolsService.enable(),
149
- ...CaddyService.start(),
150
- ...DeploymentToolsService.start()
135
+ ...CaddyService.start()
136
+ // ossy-runtime and ossy-api are enabled manually after building images:
137
+ // sudo systemctl enable --now ossy-runtime ossy-api
151
138
  )
152
139
 
153
140
  const ec2Instance = new Instance(this, 'Ec2Instance', {
@@ -157,7 +144,7 @@ class ContainerDeploymentTarget extends Construct {
157
144
  role,
158
145
  instanceType: InstanceType.of(
159
146
  InstanceClass.T3,
160
- InstanceSize.LARGE
147
+ InstanceSize.SMALL
161
148
  ),
162
149
  machineImage: new GenericLinuxImage({
163
150
  [SupportedRegions.North]: InstanceImages.UBUNTU
@@ -172,7 +159,6 @@ class ContainerDeploymentTarget extends Construct {
172
159
  })
173
160
 
174
161
  props.bucket.grantRead(ec2Instance, '*')
175
- deploymentQueue.grant(ec2Instance, '*')
176
162
 
177
163
  this.instancePublicIp = ec2Instance.instancePublicIp
178
164
 
@@ -0,0 +1,43 @@
1
+ const systemdServiceFile = `
2
+ [Unit]
3
+ Description=Ossy API
4
+ After=network.target docker.service
5
+ Requires=docker.service
6
+
7
+ [Service]
8
+ EnvironmentFile=/etc/environment
9
+ ExecStartPre=-/usr/bin/docker rm -f ossy-api
10
+ ExecStart=/usr/bin/docker run --name ossy-api \\
11
+ --network ossy-network \\
12
+ -p 3001:3001 \\
13
+ -e DB_URL=\${DB_URL} \\
14
+ -e DB_NAME=\${DB_NAME} \\
15
+ -e TOKEN_SECRET=\${TOKEN_SECRET} \\
16
+ -e MEDIA_REPOSITORY=\${MEDIA_REPOSITORY} \\
17
+ -e MEDIA_CDN_DOMAIN_NAME=\${MEDIA_CDN_DOMAIN_NAME} \\
18
+ -e AWS_ACCESS_KEY_ID=\${AWS_ACCESS_KEY_ID} \\
19
+ -e AWS_SECRET_ACCESS_KEY=\${AWS_SECRET_ACCESS_KEY} \\
20
+ ossy-api:latest
21
+ ExecStop=/usr/bin/docker stop ossy-api
22
+ Restart=on-failure
23
+ RestartSec=5
24
+ `
25
+
26
+ // No [Install] section — service is enabled manually after the image is built.
27
+ // SSH into the host, build the image, then:
28
+ // sudo systemctl enable --now ossy-api
29
+
30
+ /**
31
+ * @class
32
+ */
33
+ class OssyApiService {
34
+
35
+ static install() {
36
+ return [`sudo tee /etc/systemd/system/ossy-api.service > /dev/null << 'EOF'\n${systemdServiceFile}\nEOF`]
37
+ }
38
+
39
+ }
40
+
41
+ module.exports = {
42
+ OssyApiService
43
+ }
@@ -0,0 +1,37 @@
1
+ const systemdServiceFile = `
2
+ [Unit]
3
+ Description=Ossy Runtime
4
+ After=network.target docker.service
5
+ Requires=docker.service
6
+
7
+ [Service]
8
+ EnvironmentFile=/etc/environment
9
+ ExecStartPre=-/usr/bin/docker rm -f ossy-runtime
10
+ ExecStart=/usr/bin/docker run --name ossy-runtime \\
11
+ --network ossy-network \\
12
+ -p 3000:3000 \\
13
+ -e OSSY_API_KEY=\${OSSY_API_KEY} \\
14
+ ossy-runtime:latest
15
+ ExecStop=/usr/bin/docker stop ossy-runtime
16
+ Restart=on-failure
17
+ RestartSec=5
18
+ `
19
+
20
+ // No [Install] section — service is enabled manually after the image is built.
21
+ // SSH into the host, build the image, then:
22
+ // sudo systemctl enable --now ossy-runtime
23
+
24
+ /**
25
+ * @class
26
+ */
27
+ class OssyRuntimeService {
28
+
29
+ static install() {
30
+ return [`sudo tee /etc/systemd/system/ossy-runtime.service > /dev/null << 'EOF'\n${systemdServiceFile}\nEOF`]
31
+ }
32
+
33
+ }
34
+
35
+ module.exports = {
36
+ OssyRuntimeService
37
+ }
@@ -1,166 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="utf-8">
5
- <title>JSDoc: Class: AwsCredentialsService</title>
6
-
7
- <script src="scripts/prettify/prettify.js"> </script>
8
- <script src="scripts/prettify/lang-css.js"> </script>
9
- <!--[if lt IE 9]>
10
- <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
11
- <![endif]-->
12
- <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
13
- <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
14
- </head>
15
-
16
- <body>
17
-
18
- <div id="main">
19
-
20
- <h1 class="page-title">Class: AwsCredentialsService</h1>
21
-
22
-
23
-
24
-
25
-
26
-
27
- <section>
28
-
29
- <header>
30
-
31
- <h2><span class="attribs"><span class="type-signature"></span></span>AwsCredentialsService<span class="signature">()</span><span class="type-signature"></span></h2>
32
-
33
-
34
- </header>
35
-
36
- <article>
37
- <div class="container-overview">
38
-
39
-
40
-
41
-
42
-
43
-
44
- <h4 class="name" id="AwsCredentialsService"><span class="type-signature"></span>new AwsCredentialsService<span class="signature">()</span><span class="type-signature"></span></h4>
45
-
46
-
47
-
48
-
49
-
50
-
51
-
52
-
53
-
54
-
55
-
56
-
57
-
58
-
59
-
60
-
61
-
62
-
63
- <dl class="details">
64
-
65
-
66
-
67
-
68
-
69
-
70
-
71
-
72
-
73
-
74
-
75
-
76
-
77
-
78
-
79
-
80
-
81
-
82
-
83
-
84
-
85
-
86
-
87
-
88
-
89
-
90
- <dt class="tag-source">Source:</dt>
91
- <dd class="tag-source"><ul class="dummy"><li>
92
- <a href="aws-credentials_aws-credentials.js.html">aws-credentials/aws-credentials.js</a>, <a href="aws-credentials_aws-credentials.js.html#line9">line 9</a>
93
- </li></ul></dd>
94
-
95
-
96
-
97
-
98
-
99
-
100
-
101
- </dl>
102
-
103
-
104
-
105
-
106
-
107
-
108
-
109
-
110
-
111
-
112
-
113
-
114
-
115
-
116
-
117
-
118
-
119
-
120
-
121
-
122
-
123
- </div>
124
-
125
-
126
-
127
-
128
-
129
-
130
-
131
-
132
-
133
-
134
-
135
-
136
-
137
-
138
-
139
-
140
-
141
-
142
-
143
-
144
- </article>
145
-
146
- </section>
147
-
148
-
149
-
150
-
151
- </div>
152
-
153
- <nav>
154
- <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="AwsCredentialsService.html">AwsCredentialsService</a></li><li><a href="AwsProfile.html">AwsProfile</a></li><li><a href="CaddyService.html">CaddyService</a></li><li><a href="ContainerServer.html">ContainerServer</a></li><li><a href="DeploymentQueueService.html">DeploymentQueueService</a></li><li><a href="DeploymentToolsService.html">DeploymentToolsService</a></li><li><a href="DockerService.html">DockerService</a></li><li><a href="EstablishTrustStack.html">EstablishTrustStack</a></li><li><a href="PlatformConfigService.html">PlatformConfigService</a></li><li><a href="PlatformDeploymentService.html">PlatformDeploymentService</a></li><li><a href="PlatformServerService.html">PlatformServerService</a></li><li><a href="PlatformStack.html">PlatformStack</a></li><li><a href="PlatformTemplateService.html">PlatformTemplateService</a></li><li><a href="RestApiService.html">RestApiService</a></li></ul><h3><a href="global.html">Global</a></h3>
155
- </nav>
156
-
157
- <br class="clear">
158
-
159
- <footer>
160
- Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.11</a> on Sun Oct 23 2022 22:23:31 GMT+0200 (Central European Summer Time)
161
- </footer>
162
-
163
- <script> prettyPrint(); </script>
164
- <script src="scripts/linenumber.js"> </script>
165
- </body>
166
- </html>