Use environment variables to replace the hard-code value of domain name

Docker compose file supports variable substitution. When running
docker-compose up, Compose looks for the environment variables from
shell and substitutes the values at runtime.

Change-Id: I5255ead82276fac7db24ee74af453f83ca20bbe6
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This commit is contained in:
Ryan Chu 2018-11-30 09:14:54 +01:00
parent beab266977
commit bcaf67258f
3 changed files with 32 additions and 19 deletions

View File

@ -100,6 +100,10 @@ isEmpty(TESTSERVER_VERSION) {
} else {
TESTSERVER_COMPOSE_FILE = $$dirname(_QMAKE_CONF_)/tests/testserver/docker-compose.yml
DEFINES += QT_TEST_SERVER_NAME
# The environment variables passed to the docker-compose file
TEST_ENV = 'TEST_DOMAIN=$$DNSDOMAIN'
TEST_CMD = env
}
# The domain name is relevant to https keycert (qnetworkreply/crts/qt-test-net-cacert.pem).

View File

@ -7,25 +7,27 @@ version: '3.4'
# contexts gets changes, please make sure to update this compose file as well.
# You can run command 'docker images' to list all the tags of test server images.
# For example:
# REPOSITORY TAG IMAGE ID
# qt-test-server-apache2 cc9ea678b92bdda33acb9fa0159bb4ad0f3cd947 2ad5c8720317
# REPOSITORY TAG
# qt-test-server-apache2 537fe302f61851d1663f41495230d8e3554a4a13
services:
apache2:
image: qt-test-server-apache2:537fe302f61851d1663f41495230d8e3554a4a13
container_name: qt-test-server-apache2
domainname: test-net.qt.local
domainname: ${TEST_DOMAIN}
volumes:
- ./common:/common:ro
- ./apache2:/service:ro
entrypoint: common/startup.sh
command: [common/ssl.sh, service/apache2.sh]
network_mode: "host"
environment:
- test_domain=${TEST_DOMAIN}
squid:
image: qt-test-server-squid:9c32f41b19aca3d778733c4d8fb0ecc5955e893c
container_name: qt-test-server-squid
domainname: test-net.qt.local
domainname: ${TEST_DOMAIN}
depends_on:
- apache2
volumes:
@ -34,22 +36,26 @@ services:
entrypoint: common/startup.sh
command: service/squid.sh
network_mode: "host"
environment:
- test_domain=${TEST_DOMAIN}
vsftpd:
image: qt-test-server-vsftpd:f3a9c8d793a77cc007c0e4e481bec01f9e3eeb7e
container_name: qt-test-server-vsftpd
domainname: test-net.qt.local
domainname: ${TEST_DOMAIN}
volumes:
- ./common:/common:ro
- ./vsftpd:/service:ro
entrypoint: common/startup.sh
command: service/vsftpd.sh
network_mode: "host"
environment:
- test_domain=${TEST_DOMAIN}
ftp-proxy:
image: qt-test-server-ftp-proxy:d7de8b28392d173db512a558ccc84ead8bece2ae
container_name: qt-test-server-ftp-proxy
domainname: test-net.qt.local
domainname: ${TEST_DOMAIN}
depends_on:
- vsftpd
volumes:
@ -58,11 +64,13 @@ services:
entrypoint: common/startup.sh
command: service/ftp-proxy.sh
network_mode: "host"
environment:
- test_domain=${TEST_DOMAIN}
danted:
image: qt-test-server-danted:35607f9b790524cf9690c7d12a9a401696b7b6b5
container_name: qt-test-server-danted
domainname: test-net.qt.local
domainname: ${TEST_DOMAIN}
depends_on:
- apache2
- vsftpd
@ -78,3 +86,4 @@ services:
- danted_external=${MACHINE_IP:-eth0}
- danted_auth_internal=${MACHINE_IP:-eth0}
- danted_auth_external=${MACHINE_IP:-eth0}
- test_domain=${TEST_DOMAIN}

View File

@ -7,14 +7,14 @@ version: '3.4'
# contexts gets changes, please make sure to update this compose file as well.
# You can run command 'docker images' to list all the tag of test server images.
# For example:
# REPOSITORY TAG IMAGE ID
# qt-test-server-apache2 e2a70c8b169c204e762b375885bd3a26cc40ba48 2ad5c8720317
# REPOSITORY TAG
# qt-test-server-apache2 537fe302f61851d1663f41495230d8e3554a4a13
services:
apache2:
image: qt-test-server-apache2:537fe302f61851d1663f41495230d8e3554a4a13
container_name: qt-test-server-apache2
domainname: test-net.qt.local
domainname: ${TEST_DOMAIN}
hostname: apache2
volumes:
- ./common:/common:ro
@ -25,12 +25,12 @@ services:
squid:
image: qt-test-server-squid:9c32f41b19aca3d778733c4d8fb0ecc5955e893c
container_name: qt-test-server-squid
domainname: test-net.qt.local
domainname: ${TEST_DOMAIN}
hostname: squid
depends_on:
- apache2
external_links:
- apache2:apache2.test-net.qt.local
- apache2:apache2.${TEST_DOMAIN}
volumes:
- ./common:/common:ro
- ./squid:/service:ro
@ -40,7 +40,7 @@ services:
vsftpd:
image: qt-test-server-vsftpd:f3a9c8d793a77cc007c0e4e481bec01f9e3eeb7e
container_name: qt-test-server-vsftpd
domainname: test-net.qt.local
domainname: ${TEST_DOMAIN}
hostname: vsftpd
volumes:
- ./common:/common:ro
@ -51,12 +51,12 @@ services:
ftp-proxy:
image: qt-test-server-ftp-proxy:d7de8b28392d173db512a558ccc84ead8bece2ae
container_name: qt-test-server-ftp-proxy
domainname: test-net.qt.local
domainname: ${TEST_DOMAIN}
hostname: ftp-proxy
depends_on:
- vsftpd
external_links:
- vsftpd:vsftpd.test-net.qt.local
- vsftpd:vsftpd.${TEST_DOMAIN}
volumes:
- ./common:/common:ro
- ./ftp-proxy:/service:ro
@ -66,16 +66,16 @@ services:
danted:
image: qt-test-server-danted:35607f9b790524cf9690c7d12a9a401696b7b6b5
container_name: qt-test-server-danted
domainname: test-net.qt.local
domainname: ${TEST_DOMAIN}
hostname: danted
depends_on:
- apache2
- vsftpd
- ftp-proxy
external_links:
- apache2:apache2.test-net.qt.local
- vsftpd:vsftpd.test-net.qt.local
- ftp-proxy:ftp-proxy.test-net.qt.local
- apache2:apache2.${TEST_DOMAIN}
- vsftpd:vsftpd.${TEST_DOMAIN}
- ftp-proxy:ftp-proxy.${TEST_DOMAIN}
volumes:
- ./common:/common:ro
- ./danted:/service:ro