@akash-chowdhury-24/deployhub 2.0.39 → 2.0.41

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
@@ -765,7 +765,7 @@ SSH-based deploys (`ssh`, `ec2`, `azure-vm`, `gcp-vm`, and `docker` with `remote
765
765
 
766
766
  Commands run over the **existing** SSH session (not a second connection), unless a successful hook sets `"reconnect": true`. Kubernetes and Docker `local` / `raw` modes do not support hooks (no persistent remote shell session); configuring them there fails loudly at deploy/rollback.
767
767
 
768
- On docker-ssh, `postDeploy` runs **after** the port-publish inspect check (`docker inspect` confirms `0.0.0.0:<port>->`). A hook that curls the app's published port therefore sees a container DeployHub already treated as published. If that inspect fails, `postDeploy` does not run.
768
+ On docker-ssh, `preDeploy` / `rollback` run **before** remote registry login and `docker stop`/`run`, so a hook can install Docker on a bare host. `postDeploy` runs **after** the port-publish inspect check (`docker inspect` confirms `0.0.0.0:<port>->`). A hook that curls the app's published port therefore sees a container DeployHub already treated as published. If that inspect fails, `postDeploy` does not run.
769
769
 
770
770
  Hook `command` strings are raw remote shell — there is **no** `{{buildId}}` / `{{containerName}}` / `{{port}}` / `{{environment}}` substitution. Hardcode values per environment (or read them from the remote environment). Extra Docker environments use an env-scoped container name (`{project}-{env}`; the first/grandfathered env stays `{project}`), so a hook that `docker exec myapp …` on staging will miss `myapp-staging`.
771
771
 
@@ -830,6 +830,8 @@ sudo chown your-ssh-user:your-ssh-user /var/www/your-app-name
830
830
 
831
831
  Replace `/var/www/your-app-name` with your actual deploy path and `your-ssh-user` with your configured `SSH_USER` (e.g. `ec2-user` on Amazon Linux, `ubuntu` on Ubuntu). Without this, DeployHub cannot write your build output — `deployhub doctor` will catch it and show the exact fix.
832
832
 
833
+ **Manually placed files (`.env`, etc.):** SSH / EC2 / Azure VM / GCP VM redeploy and rollback do **not** wipe the deploy directory. Extraction uses `unzip -o` (fullstack: `rsync -a` with no `--delete`) so only files present in the artifact are added or overwritten; a `.env` you place on the server yourself is left untouched. Keep secrets out of the zip. Docker-SSH is container-based and does not use this directory extract.
834
+
833
835
  **Frontend deploys** that auto-activate `nginx.conf` also need **passwordless sudo** for Nginx test/reload (and `cp` into `/etc/nginx/`). After installing Nginx, run `sudo visudo` and add a line like:
834
836
 
835
837
  ```bash
@@ -853,6 +855,8 @@ sudo usermod -aG docker your-ssh-user
853
855
 
854
856
  Then **reconnect** (group membership applies on the next login). `deployhub doctor` reports this if missing (it prints the exact `usermod` line). See [Docker](#docker) below.
855
857
 
858
+ You can also put that bootstrap in **preDeploy hooks** on a bare host (install Docker, `usermod`, `"reconnect": true`). Registry login runs **after** preDeploy, so those hooks get a chance to install `docker` before `docker login`. Failed login used to abort first (`docker: command not found`) and skip the hooks.
859
+
856
860
  ### SSH
857
861
 
858
862
  **Verification:** Real-world verified DEPLOY and ROLLBACK.
@@ -902,7 +906,7 @@ Then **reconnect** (group membership applies on the next login). `deployhub doct
902
906
  - [ ] Docker installed (`docker --version` works) — on this machine / CI for **local** and **raw**; on the remote Linux host for **ssh**
903
907
  - [ ] Registry account if pushing private images
904
908
  - [ ] `docker-compose.yml` in project if you use multi-service Compose (not auto-generated)
905
- - [ ] **SSH mode only:** [one-time server setup](#one-time-server-setup-before-your-first-deploy) — Docker on the host and the SSH user in the `docker` group (`sudo usermod -aG docker <user>`, then reconnect)
909
+ - [ ] **SSH mode only:** [one-time server setup](#one-time-server-setup-before-your-first-deploy) — Docker on the host and the SSH user in the `docker` group (`sudo usermod -aG docker <user>`, then reconnect). A `preDeploy` hook can install Docker and run that `usermod` with `"reconnect": true`; registry login happens after preDeploy.
906
910
 
907
911
  `init` and `env add` ask **Where should the container run?**
908
912
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akash-chowdhury-24/deployhub",
3
- "version": "2.0.39",
3
+ "version": "2.0.41",
4
4
  "description": "Zero-configuration deployment and artifact manager",
5
5
  "type": "module",
6
6
  "main": "./src/cli/index.js",
@@ -167,6 +167,13 @@ export function createDockerProvider(config, envName, env = process.env) {
167
167
  const registryToken = imageEnv.DOCKER_REGISTRY_TOKEN || '';
168
168
  const registryUrl = imageEnv.DOCKER_REGISTRY_URL || '';
169
169
 
170
+ ssh = await runDeployHooks({
171
+ session,
172
+ ssh,
173
+ settings,
174
+ stage: isRollback ? 'rollback' : 'preDeploy',
175
+ });
176
+
170
177
  if (registryUser && registryToken) {
171
178
  const registry = registryUrl || 'https://index.docker.io/v1/';
172
179
  log.info('Logging in to container registry on remote host...');
@@ -177,13 +184,6 @@ export function createDockerProvider(config, envName, env = process.env) {
177
184
  );
178
185
  }
179
186
 
180
- ssh = await runDeployHooks({
181
- session,
182
- ssh,
183
- settings,
184
- stage: isRollback ? 'rollback' : 'preDeploy',
185
- });
186
-
187
187
  await session.exec(ssh, cmds.stop);
188
188
  await session.exec(ssh, cmds.rm);
189
189
  await session.exec(ssh, cmds.pull, {