Cargo-safety - Intelligence Service Update Guide
Intelligence Service Update Guide
This guide explains how to update the intelligence service on the Cargo Safety GCP instances (nightly and stable environments).
Prerequisites
gcloudCLI installed and authenticated- Access to the
attracs-logistics-nightly-6519andattracs-logisticsGCP projects - Local copy of the
intelligencesource codeNote on usernames: all commands in this guide use
janomonjeas the remote user and/home/janomonje/...as the home path. Replace it with whatever user account exists on the target instance for your setup (for example, some stable instances usejaani). The same applies to the local source paths — adjust them to match where your working copy lives.
Environments
| Environment | Project | Instances | Source path (local) |
|---|---|---|---|
| Nightly | attracs-logistics-nightly-6519 |
road-confidential-instance-nightly-1 (europe-north1-a), road-confidential-instance-nightly-2 (europe-north1-b) |
/home/janomonje/devOps/cargo-safety/app/server/intelligence/ |
| Stable | attracs-logistics |
road-confidential-instance-stable-1, road-confidential-instance-stable-2 |
/home/janomonje/projects/cargo-safety/app/server/intelligence/ |
Step 1 — Copy the new code to the instances
All transfers use --tunnel-through-iap (IAP tunneling) for secure access.
Nightly
gcloud compute scp --recurse /home/janomonje/devOps/cargo-safety/app/server/intelligence/ \
road-confidential-instance-nightly-1:/home/janomonje/ \
--project=attracs-logistics-nightly-6519 \
--zone=europe-north1-a \
--tunnel-through-iap
gcloud compute scp --recurse /home/janomonje/devOps/cargo-safety/app/server/intelligence/ \
road-confidential-instance-nightly-2:/home/janomonje/ \
--project=attracs-logistics-nightly-6519 \
--zone=europe-north1-b \
--tunnel-through-iap
Stable
gcloud compute scp --recurse /home/janomonje/projects/cargo-safety/app/server/intelligence/ \
road-confidential-instance-stable-1:/home/janomonje/ \
--project=attracs-logistics \
--tunnel-through-iap \
--zone=europe-north1-a
gcloud compute scp --recurse /home/janomonje/projects/cargo-safety/app/server/intelligence/ \
road-confidential-instance-stable-2:/home/janomonje/ \
--project=attracs-logistics \
--tunnel-through-iap \
--zone=europe-north1-a
Step 2 — SSH into the instance
Nightly
gcloud compute ssh road-confidential-instance-nightly-1 \
--project=attracs-logistics-nightly-6519 \
--tunnel-through-iap \
--zone=europe-north1-a
gcloud compute ssh road-confidential-instance-nightly-2 \
--project=attracs-logistics-nightly-6519 \
--tunnel-through-iap \
--zone=europe-north1-b
Stable
gcloud compute ssh road-confidential-instance-stable-1 \
--project=attracs-logistics \
--tunnel-through-iap
gcloud compute ssh road-confidential-instance-stable-2 \
--project=attracs-logistics \
--tunnel-through-iap
Repeat steps 3–6 on each instance.
Step 3 — Stop the application via Supervisor
Shut down the running application from the supervisor UI / CLI before touching Docker so that supervisor does not try to restart it mid-update.
Step 4 — Update the Docker container
Navigate to the intelligence folder on the instance:
cd /etc/docker-cargo-safety/intelligence/
Bring the stack down and remove volumes:
docker compose down -v
Remove the old image so the next up rebuilds it:
docker image rm intelligence-intelligence
Copy the freshly uploaded code into the application directory:
cp -r /home/janomonje/intelligence /etc/docker-cargo-safety/
Recreate and start the containers:
docker compose up -d --force-recreate
Step 5 — Verify
Check that the container is running:
sudo docker ps -a
Tail the logs to confirm a clean startup:
sudo docker logs -f intelligence-intelligence-1
Step 6 — Optional cleanup
Reclaim disk space by clearing unused Docker data:
sudo docker system prune
Appendix — Supervisor configuration
The application is managed by Supervisor with the following program definition (kept here for reference; do not edit unless you know what you're doing):
[program:cargo-safety.attracs.com]
command=/bin/bash /etc/attracs-supervisor/run-process.sh \
-p cargo-safety-0.1.0.tar.gz \
-w app/server \
-x server \
-a -production \
-port 4136 \
-log-level debug \
-debug-database \
-reverse-proxy-host https://cargo-safety.attracs.com \
-config /etc/cargo-safety/attracs.yml
directory=/home/syncthing/attracs-builds/cargo-safety/releases/0.1.0
startsecs=5
autorestart=true
Quick checklist
- SCP code to both instances in the target environment
- SSH into instance 1
- Stop application in Supervisor
docker compose down -vin/etc/docker-cargo-safety/intelligence/- Remove old image
- Copy new code into
/etc/docker-cargo-safety/ docker compose up -d --force-recreate- Verify with
docker ps -aanddocker logs -f - Repeat on instance 2