4.1 KiB
Production deployment: warehouse-allocation.mvphub.ir
Current layout
| Item | Value |
|---|---|
| SSH host | ict |
| Public URL | https://warehouse-allocation.mvphub.ir |
| Release root | /srv/apps/warehouse-allocation |
| Current release | /srv/apps/warehouse-allocation/current |
| Shared environment | /srv/apps/warehouse-allocation/shared/.env |
| Compose project | warehouse-allocation |
| API loopback address | 127.0.0.1:18081 |
| Nginx site | /etc/nginx/sites-available/warehouse-allocation.mvphub.ir |
| Certificate | /etc/letsencrypt/live/warehouse-allocation.mvphub.ir |
| ACME webroot | /var/www/letsencrypt |
The API and Redis belong to a dedicated Compose project. Redis has no host port, and the API port is bound only to loopback. Public traffic can reach it only through the hostname-specific Nginx reverse proxy.
Status and logs
ssh ict
docker compose \
--env-file /srv/apps/warehouse-allocation/shared/.env \
-f /srv/apps/warehouse-allocation/current/deploy/compose.server.yaml \
ps
docker logs --tail 100 warehouse-allocation-api-1
docker logs --tail 100 warehouse-allocation-redis-1
curl -fsS http://127.0.0.1:18081/health/ready
curl -fsS https://warehouse-allocation.mvphub.ir/health/ready
nginx -t
Do not print or commit /srv/apps/warehouse-allocation/shared/.env. It contains the
inventory administration token.
Starting or reconciling the current release
docker compose \
--env-file /srv/apps/warehouse-allocation/shared/.env \
-f /srv/apps/warehouse-allocation/current/deploy/compose.server.yaml \
up -d --build
The production Compose file is
compose.server.yaml. It must be used instead of the local
root compose.yaml, because it provides the isolated loopback port, restart
policy, resource limits, persistent Redis volume, and production environment.
Safe release process
- Run tests and quality checks locally.
- Package tracked and required untracked source files without
.env,.git, or virtual environments. - Upload the archive to the server and verify its SHA-256 checksum.
- Extract it into a new immutable directory under
/srv/apps/warehouse-allocation/releases/<release-id>. - Validate the new Compose file using the shared environment.
- Point
/srv/apps/warehouse-allocation/currentat the new release. - Run Compose with
up -d --build. - Wait for both containers to become healthy.
- Verify loopback health, public HTTPS health, OpenAPI, and one allocation smoke test.
Never modify another application's Compose project, loopback port, Nginx site, or volume as part of this release.
Nginx and TLS
The repository contains:
nginx/warehouse-allocation.bootstrap.conffor initial HTTP/ACME validation;nginx/warehouse-allocation.mvphub.ir.conffor the final HTTP-to-HTTPS redirect and reverse proxy.
Always run nginx -t before systemctl reload nginx. A reload is graceful and
must only happen after the full server configuration passes validation.
The certificate uses Certbot's webroot authenticator. The existing
certbot.timer renews it automatically.
Rollback
Identify the prior release first:
find /srv/apps/warehouse-allocation/releases -mindepth 1 -maxdepth 1 -type d -print
readlink -f /srv/apps/warehouse-allocation/current
Point current at the explicit prior release, validate Compose, and start it:
ln -sfn /srv/apps/warehouse-allocation/releases/<prior-release-id> \
/srv/apps/warehouse-allocation/current
docker compose \
--env-file /srv/apps/warehouse-allocation/shared/.env \
-f /srv/apps/warehouse-allocation/current/deploy/compose.server.yaml \
config --quiet
docker compose \
--env-file /srv/apps/warehouse-allocation/shared/.env \
-f /srv/apps/warehouse-allocation/current/deploy/compose.server.yaml \
up -d --build
Then verify /health/ready on loopback and HTTPS. The Redis volume is deliberately
shared between releases, so rolling application code back does not discard
inventory data.