auto-deploy-sh 2.1.4 → 2.1.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.
package/README.md CHANGED
@@ -24,7 +24,7 @@ npm install auto-deploy-sh -D
24
24
  }
25
25
  ```
26
26
 
27
- 2. Execute in terminal:
27
+ - Execute in terminal:
28
28
 
29
29
  ```bash
30
30
  npm run deploy
@@ -79,6 +79,8 @@ The configuration file is **fixed as `deploy-config.json`**. If missing, the too
79
79
  - `always`: The container **will always restart automatically** if it stops. It will also start automatically after Docker or system restarts.Even if the container is manually stopped, it will be restarted again after Docker restarts.
80
80
  - `unless-stopped`(recommended): The container will automatically restart on failure and start after Docker or system restarts.**If the container is manually stopped, it will not be restarted again**, making it suitable for long-running production services.
81
81
  - `on-failure`: The container **will restart only if it exits with a non-zero status code**. It will not restart on normal exits (exit code 0).
82
+ - `afterLaunch` (optional): **Post-start commands** (array of strings) to execute on the remote server after the container starts. Commands run from `/tmp/www/app/<containerName>` and are chained with `&&`, so if one command fails, the following commands are skipped and the deployment is marked as failed (e.g., `["docker ps", "curl -f http://localhost/health"]`).
83
+ - `customRunOptions` (optional): Custom content appended to the end of the `docker run` command after the image tag. It can be used to pass a custom container startup command or arguments (e.g., `"--env-file ./env.list"`).
82
84
  - `Options`: **Optional** advanced settings (all sub-properties are optional)
83
85
  - `permission`: Build-time user/group settings. During deployment, they are converted to `docker build --build-arg UID=<uid> --build-arg GID=<gid>`. The Dockerfile must declare and use `ARG UID` and `ARG GID` for these values to take effect.
84
86
  - `uid`: User ID passed as the `UID` build arg.
@@ -107,6 +109,8 @@ The configuration file is **fixed as `deploy-config.json`**. If missing, the too
107
109
  "containerName": "string",
108
110
  "BindPorts": "string",
109
111
  "restart": "'no' | 'always' | 'unless-stopped' | 'on-failure'",
112
+ "afterLaunch": "string[]",
113
+ "customRunOptions": "string",
110
114
  "Options": {
111
115
  "permission": {
112
116
  "uid": "string",
@@ -141,6 +145,8 @@ The configuration file is **fixed as `deploy-config.json`**. If missing, the too
141
145
  "containerName": "my-app-container",
142
146
  "BindPorts": "80:80",
143
147
  "restart": "unless-stopped",
148
+ "afterLaunch": ["docker ps", "curl -f http://localhost/health"],
149
+ "customRunOptions": "npm run start:prod",
144
150
  "Options": {
145
151
  "permission": {
146
152
  "uid": "1000",
@@ -69,6 +69,15 @@ const configMethod = {
69
69
  },
70
70
  ],
71
71
  },
72
+ afterLaunch: {
73
+ type: 'input',
74
+ message: 'After launch (multiple commands separated by , ): ',
75
+ handleFn: (value) => value.split(','),
76
+ },
77
+ customRunOptions: {
78
+ type: 'input',
79
+ message: 'Custom run options (optional): eg: --env-file ./env.list',
80
+ },
72
81
  };
73
82
  const optionsMethod = {
74
83
  permission: {
@@ -211,6 +211,15 @@ export class Deploy {
211
211
  `);
212
212
  await this.buildDocker(ssh, IMAGE_TAG, REMOTEAPPPATH, TARGET_DIR, CONTAINER_NAME);
213
213
  await this.runDocker(ssh, CONTAINER_NAME);
214
+ if (this.config.afterLaunch && Array.isArray(this.config.afterLaunch)) {
215
+ await this.execCommand(ssh, {
216
+ startMsg: 'Start executing afterLaunch commands....',
217
+ succMsg: 'afterLaunch commands completed.',
218
+ }, `
219
+ cd "${REMOTEAPPPATH}/${CONTAINER_NAME}"
220
+ ${this.config.afterLaunch.join(' && ')}
221
+ `);
222
+ }
214
223
  log.done('✔ Deployment completed.');
215
224
  }
216
225
  catch {
@@ -315,7 +324,7 @@ export class Deploy {
315
324
  startMsg: `🐳 Start container: ${CONTAINER_NAME}...`,
316
325
  succMsg: `🐳 Container started successfully.`,
317
326
  }, `
318
- docker run -d ${optionsCLI}
327
+ docker run -d ${optionsCLI} ${this.config.customRunOptions || ''}
319
328
  `);
320
329
  }
321
330
  async judgeNetwork(ssh, networks) {
@@ -11,6 +11,7 @@ export type sshConfig = {
11
11
  containerName: string;
12
12
  BindPorts: string;
13
13
  restart?: 'no' | 'always' | 'on-failure' | 'unless-stopped';
14
+ afterLaunch?: string[];
14
15
  Options: {
15
16
  permission?: {
16
17
  gid?: string;
@@ -27,6 +28,7 @@ export type sshConfig = {
27
28
  };
28
29
  };
29
30
  };
31
+ customRunOptions?: string;
30
32
  };
31
33
  export type fileData = string | NodeJS.ArrayBufferView;
32
34
  import type { promises } from 'fs';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "auto-deploy-sh",
3
- "version": "2.1.4",
3
+ "version": "2.1.5",
4
4
  "description": "Automated Docker deployment tool",
5
5
  "bin": {
6
6
  "auto-deploy-sh": "./dist/cli/index.js"