Skip to content

Commit f132120

Browse files
committed
Add container timeout to prevent dangling containers
1 parent bdc3e34 commit f132120

File tree

4 files changed

+24
-7
lines changed

4 files changed

+24
-7
lines changed

Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,10 @@ WORKDIR /var/www/html
113113

114114
EXPOSE 22 80 3306 9200
115115

116+
ENV CONTAINER_TIMEOUT=1h
117+
116118
ENTRYPOINT ["/sbin/multirun"]
117119

118-
CMD ["/usr/sbin/start-elasticsearch", "/usr/sbin/start-mysql"]
120+
CMD ["/usr/sbin/start-elasticsearch", "/usr/sbin/start-mysql", "/usr/bin/container-timeout"]
119121

120122
HEALTHCHECK --timeout=10s --interval=10s --start-period=10s CMD /usr/bin/healthcheck

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77

88
Please see the docker hub repo page [mageops/magento-run-tests](https://hub.docker.com/r/mageops/magento-run-tests).
99

10+
# Container timeout
11+
Container will by default exit after 1h to prevent dangling container in CI environments,
12+
you can adjust this behavior by changing setting different `CONTAINER_TIMEOUT` environment variable.
13+
Setting `CONTAINER_TIMEOUT` to `no` will disable that behavior completely.
14+
1015
## Docker tags and software versions
1116

1217
The `master` branch uses Maria DB 10.2, Elasticsearch 6 and PHP 7.2 which are the latest versions supported by Magento.

docker-compose.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
version: "2.3"
22
services:
33
tests:
4-
image: magesuite/run-tests:stable
4+
build: .
55
environment:
66
- DB_USER=magento2
77
- DB_PASS=magento2
88
- DB_NAME=magento2_integration_tests
9+
- CONTAINER_TIMEOUT=30s
910
volumes:
10-
- type: bind
11-
source: '${PWD}'
12-
target: /var/www/html
1311
- type: tmpfs
1412
target: /tmp:rw,exec
1513
volume:
@@ -34,5 +32,3 @@ services:
3432
target: /dev/tests/integration/tmp
3533
volume:
3634
nocopy: true
37-
38-

rootfs/usr/bin/container-timeout

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
set -auo pipefail
4+
5+
if [ "${CONTAINER_TIMEOUT:-}" == "no" ];then
6+
echo "Container timeout disabled"
7+
while true;do
8+
sleep 1h
9+
done
10+
fi
11+
12+
sleep "${CONTAINER_TIMEOUT:-1h}"
13+
echo "Container timeout reached, exiting"
14+
exit 1

0 commit comments

Comments
 (0)