Skip to content

Commit abafb13

Browse files
committed
Make smoke test resolve mapped port via inspect
1 parent 61c5260 commit abafb13

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

.github/workflows/docker-publish.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,20 @@ jobs:
6767
set -euo pipefail
6868
cid=$(docker run -d -p 0:3000 "$IMAGE_UNDER_TEST")
6969
trap "docker rm -f $cid >/dev/null 2>&1" EXIT
70-
port=$(docker port "$cid" 3000/tcp | sed -E 's/.*:([0-9]+)$/\1/')
70+
port=$(docker inspect -f '{{ (index (index .NetworkSettings.Ports "3000/tcp") 0).HostPort }}' "$cid")
71+
if [ -z "$port" ]; then
72+
echo "Failed to resolve mapped port for container $cid" >&2
73+
docker logs "$cid" || true
74+
exit 1
75+
fi
7176
for i in {1..20}; do
7277
if curl -fsS "http://127.0.0.1:${port}/" > /dev/null; then
7378
exit 0
7479
fi
7580
sleep 1
7681
done
7782
echo "Service did not respond on / after 20s" >&2
83+
docker logs "$cid" || true
7884
exit 1
7985
8086
- name: Log in to GHCR

0 commit comments

Comments
 (0)