@ossy/deployment-tools 0.0.38 → 0.0.40

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 (34) hide show
  1. package/README.md +29 -21
  2. package/bin/dist/aws-credentials-client.d.ts +4 -0
  3. package/bin/dist/caddy-client.d.ts +13 -0
  4. package/bin/dist/ci-rest-api.d.ts +4 -0
  5. package/bin/dist/cli-commands/deploy-handler.d.ts +1 -0
  6. package/bin/dist/cli-commands/index.d.ts +4 -0
  7. package/bin/dist/cli-commands/start-handler.d.ts +1 -0
  8. package/bin/dist/cli-commands/status-handler.d.ts +1 -0
  9. package/bin/dist/cli-commands/stop-handler.d.ts +1 -0
  10. package/bin/dist/deployment-platform-client.d.ts +11 -0
  11. package/bin/dist/deployment-queue-client.d.ts +7 -0
  12. package/bin/dist/docker-client.d.ts +8 -0
  13. package/bin/dist/index.cli.d.ts +1 -0
  14. package/bin/dist/index.d.ts +2 -0
  15. package/bin/dist/log/index.d.ts +3 -0
  16. package/bin/dist/types/index.d.ts +65 -0
  17. package/dist/dist/aws-credentials-client.d.ts +4 -0
  18. package/dist/dist/caddy-client.d.ts +13 -0
  19. package/dist/dist/ci-rest-api.d.ts +4 -0
  20. package/dist/dist/cli-commands/deploy-handler.d.ts +1 -0
  21. package/dist/dist/cli-commands/index.d.ts +4 -0
  22. package/dist/dist/cli-commands/start-handler.d.ts +1 -0
  23. package/dist/dist/cli-commands/status-handler.d.ts +1 -0
  24. package/dist/dist/cli-commands/stop-handler.d.ts +1 -0
  25. package/dist/dist/deployment-platform-client.d.ts +11 -0
  26. package/dist/dist/deployment-queue-client.d.ts +7 -0
  27. package/dist/dist/docker-client.d.ts +8 -0
  28. package/dist/dist/index.cli.d.ts +2 -0
  29. package/dist/dist/index.d.ts +2 -0
  30. package/dist/dist/log/index.d.ts +3 -0
  31. package/dist/dist/types/index.d.ts +65 -0
  32. package/package.json +2 -2
  33. package/src/cli-commands/stop-handler.ts +1 -1
  34. package/tsconfig.json +2 -1
package/README.md CHANGED
@@ -1,28 +1,36 @@
1
- # deployment-tools
1
+ # @ossy/deployment-tools
2
2
 
3
- Command line toolkit to aid deployment of containers and static files
3
+ Collection of scripts and tools to aid deployment of
4
+ containers and static files to Amazon Web Services through GitHub Actions
4
5
 
5
- ## Getting started
6
+ ## Scripts
6
7
 
7
- Make sure NodeJs and npm is installed and Docker and Caddy is up and running
8
- ```
9
- npx @ossy-se/deployment-tools start
10
- npx @ossy-se/deployment-tools deploy --ossyfile ./ossy.js
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 start
11
13
  ```
12
14
 
13
- ## Available commands
14
- | Command | Description |
15
- |---------|-------------|
16
- | start | starts a node server in the background that exposes a web API on port 3000. |
17
- | stop | stops the server started with `start` |
18
- | status | prints the status of the node server |
19
- | deploy | make a deployment, the API needs to be up and running |
15
+ ### stop
16
+ Stops the deployment-tools systemd service
17
+ ```bash
18
+ npx @ossy/deployment-tools stop
19
+ ```
20
20
 
21
- ## Configuration
21
+ ### status
22
+ Prints the status of the deployment-tools systemd service
23
+ ```bash
24
+ npx @ossy/deployment-tools status
25
+ ```
22
26
 
23
- ### Environment variables
24
- | Name | Default | Description |
25
- |------|---------|-------------|
26
- | DEPLOYMENT_TOOLS_DOMAIN | localhost | the domain that containers are deployed to as well as the domain the web api is available on |
27
- | DEPLOYMENT_TOOLS_SUBDOMAIN | local-dev.ci | subdomain of the web api |
28
- | DEPLOYMENT_TOOLS_PORT | 3000 | port of the web api |
27
+ ### deploy
28
+ Sends a deployment request to the aws sqs deployment queue.
29
+ ```bash
30
+ npx --yes @ossy/deployment-tools deploy \
31
+ --username ${{ github.actor }} \
32
+ --authentication ${{ secrets.GITHUB_TOKEN }} \
33
+ --target-env ${{ github.event.inputs.environmentName }} \
34
+ --platforms packages/infrastructure/bin/deployment-platforms.json \
35
+ --ossyfile packages/${{ github.event.inputs.packageName }}/ossy.json \
36
+ ```
@@ -0,0 +1,4 @@
1
+ import { DeploymentPlatform } from 'types';
2
+ export declare class AwsCredentialsClient {
3
+ static resolveAwsCredentials({ awsAccountId, awsRegion, awsRoleToAssume }: DeploymentPlatform): Promise<any>;
4
+ }
@@ -0,0 +1,13 @@
1
+ import { DeploymentPlatform, ContainerDeploymentRequest } from 'types';
2
+ export declare const Matchers: {
3
+ host: (host: any) => {
4
+ host: any[];
5
+ };
6
+ path: (path: any) => {
7
+ path: any[];
8
+ };
9
+ };
10
+ export declare class CaddyClient {
11
+ static deploy(deploymentPlatform: DeploymentPlatform, deploymentRequest: ContainerDeploymentRequest): Promise<void | import("node-fetch").Response>;
12
+ static applyDefaultServerConfig(deploymentPlatform: DeploymentPlatform): Promise<void | import("node-fetch").Response>;
13
+ }
@@ -0,0 +1,4 @@
1
+ import { DeploymentPlatform } from 'types';
2
+ export declare class CiRestApi {
3
+ static start(deploymentPlatform: DeploymentPlatform): void;
4
+ }
@@ -0,0 +1 @@
1
+ export declare const deployHandler: (cliArgs: any) => void;
@@ -0,0 +1,4 @@
1
+ export declare const runCliCommand: ({ name, args }: {
2
+ name: any;
3
+ args: any;
4
+ }) => void;
@@ -0,0 +1 @@
1
+ export declare const startHandler: (cliArgs: any) => void;
@@ -0,0 +1 @@
1
+ export declare const statusHandler: () => void;
@@ -0,0 +1 @@
1
+ export declare const stopHandler: () => void;
@@ -0,0 +1,11 @@
1
+ import { DeploymentPlatform, SupportedEnvironments, DeploymentTemplate } from 'types';
2
+ export declare class DeploymentPlatformClient {
3
+ static start(pathToDeploymentPlatforms: string): void;
4
+ static deploy(username: any, authentication: any, targetEnvironment: any, pathToDeploymentPlatforms: any, pathToOssyFile: any): Promise<void>;
5
+ static getDeploymentTemplates(pathToOssyFile: string): Promise<DeploymentTemplate[]>;
6
+ static getDeploymentPlatforms(pathToDeploymentPlatforms: string): Promise<DeploymentPlatform[]>;
7
+ static getEnvironmentVariables(targetEnvironment: SupportedEnvironments, deploymentRequest: DeploymentTemplate): any;
8
+ static resolveDeploymentPlatformValues(deploymentPlatform: DeploymentPlatform): DeploymentPlatform;
9
+ static setDefaultDeploymentPlatformValues(deploymentPlatform: DeploymentPlatform): DeploymentPlatform;
10
+ static setCalculatedDeploymentPlatformValues(deploymentPlatform: DeploymentPlatform): DeploymentPlatform;
11
+ }
@@ -0,0 +1,7 @@
1
+ import { SQSClient } from '@aws-sdk/client-sqs';
2
+ import { DeploymentPlatform, ContainerDeploymentRequest } from 'types';
3
+ export declare class DeploymentQueueClient {
4
+ static sendDeploymentRequest(deploymentPlatform: DeploymentPlatform, deploymentRequest: ContainerDeploymentRequest): Promise<void>;
5
+ static pollForDeploymentRequests(deploymentPlatform: DeploymentPlatform, handleDeploymentRequest: (deploymentRequest: ContainerDeploymentRequest) => Promise<void>): void;
6
+ static createAwsSqsClient(deploymentPlatform: DeploymentPlatform): Promise<SQSClient>;
7
+ }
@@ -0,0 +1,8 @@
1
+ import { DeploymentPlatform, ContainerDeploymentRequest } from 'types';
2
+ export declare class DockerClient {
3
+ static createDockerNetworkForContainerManagerServer(deploymentPlatform: DeploymentPlatform): void;
4
+ static stopContainer(deploymentRequest: ContainerDeploymentRequest): string;
5
+ static startContainer(deploymentPlatform: any, { image, containerPort, hostPort, registry, env }: ContainerDeploymentRequest): string;
6
+ static resolveCredentials({ registry, username, authentication }: ContainerDeploymentRequest): string;
7
+ static deploy(deploymentPlatform: DeploymentPlatform, deploymentRequest: ContainerDeploymentRequest): Promise<void>;
8
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ export { DeploymentPlatformClient } from 'deployment-platform-client';
2
+ export * from 'types';
@@ -0,0 +1,3 @@
1
+ export declare const logInfo: (logInput: any) => void;
2
+ export declare const logError: (logInput: any) => void;
3
+ export declare const logDebug: (logInput: any) => void;
@@ -0,0 +1,65 @@
1
+ export interface DeploymentPlatformTemplate {
2
+ platformName: string;
3
+ domain: string;
4
+ supportedDeploymentTypes: SupportedDeploymentTypes[];
5
+ supportedEnvironments: SupportedEnvironments[];
6
+ awsRegion?: string;
7
+ awsAccountId: string;
8
+ awsKeyPairName?: string;
9
+ awsRoleToAssume?: string;
10
+ awsDeploymentSqsArn?: string;
11
+ ciSubDomain?: string;
12
+ ciInternalServerPort?: string | number;
13
+ ciServerName?: string;
14
+ ciDockerNetworkName?: string;
15
+ }
16
+ export interface DeploymentPlatform extends Required<Omit<DeploymentPlatformTemplate, 'awsRoleToAssume' | 'awsKeyPairName'>> {
17
+ activeEnvironment: SupportedEnvironments;
18
+ awsRoleToAssume?: string;
19
+ awsKeyPairName?: string;
20
+ }
21
+ export declare enum SupportedRegions {
22
+ North = "eu-north-1"
23
+ }
24
+ export declare enum SupportedEnvironments {
25
+ LOCAL = "local",
26
+ QA = "qa",
27
+ TEST = "test",
28
+ DEMO = "demo",
29
+ PROD = "prod"
30
+ }
31
+ export declare enum SupportedDeploymentTypes {
32
+ Container = "CONTAINER"
33
+ }
34
+ export interface DeploymentTemplate {
35
+ type: SupportedDeploymentTypes;
36
+ targetDeploymentPlatform: string;
37
+ subdomain?: string;
38
+ env?: {
39
+ shared?: {
40
+ [name: string]: string | number;
41
+ };
42
+ prod?: {
43
+ [name: string]: string | number;
44
+ };
45
+ test?: {
46
+ [name: string]: string | number;
47
+ };
48
+ qa?: {
49
+ [name: string]: string | number;
50
+ };
51
+ };
52
+ }
53
+ export interface ContainerDeploymentTemplate extends DeploymentTemplate {
54
+ type: SupportedDeploymentTypes.Container;
55
+ dockerFile: string;
56
+ dockerContext: string;
57
+ image: string;
58
+ hostPort: number;
59
+ containerPort: number;
60
+ registry: string;
61
+ }
62
+ export interface ContainerDeploymentRequest extends ContainerDeploymentTemplate {
63
+ authentication?: string;
64
+ username?: string;
65
+ }
@@ -0,0 +1,4 @@
1
+ import { DeploymentPlatform } from 'types';
2
+ export declare class AwsCredentialsClient {
3
+ static resolveAwsCredentials({ awsAccountId, awsRegion, awsRoleToAssume }: DeploymentPlatform): Promise<any>;
4
+ }
@@ -0,0 +1,13 @@
1
+ import { DeploymentPlatform, ContainerDeploymentRequest } from 'types';
2
+ export declare const Matchers: {
3
+ host: (host: any) => {
4
+ host: any[];
5
+ };
6
+ path: (path: any) => {
7
+ path: any[];
8
+ };
9
+ };
10
+ export declare class CaddyClient {
11
+ static deploy(deploymentPlatform: DeploymentPlatform, deploymentRequest: ContainerDeploymentRequest): Promise<void | import("node-fetch").Response>;
12
+ static applyDefaultServerConfig(deploymentPlatform: DeploymentPlatform): Promise<void | import("node-fetch").Response>;
13
+ }
@@ -0,0 +1,4 @@
1
+ import { DeploymentPlatform } from 'types';
2
+ export declare class CiRestApi {
3
+ static start(deploymentPlatform: DeploymentPlatform): void;
4
+ }
@@ -0,0 +1 @@
1
+ export declare const deployHandler: (cliArgs: any) => void;
@@ -0,0 +1,4 @@
1
+ export declare const runCliCommand: ({ name, args }: {
2
+ name: any;
3
+ args: any;
4
+ }) => void;
@@ -0,0 +1 @@
1
+ export declare const startHandler: (cliArgs: any) => void;
@@ -0,0 +1 @@
1
+ export declare const statusHandler: () => void;
@@ -0,0 +1 @@
1
+ export declare const stopHandler: () => void;
@@ -0,0 +1,11 @@
1
+ import { DeploymentPlatform, SupportedEnvironments, DeploymentTemplate } from 'types';
2
+ export declare class DeploymentPlatformClient {
3
+ static start(pathToDeploymentPlatforms: string): void;
4
+ static deploy(username: any, authentication: any, targetEnvironment: any, pathToDeploymentPlatforms: any, pathToOssyFile: any): Promise<void>;
5
+ static getDeploymentTemplates(pathToOssyFile: string): Promise<DeploymentTemplate[]>;
6
+ static getDeploymentPlatforms(pathToDeploymentPlatforms: string): Promise<DeploymentPlatform[]>;
7
+ static getEnvironmentVariables(targetEnvironment: SupportedEnvironments, deploymentRequest: DeploymentTemplate): any;
8
+ static resolveDeploymentPlatformValues(deploymentPlatform: DeploymentPlatform): DeploymentPlatform;
9
+ static setDefaultDeploymentPlatformValues(deploymentPlatform: DeploymentPlatform): DeploymentPlatform;
10
+ static setCalculatedDeploymentPlatformValues(deploymentPlatform: DeploymentPlatform): DeploymentPlatform;
11
+ }
@@ -0,0 +1,7 @@
1
+ import { SQSClient } from '@aws-sdk/client-sqs';
2
+ import { DeploymentPlatform, ContainerDeploymentRequest } from 'types';
3
+ export declare class DeploymentQueueClient {
4
+ static sendDeploymentRequest(deploymentPlatform: DeploymentPlatform, deploymentRequest: ContainerDeploymentRequest): Promise<void>;
5
+ static pollForDeploymentRequests(deploymentPlatform: DeploymentPlatform, handleDeploymentRequest: (deploymentRequest: ContainerDeploymentRequest) => Promise<void>): void;
6
+ static createAwsSqsClient(deploymentPlatform: DeploymentPlatform): Promise<SQSClient>;
7
+ }
@@ -0,0 +1,8 @@
1
+ import { DeploymentPlatform, ContainerDeploymentRequest } from 'types';
2
+ export declare class DockerClient {
3
+ static createDockerNetworkForContainerManagerServer(deploymentPlatform: DeploymentPlatform): void;
4
+ static stopContainer(deploymentRequest: ContainerDeploymentRequest): string;
5
+ static startContainer(deploymentPlatform: any, { image, containerPort, hostPort, registry, env }: ContainerDeploymentRequest): string;
6
+ static resolveCredentials({ registry, username, authentication }: ContainerDeploymentRequest): string;
7
+ static deploy(deploymentPlatform: DeploymentPlatform, deploymentRequest: ContainerDeploymentRequest): Promise<void>;
8
+ }
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,2 @@
1
+ export { DeploymentPlatformClient } from 'deployment-platform-client';
2
+ export * from 'types';
@@ -0,0 +1,3 @@
1
+ export declare const logInfo: (logInput: any) => void;
2
+ export declare const logError: (logInput: any) => void;
3
+ export declare const logDebug: (logInput: any) => void;
@@ -0,0 +1,65 @@
1
+ export interface DeploymentPlatformTemplate {
2
+ platformName: string;
3
+ domain: string;
4
+ supportedDeploymentTypes: SupportedDeploymentTypes[];
5
+ supportedEnvironments: SupportedEnvironments[];
6
+ awsRegion?: string;
7
+ awsAccountId: string;
8
+ awsKeyPairName?: string;
9
+ awsRoleToAssume?: string;
10
+ awsDeploymentSqsArn?: string;
11
+ ciSubDomain?: string;
12
+ ciInternalServerPort?: string | number;
13
+ ciServerName?: string;
14
+ ciDockerNetworkName?: string;
15
+ }
16
+ export interface DeploymentPlatform extends Required<Omit<DeploymentPlatformTemplate, 'awsRoleToAssume' | 'awsKeyPairName'>> {
17
+ activeEnvironment: SupportedEnvironments;
18
+ awsRoleToAssume?: string;
19
+ awsKeyPairName?: string;
20
+ }
21
+ export declare enum SupportedRegions {
22
+ North = "eu-north-1"
23
+ }
24
+ export declare enum SupportedEnvironments {
25
+ LOCAL = "local",
26
+ QA = "qa",
27
+ TEST = "test",
28
+ DEMO = "demo",
29
+ PROD = "prod"
30
+ }
31
+ export declare enum SupportedDeploymentTypes {
32
+ Container = "CONTAINER"
33
+ }
34
+ export interface DeploymentTemplate {
35
+ type: SupportedDeploymentTypes;
36
+ targetDeploymentPlatform: string;
37
+ subdomain?: string;
38
+ env?: {
39
+ shared?: {
40
+ [name: string]: string | number;
41
+ };
42
+ prod?: {
43
+ [name: string]: string | number;
44
+ };
45
+ test?: {
46
+ [name: string]: string | number;
47
+ };
48
+ qa?: {
49
+ [name: string]: string | number;
50
+ };
51
+ };
52
+ }
53
+ export interface ContainerDeploymentTemplate extends DeploymentTemplate {
54
+ type: SupportedDeploymentTypes.Container;
55
+ dockerFile: string;
56
+ dockerContext: string;
57
+ image: string;
58
+ hostPort: number;
59
+ containerPort: number;
60
+ registry: string;
61
+ }
62
+ export interface ContainerDeploymentRequest extends ContainerDeploymentTemplate {
63
+ authentication?: string;
64
+ username?: string;
65
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ossy/deployment-tools",
3
- "version": "0.0.38",
4
- "description": "Collection of scripts and tools to aid deployment of containers and static files",
3
+ "version": "0.0.40",
4
+ "description": "Collection of scripts and tools to aid deployment of containers and static files to Amazon Web Services through GitHub Actions",
5
5
  "type": "module",
6
6
  "types": "dist/index.d.ts" ,
7
7
  "main": "dist/index.js",
@@ -2,6 +2,6 @@ import { exec } from 'child_process'
2
2
  import { logInfo } from '../log'
3
3
 
4
4
  export const stopHandler = () => {
5
- logInfo({ message: 'Running stop command' })
5
+ logInfo({ message: 'Running stop command' })
6
6
  exec('systemctl stop deployment-tools.service')
7
7
  }
package/tsconfig.json CHANGED
@@ -5,6 +5,7 @@
5
5
  "moduleResolution": "nodenext",
6
6
  "baseUrl": "src",
7
7
  "lib": ["es2021"],
8
- "declaration": true
8
+ "declaration": true,
9
+ "declarationDir": "./dist"
9
10
  }
10
11
  }