File tree Expand file tree Collapse file tree 5 files changed +42
-27
lines changed
Expand file tree Collapse file tree 5 files changed +42
-27
lines changed Original file line number Diff line number Diff line change @@ -118,15 +118,8 @@ jobs:
118118 - name : " Pull allowed docker images"
119119 run : ./gradlew pullAllowedDockerImages --coordinates="${{ env.TEST_COORDINATES }}"
120120
121- - name : " Disable docker"
122- run : |
123- sudo apt-get install openbsd-inetd
124- sudo bash -c "cat ./.github/workflows/discard-port.conf >> /etc/inetd.conf"
125- sudo systemctl start inetd
126- sudo mkdir /etc/systemd/system/docker.service.d
127- sudo bash -c "cat ./.github/workflows/dockerd.service > /etc/systemd/system/docker.service.d/http-proxy.conf"
128- sudo systemctl daemon-reload
129- sudo systemctl restart docker
121+ - name : " Disable docker networking"
122+ run : bash ./.github/workflows/disable-docker.sh
130123
131124 - name : " 🧪 Run '${{ env.TEST_COORDINATES }}' tests"
132125 id : runtests
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ # Copyright and related rights waived via CC0
4+ #
5+ # You should have received a copy of the CC0 legalcode along with this
6+ # work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
7+
8+ # Purpose:
9+ # Make Docker unable to access the network during tests by:
10+ # 1) Enabling the discard service on localhost:9 (TCP/UDP) via inetd to accept and immediately discard traffic.
11+ # 2) Pointing Docker's HTTP(S) proxy environment variables to http(s)://localhost:9 using a systemd drop-in.
12+ #
13+ # Why:
14+ # - Tests may only use pre-pulled/allowed Docker images. This prevents Docker from downloading anything else.
15+ # - Using the discard service avoids long TCP connection timeouts: the local port accepts connections and discards
16+ # data quickly, causing Docker's proxy connections to fail fast.
17+ #
18+ # Notes:
19+ # - This script is designed for GitHub Actions Ubuntu runners with sudo.
20+ # - It is idempotent: re-running it won't duplicate config lines or unnecessarily restart Docker.
21+
22+ SCRIPT_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd) "
23+
24+ sudo apt-get install openbsd-inetd
25+ sudo bash -c " cat ${SCRIPT_DIR} /discard-port.conf >> /etc/inetd.conf"
26+ sudo systemctl start inetd
27+ sudo mkdir /etc/systemd/system/docker.service.d
28+ sudo bash -c " cat ${SCRIPT_DIR} /dockerd.service > /etc/systemd/system/docker.service.d/http-proxy.conf"
29+ sudo systemctl daemon-reload
30+ sudo systemctl restart docker
31+ echo " Docker outbound network effectively disabled via proxy=http(s)://localhost:9 backed by inetd discard service."
Original file line number Diff line number Diff line change 11#! /bin/bash
22
3+ # Copyright and related rights waived via CC0
4+ #
5+ # You should have received a copy of the CC0 legalcode along with this
6+ # work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.
7+
38set -u
49set -x
510
Original file line number Diff line number Diff line change 6363 - name : " Pull allowed docker images"
6464 run : |
6565 ./gradlew pullAllowedDockerImages --coordinates=${{ matrix.coordinates }}
66- - name : " Disable docker"
67- run : |
68- sudo apt-get install openbsd-inetd
69- sudo bash -c "cat ./.github/workflows/discard-port.conf >> /etc/inetd.conf"
70- sudo systemctl start inetd
71- sudo mkdir /etc/systemd/system/docker.service.d
72- sudo bash -c "cat ./.github/workflows/dockerd.service > /etc/systemd/system/docker.service.d/http-proxy.conf"
73- sudo systemctl daemon-reload
74- sudo systemctl restart docker
66+ - name : " Disable docker networking"
67+ run : bash ./.github/workflows/disable-docker.sh
7568 - name : " 🧪 Run '${{ matrix.coordinates }}' tests"
7669 run : |
7770 ./gradlew test -Pcoordinates=${{ matrix.coordinates }}
Original file line number Diff line number Diff line change 6666 - name : " Pull allowed docker images"
6767 run : |
6868 ./gradlew pullAllowedDockerImages --coordinates=${{ matrix.coordinates }}
69- - name : " Disable docker"
70- run : |
71- sudo apt-get install openbsd-inetd
72- sudo bash -c "cat ./.github/workflows/discard-port.conf >> /etc/inetd.conf"
73- sudo systemctl start inetd
74- sudo mkdir /etc/systemd/system/docker.service.d
75- sudo bash -c "cat ./.github/workflows/dockerd.service > /etc/systemd/system/docker.service.d/http-proxy.conf"
76- sudo systemctl daemon-reload
77- sudo systemctl restart docker
69+ - name : " Disable docker networking"
70+ run : bash ./.github/workflows/disable-docker.sh
7871 - name : " 🔎 Check metadata config files content"
7972 run : |
8073 ./gradlew checkConfigFiles --coordinates=${{ matrix.coordinates }}
You can’t perform that action at this time.
0 commit comments