Skip to content

Commit edde78d

Browse files
Milan Majchrákclaude
andcommitted
ci(deploy): stop inheriting vanilla's fixed host ports (5432/8080/8983/4000)
Root cause of 'Bind for 0.0.0.0:5432 failed: port is already allocated' on 8603, proven by 'docker compose config' on dev-6: dspacedb (container_name: dspacedb8603) ports: target: 5432, published: "5432" <- vanilla docker-compose-rest.yml target: 5432, published: "10603" <- /opt/dspace-envs/8603 overlay Compose MERGES ports lists across -f files instead of replacing them, so the per-instance overlay adds 10603 but still inherits vanilla's fixed 5432. Those fixed ports are global to the dev host, so only one instance can own them -- dev-6 currently has customer/jcu holding 0.0.0.0:5432, :8080 and :8983, and customer/mendelu holding :4000, so 8603 could never bind them. Add docker/docker-compose-instance-ports.yml, which resets ports to [] between the vanilla files and the instance overlay; the overlay then supplies the real instance-scoped ports (10603/6603/11603/4603 for 8603). This keeps the fix in git rather than requiring /opt/dspace-envs/8603/docker-compose.yml to be patched on the machine -- mendelu and sav solve the same problem there with 'ports: !override', which is why they publish only 127.0.0.1:105xx. start.sh took the same treatment: it ran compose with the vanilla files ONLY, so its 'up' collided too. It now honours INSTANCE_OVERLAY. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 454df29 commit edde78d

3 files changed

Lines changed: 43 additions & 7 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,16 +91,18 @@ jobs:
9191
9292
- name: resolved compose ports for this instance
9393
run: |
94-
echo "===== merged compose config (dspacedb ports) for -p dspace-$INSTANCE"
94+
echo "===== ports WITH the instance-ports reset (this is what deploy actually uses)"
9595
docker compose --env-file "$ENVFILE" -p dspace-$INSTANCE \
9696
-f docker/docker-compose.yml -f docker/docker-compose-rest.yml \
97+
-f docker/docker-compose-instance-ports.yml \
9798
-f "$CONFIG_PATH/docker-compose-rest.yml" -f "$CONFIG_PATH/docker-compose.yml" \
98-
config 2>&1 | grep -nE '^ [a-z-]+:|container_name:|published:|target:|^\s+ports:' | head -60 \
99+
config 2>&1 | grep -nE '^ [a-z-]+:|container_name:|published:|^\s+ports:' | head -40 \
99100
|| echo "compose config failed"
100-
echo "===== what start.sh alone would publish (NO instance overlay)"
101+
echo "===== ports WITHOUT the reset (the vanilla fixed ports we are dropping)"
101102
docker compose --env-file "$ENVFILE" -p dspace-$INSTANCE \
102103
-f docker/docker-compose.yml -f docker/docker-compose-rest.yml \
103-
config 2>&1 | grep -nE '^ [a-z-]+:|container_name:|published:|target:|^\s+ports:' | head -40 \
104+
-f "$CONFIG_PATH/docker-compose-rest.yml" -f "$CONFIG_PATH/docker-compose.yml" \
105+
config 2>&1 | grep -nE '^ [a-z-]+:|container_name:|published:|^\s+ports:' | head -40 \
104106
|| echo "compose config failed"
105107
106108
- name: postgres inside the instance db container
@@ -133,10 +135,11 @@ jobs:
133135
env:
134136
ADMIN_PASSWORD: ${{ secrets.DSPACE_ADMIN_PASSWORD }}
135137
USER_PASSWORD: ${{ secrets.DSPACE_USER_PASSWORD }}
138+
INSTANCE_OVERLAY: ${{ env.CONFIG_PATH }}
136139
run: |
137140
./start.sh dspace-$INSTANCE
138141
cd ../..
139-
docker compose --env-file $ENVFILE -p dspace-$INSTANCE -f docker/docker-compose.yml -f docker/docker-compose-rest.yml -f $CONFIG_PATH/docker-compose-rest.yml -f $CONFIG_PATH/docker-compose.yml up -d --no-build --remove-orphans
142+
docker compose --env-file $ENVFILE -p dspace-$INSTANCE -f docker/docker-compose.yml -f docker/docker-compose-rest.yml -f docker/docker-compose-instance-ports.yml -f $CONFIG_PATH/docker-compose-rest.yml -f $CONFIG_PATH/docker-compose.yml up -d --no-build --remove-orphans
140143
141144
import-8603:
142145
runs-on: dspace-${{inputs.DEV_MACHINE}}-dep-1
@@ -201,6 +204,7 @@ jobs:
201204
echo "Running one-off DB migration via docker compose..."
202205
docker compose --env-file $ENVFILE -p dspace-${INSTANCE} \
203206
-f docker/docker-compose.yml -f docker/docker-compose-rest.yml \
207+
-f docker/docker-compose-instance-ports.yml \
204208
-f $OVERLAY/docker-compose-rest.yml -f $OVERLAY/docker-compose.yml \
205209
run --rm --no-deps --entrypoint /bin/bash dspace \
206210
-c "while (!</dev/tcp/dspacedb/5432) >/dev/null 2>&1; do sleep 1; done; cd /dspace/bin && ./dspace database migrate ignored"

build-scripts/run/start.sh

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,25 @@ echo "Using envfile: [$ENVFILE] for project: [$PROJECT]"
1010

1111
source $ENVFILE
1212

13+
# The vanilla compose files publish fixed host ports (5432/8080/8983/4000), which are global
14+
# to the machine. When INSTANCE_OVERLAY points at /opt/dspace-envs/<instance>, bring the
15+
# containers up through that overlay instead, with docker-compose-instance-ports.yml resetting
16+
# the fixed ports first -- otherwise this `up` fights whichever instance already owns them.
17+
COMPOSE_FILES="-f docker/docker-compose.yml -f docker/docker-compose-rest.yml"
18+
if [[ -n "$INSTANCE_OVERLAY" ]]; then
19+
COMPOSE_FILES="$COMPOSE_FILES -f docker/docker-compose-instance-ports.yml -f $INSTANCE_OVERLAY/docker-compose-rest.yml -f $INSTANCE_OVERLAY/docker-compose.yml"
20+
echo "Using instance overlay: [$INSTANCE_OVERLAY]"
21+
fi
22+
echo "Compose files: [$COMPOSE_FILES]"
23+
1324
# docker-compose does not pull those that have `build` section?!
1425
echo "====="
1526
docker pull $DSPACE_UI_IMAGE
1627

1728
pushd ../..
1829
echo "====="
19-
docker compose --env-file $ENVFILE -f docker/docker-compose.yml -f docker/docker-compose-rest.yml pull
20-
docker compose --env-file $ENVFILE -p $PROJECT -f docker/docker-compose.yml -f docker/docker-compose-rest.yml up -d --no-build --remove-orphans
30+
docker compose --env-file $ENVFILE $COMPOSE_FILES pull
31+
docker compose --env-file $ENVFILE -p $PROJECT $COMPOSE_FILES up -d --no-build --remove-orphans
2132
popd
2233

2334
# Create admin user
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Drop the FIXED host ports that the vanilla docker-compose.yml / docker-compose-rest.yml
2+
# publish (dspace 8080, dspace-angular 4000+9876, dspacedb 5432, dspacesolr 8983).
3+
#
4+
# Those are global to the machine, so on a shared dev host only ONE instance can ever own
5+
# them: the second instance to deploy dies with
6+
# "Bind for 0.0.0.0:5432 failed: port is already allocated".
7+
# Compose MERGES `ports` lists across -f files rather than replacing them, so a per-instance
8+
# overlay that only adds its own ports still inherits the fixed ones.
9+
#
10+
# Include this file AFTER the vanilla compose files and BEFORE the per-instance overlay in
11+
# /opt/dspace-envs/<instance>/: it resets the list, and the overlay then contributes the real
12+
# instance-scoped ports (e.g. 10603->5432).
13+
services:
14+
dspace:
15+
ports: !override []
16+
dspace-angular:
17+
ports: !override []
18+
dspacedb:
19+
ports: !override []
20+
dspacesolr:
21+
ports: !override []

0 commit comments

Comments
 (0)