auto-deploy-sh 2.1.0 → 2.1.1

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
@@ -73,7 +73,7 @@ The configuration file is **fixed as `deploy-config.json`**. If missing, the too
73
73
  - `dockerBuildFiles`: Files/directories to include in the Docker build context (required for Dockerfile execution).
74
74
  - `imageTag`: Docker image tag, formatted as `[registry-url/][username/project-name]:[tag]` (e.g., `my-registry.com/user/my-app:v1.0`).
75
75
  - `containerName`: Unique name for the running container (ensures no conflicts with existing containers).
76
- - `BindPorts`: Port mapping, formatted as `<host-port>:<container-port>` (e.g., `"8080:80"`).
76
+ - `BindPorts` (optional): Port mapping, formatted as `<host-port>:<container-port>` (e.g., `"8080:80"`).
77
77
  - `restart` (optional): Container restart policy, controls how Docker handles container restarts. The following options are supported:
78
78
  - `no`(default): The container **will not restart automatically after it exits**. It will also remain stopped after Docker or system restarts. Suitable for one-off tasks or debugging scenarios.
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.
@@ -186,6 +186,9 @@ export class Deploy {
186
186
  const REMOTE_PATH = this.remotePath;
187
187
  const IMAGE_TAG = this.config.imageTag;
188
188
  const TARGET_DIR = `./${CONTAINER_NAME}`;
189
+ if (typeof this.config.Options?.networks === 'string') {
190
+ this.config.Options.networks = [this.config.Options.networks];
191
+ }
189
192
  const networks = this.config.Options?.networks || [];
190
193
  if (networks.length > 0) {
191
194
  await this.judgeNetwork(ssh, networks);
@@ -238,7 +241,7 @@ export class Deploy {
238
241
  `);
239
242
  }
240
243
  async runDocker(ssh, CONTAINER_NAME) {
241
- let optionsCLI = `--name ${CONTAINER_NAME} -p ${this.config.BindPorts}`;
244
+ let optionsCLI = `--name ${CONTAINER_NAME}${this.config.BindPorts ? ` -p ${this.config.BindPorts}` : ''}`;
242
245
  if (this.config.restart) {
243
246
  optionsCLI += ` --restart ${this.config.restart}`;
244
247
  }
package/dist/bin/index.js CHANGED
@@ -9,7 +9,7 @@ export async function deploySSH(configFile = 'deploy-config.json') {
9
9
  const CONFIG_FILE_PATH = path.resolve(process.cwd(), CONFIG_FILE);
10
10
  if (await fs.exist(CONFIG_FILE_PATH)) {
11
11
  let config = JSON.parse((await fs.readDirOrFile(CONFIG_FILE_PATH, { encoding: 'utf-8' })));
12
- if (!config.BindPorts.includes(':')) {
12
+ if (config.BindPorts && !config.BindPorts.includes(':')) {
13
13
  log.error('Config BindPorts do not meet the standard');
14
14
  exit(1);
15
15
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "auto-deploy-sh",
3
- "version": "2.1.0",
3
+ "version": "2.1.1",
4
4
  "description": "Automated Docker deployment tool",
5
5
  "bin": {
6
6
  "auto-deploy-sh": "./dist/cli/index.js"