auto-deploy-sh 2.1.2 → 2.1.4

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
@@ -80,6 +80,9 @@ The configuration file is **fixed as `deploy-config.json`**. If missing, the too
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
82
  - `Options`: **Optional** advanced settings (all sub-properties are optional)
83
+ - `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
+ - `uid`: User ID passed as the `UID` build arg.
85
+ - `gid`: Group ID passed as the `GID` build arg.
83
86
  - `volumes`: Volume mappings (array of strings), formatted as `[host-path/volume-name]:[container-path]:[optional-flags]` (e.g., `["/host/data:/container/data:ro"]`).
84
87
  - `networks`: Connect the container to a custom Docker network (created via `docker network create <network-name>`) for inter-container communication.
85
88
  - `logging`: Docker log management configuration. During deployment, it is converted to Docker `--log-driver` and `--log-opt` arguments. Before starting the container, the tool checks the logging drivers supported by the remote Docker daemon. If the configured `driver` is not supported, deployment stops and prints the current default driver and supported driver list.
@@ -105,6 +108,10 @@ The configuration file is **fixed as `deploy-config.json`**. If missing, the too
105
108
  "BindPorts": "string",
106
109
  "restart": "'no' | 'always' | 'unless-stopped' | 'on-failure'",
107
110
  "Options": {
111
+ "permission": {
112
+ "uid": "string",
113
+ "gid": "string"
114
+ },
108
115
  "volumes": "string[]",
109
116
  "networks": "string[]",
110
117
  "logging": {
@@ -135,6 +142,10 @@ The configuration file is **fixed as `deploy-config.json`**. If missing, the too
135
142
  "BindPorts": "80:80",
136
143
  "restart": "unless-stopped",
137
144
  "Options": {
145
+ "permission": {
146
+ "uid": "1000",
147
+ "gid": "1000"
148
+ },
138
149
  "volumes": ["/host/logs:/app/logs:rw"],
139
150
  "networks": ["my-custom-network", "my-custom-network-1"],
140
151
  "logging": {
@@ -71,6 +71,31 @@ const configMethod = {
71
71
  },
72
72
  };
73
73
  const optionsMethod = {
74
+ permission: {
75
+ type: 'confirm',
76
+ message: 'Do you want to set the container user permissions?',
77
+ default: false,
78
+ handleFn: async (value) => {
79
+ if (!value)
80
+ return {};
81
+ const gid = await inquirer.invoke({
82
+ type: 'input',
83
+ message: 'GID (Group ID): ',
84
+ });
85
+ const uid = await inquirer.invoke({
86
+ type: 'input',
87
+ message: 'UID (User ID): ',
88
+ });
89
+ if (!gid && !uid)
90
+ return {};
91
+ const options = {};
92
+ if (gid)
93
+ options.gid = gid;
94
+ if (uid)
95
+ options.uid = uid;
96
+ return options;
97
+ },
98
+ },
74
99
  volumes: {
75
100
  type: 'input',
76
101
  message: 'Multiple volumes are divided into by , : ',
@@ -221,12 +221,18 @@ export class Deploy {
221
221
  }
222
222
  }
223
223
  async buildDocker(ssh, IMAGE_TAG, REMOTEAPPPATH, TARGET_DIR, CONTAINER_NAME) {
224
+ const options = this.config.Options || {};
225
+ const gid = options.permission?.gid || '';
226
+ const uid = options.permission?.uid || '';
227
+ const buildArgs = [uid ? `--build-arg UID=${uid}` : '', gid ? `--build-arg GID=${gid}` : '']
228
+ .filter(Boolean)
229
+ .join(' ');
224
230
  await this.execCommand(ssh, {
225
231
  startMsg: `🐳 Build image: ${IMAGE_TAG}...`,
226
232
  succMsg: `🐳 Build image: ${IMAGE_TAG} success.`,
227
233
  }, `
228
234
  cd "${REMOTEAPPPATH}"
229
- docker build -t ${IMAGE_TAG} ${TARGET_DIR}
235
+ docker build ${buildArgs} -t ${IMAGE_TAG} ${TARGET_DIR}
230
236
  `);
231
237
  await this.execCommand(ssh, {
232
238
  startMsg: `🔄 Stop and clean the old container.: ${CONTAINER_NAME}...`,
package/dist/bin/index.js CHANGED
@@ -35,7 +35,7 @@ export async function deploySSH(configFile = 'deploy-config.json') {
35
35
  catch {
36
36
  }
37
37
  finally {
38
- fs.removeSync(path.resolve(process.cwd(), deploy.uploadFileName));
38
+ await fs.remove(path.resolve(process.cwd(), deploy.uploadFileName));
39
39
  ssh.dispose();
40
40
  exit(1);
41
41
  }
@@ -12,6 +12,10 @@ export type sshConfig = {
12
12
  BindPorts: string;
13
13
  restart?: 'no' | 'always' | 'on-failure' | 'unless-stopped';
14
14
  Options: {
15
+ permission?: {
16
+ gid?: string;
17
+ uid?: string;
18
+ };
15
19
  volumes: string[];
16
20
  networks: string[];
17
21
  logging: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "auto-deploy-sh",
3
- "version": "2.1.2",
3
+ "version": "2.1.4",
4
4
  "description": "Automated Docker deployment tool",
5
5
  "bin": {
6
6
  "auto-deploy-sh": "./dist/cli/index.js"