Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions studio/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ LABEL org.visualtext.nlp-studio="${NLP_STUDIO_COMMIT}" \
org.visualtext.built-at="${BUILD_DATE}"

USER studio
EXPOSE 3001
EXPOSE 3002

# Loopback only: nginx in front holds the password. See studio/deploy/INSTALL.md.
CMD ["python", "server/app.py", "--host", "127.0.0.1", "--port", "3001", "--dist", "dist"]
CMD ["python", "server/app.py", "--host", "127.0.0.1", "--port", "3002", "--dist", "dist"]
18 changes: 11 additions & 7 deletions studio/deploy/INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ second container beside the phase-1 editor, on the same host name.

```
nginx :443
├── /studio/ -> 127.0.0.1:3001 nlp-studio-app (this directory)
├── /studio/ -> 127.0.0.1:3002 nlp-studio-app (this directory)
│ the site's password, or GitHub sign-in (nginx-app-*.conf)
└── / -> 127.0.0.1:3000 nlp-studio (stopgap/, the site's password)
```
Expand Down Expand Up @@ -60,19 +60,23 @@ starting anything it runs [smoke-test.sh](smoke-test.sh) on port 3998, under the
restrictions as the live container: the sample analyzer must run to its known output,
`system()` must be refused, and a run must fail to write outside `/tmp`. Then:

curl -s http://127.0.0.1:3001/api/health
curl -s http://127.0.0.1:3002/api/health
# {"ok": true, "engine": "2.2.38", ..., "signIn": false, "github": false}

Nothing is public yet: the container listens on loopback only.

The container runs with `network_mode: host`, so port 3001 has to be free before it
The container runs with `network_mode: host`, so port 3002 has to be free before it
starts — nothing warns you if another service already answers there, and the health
check above would be that service's answer rather than the studio's. Check first:

ss -ltnp | grep ':3001 ' || echo "3001 is free"
ss -ltnp | grep ':3002 ' || echo "3002 is free"

If something else holds it, give the app another port in `docker-compose.yml` (the
`--port` in its `command`) and in the nginx `proxy_pass`; the two must agree.
`--port` in its `command`), `update.sh` (`HEALTH_URL`) and the nginx `proxy_pass`; they
must agree.

It was 3001 until another account on this host started a service there, bound to every
interface. That service is not this deployment's to move, so the app moved to 3002.

### 3. Route /studio/ in nginx, behind the password — as root

Expand Down Expand Up @@ -164,7 +168,7 @@ all the sign-in settings are there.
### 4. Restart the app with them — as visualtext

docker compose -f /home/visualtext/nlp-studio/studio/deploy/docker-compose.yml up -d
curl -s http://127.0.0.1:3001/api/health
curl -s http://127.0.0.1:3002/api/health
# ..., "signIn": true, "github": true}

`"signIn": true` is the only answer to go on with. If the container is not running, its
Expand Down Expand Up @@ -277,7 +281,7 @@ Logs go to `stopgap/logs/update-app-YYYY-MM.log`.

docker image inspect nlp-studio:app --format '{{json .Config.Labels}}'
docker logs --tail 50 nlp-studio-app
curl -s http://127.0.0.1:3001/api/health
curl -s http://127.0.0.1:3002/api/health

## Rolling back

Expand Down
2 changes: 1 addition & 1 deletion studio/deploy/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ services:
# ports other than 80, so a published port connects and then resets. The cost
# is that this container is not network-isolated; see INSTALL.md.
network_mode: host
command: ["python", "server/app.py", "--host", "127.0.0.1", "--port", "3001", "--dist", "dist",
command: ["python", "server/app.py", "--host", "127.0.0.1", "--port", "3002", "--dist", "dist",
"--max-runs", "2", "--timeout", "10"]

# GitHub sign-in (INSTALL.md, "Switching to GitHub sign-in"). The values come from
Expand Down
4 changes: 2 additions & 2 deletions studio/deploy/nginx-app-password.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# studio.visualtext.org/studio/ -> the NLP Studio app (127.0.0.1:3001), behind the
# studio.visualtext.org/studio/ -> the NLP Studio app (127.0.0.1:3002), behind the
# site's password. See INSTALL.md.
#
# Install as root beside the phase-1 file, in the same directory:
Expand All @@ -24,7 +24,7 @@ location ^~ /studio/ {
auth_basic_user_file /home/visualtext/.htpasswd-studio;

# The trailing slash strips /studio/: the app serves itself at its root.
proxy_pass http://127.0.0.1:3001/;
proxy_pass http://127.0.0.1:3002/;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
Expand Down
4 changes: 2 additions & 2 deletions studio/deploy/nginx-app-signin.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# studio.visualtext.org/studio/ -> the NLP Studio app (127.0.0.1:3001), with GitHub
# studio.visualtext.org/studio/ -> the NLP Studio app (127.0.0.1:3002), with GitHub
# sign-in instead of the site's password. See INSTALL.md, "Switching to GitHub sign-in".
#
# Install as root beside the phase-1 file, in the same directory:
Expand All @@ -25,7 +25,7 @@ location = /studio {

location ^~ /studio/ {
# The trailing slash strips /studio/: the app serves itself at its root.
proxy_pass http://127.0.0.1:3001/;
proxy_pass http://127.0.0.1:3002/;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
Expand Down
2 changes: 1 addition & 1 deletion studio/deploy/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ IMAGE_LIVE="nlp-studio:app"
IMAGE_PREV="nlp-studio:app-previous"
IMAGE_NEW="nlp-studio:app-candidate"
SERVICE="nlp-studio-app"
HEALTH_URL="http://127.0.0.1:3001/api/health"
HEALTH_URL="http://127.0.0.1:3002/api/health"
LOG_DIR="${NLP_STUDIO_LOG_DIR:-$REPO/stopgap/logs}"
LOG_KEEP_DAYS=30

Expand Down
Loading