Skip to content

Commit

Permalink
remove need to update docker compose (for now)
Browse files Browse the repository at this point in the history
  • Loading branch information
mishaschwartz committed Aug 15, 2023
1 parent e08a4f5 commit 95c6284
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 16 deletions.
12 changes: 8 additions & 4 deletions birdhouse/pavics-compose.sh
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,15 @@ if [ x"$1" = x"up" ]; then
echo "COMPOSE_CONF_LIST="
echo ${COMPOSE_CONF_LIST} | tr ' ' '\n' | grep -v '^-f'

cp "${COMPOSE_DIR}/docker-compose.yml" "${COMPOSE_FILE}"

# the PROXY_SECURE_PORT is a little trick to make the compose file invalid without the usage of this wrapper script
PROXY_SECURE_PORT=443 HOSTNAME=${PAVICS_FQDN} docker compose --project-directory "${BUILD_DIR}" ${COMPOSE_CONF_LIST} config -o "${COMPOSE_FILE}"
PROXY_SECURE_PORT=443 HOSTNAME=${PAVICS_FQDN} docker-compose ${COMPOSE_CONF_LIST} config > "${COMPOSE_FILE}.final"

mv "${COMPOSE_FILE}.final" "${COMPOSE_FILE}"
fi

docker compose -f "${COMPOSE_FILE}" "$@"
docker-compose -f "${COMPOSE_FILE}" "$@"
ERR=$?

# execute post-compose function if exists and no error occurred
Expand All @@ -148,11 +152,11 @@ while [ $# -gt 0 ]
do
if [ x"$1" = x"up" ]; then
# we restart the proxy after an up to make sure nginx continue to work if any container IP address changes
docker compose -f "${COMPOSE_FILE}" restart proxy
docker-compose -f "${COMPOSE_FILE}" restart proxy

# run postgres post-startup setup script
# Note: this must run before the post-docker-compose-up scripts since some may expect postgres databases to exist
postgres_id=$(docker compose -f "${COMPOSE_FILE}" ps -q postgres)
postgres_id=$(docker-compose -f "${COMPOSE_FILE}" ps -q postgres)
if [ ! -z "$postgres_id" ]; then
docker exec ${postgres_id} /postgres-setup.sh
fi
Expand Down
2 changes: 1 addition & 1 deletion birdhouse/read-configs.include.sh
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ create_compose_conf_list() {

[ -z "$BUILD_DIR" ] && return

COMPOSE_CONF_LIST="-f ${COMPOSE_DIR}/docker-compose.yml"
COMPOSE_CONF_LIST="-f ${BUILD_DIR}/docker-compose.yml"
COMPONENT_OVERRIDES=''
LOADED_COMPONENTS=''
for adir in $ALL_CONF_DIRS; do
Expand Down
21 changes: 10 additions & 11 deletions tests/test_read_configs_include.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,9 @@ def test_delayed_eval_custom_value(self, read_config_include_file) -> None:

class TestCreateComposeConfList:
@staticmethod
def default_conf_list_order(tmp_build_dir, root_dir) -> list[str]:
def default_conf_list_order(tmp_build_dir) -> list[str]:
return [
f"{root_dir}/birdhouse/docker-compose.yml",
f"{tmp_build_dir}/docker-compose.yml",
f"{tmp_build_dir}/proxy/docker-compose-extra.yml",
f"{tmp_build_dir}/canarie-api/config/proxy/docker-compose-extra.yml",
f"{tmp_build_dir}/geoserver/docker-compose-extra.yml",
Expand Down Expand Up @@ -244,13 +244,13 @@ def run_func(self, include_file: str, local_env: dict, command_suffix: str = "")
)
return proc

def test_all_conf_dirs_empty(self, read_config_include_file, tmp_build_dir, root_dir):
def test_all_conf_dirs_empty(self, read_config_include_file, tmp_build_dir):
"""Test that only the base compose file is used when ALL_CONF_DIRS is empty"""
proc = self.run_func(read_config_include_file, {"BUILD_DIR": tmp_build_dir}, 'echo "$COMPOSE_CONF_LIST"')
assert split_and_strip(get_command_stdout(proc)) == [f"-f {root_dir}/birdhouse/docker-compose.yml"]
assert split_and_strip(get_command_stdout(proc)) == [f"-f {tmp_build_dir}/docker-compose.yml"]

@pytest.mark.usefixtures("run_in_compose_dir")
def test_compose_no_overrides(self, read_config_include_file, tmp_build_dir, root_dir):
def test_compose_no_overrides(self, read_config_include_file, tmp_build_dir):
"""Test that COMPOSE_CONF_LIST is set correctly when there are no overrides"""
proc = self.run_func(
read_config_include_file,
Expand All @@ -259,7 +259,7 @@ def test_compose_no_overrides(self, read_config_include_file, tmp_build_dir, roo
)
print(proc.stdout) # useful for debugging when assert fail
assert split_and_strip(get_command_stdout(proc), split_on="-f") == [
f"{root_dir}/birdhouse/docker-compose.yml",
f"{tmp_build_dir}/docker-compose.yml",
f"{tmp_build_dir}/finch/docker-compose-extra.yml",
f"{tmp_build_dir}/raven/docker-compose-extra.yml",
]
Expand All @@ -277,7 +277,7 @@ def test_compose_in_order(self, read_config_include_file):
assert out1 == out2[:1] + out2[:0:-1]

@pytest.mark.usefixtures("run_in_compose_dir")
def test_compose_overrides(self, read_config_include_file, tmp_build_dir, root_dir):
def test_compose_overrides(self, read_config_include_file, tmp_build_dir):
"""Test that COMPOSE_CONF_LIST is set correctly when there are overrides"""
proc = self.run_func(
read_config_include_file,
Expand All @@ -286,19 +286,18 @@ def test_compose_overrides(self, read_config_include_file, tmp_build_dir, root_d
)
print(proc.stdout) # useful for debugging when assert fail
assert split_and_strip(get_command_stdout(proc), split_on="-f") == [
f"{root_dir}/birdhouse/docker-compose.yml",
f"{tmp_build_dir}/docker-compose.yml",
f"{tmp_build_dir}/finch/docker-compose-extra.yml",
f"{tmp_build_dir}/magpie/docker-compose-extra.yml",
f"{tmp_build_dir}/finch/config/magpie/docker-compose-extra.yml",
]

@pytest.mark.usefixtures("run_in_compose_dir")
def test_default_all_conf_dirs(self, read_config_include_file, tmp_build_dir, root_dir):
def test_default_all_conf_dirs(self, read_config_include_file, tmp_build_dir):
proc = self.run_func(
read_config_include_file,
{"ALL_CONF_DIRS": " ".join(TestReadConfigs.default_all_conf_order), "BUILD_DIR": tmp_build_dir},
'echo "$COMPOSE_CONF_LIST"',
)
print(proc.stdout) # useful for debugging when assert fail
assert split_and_strip(get_command_stdout(proc), split_on="-f") == self.default_conf_list_order(tmp_build_dir,
root_dir)
assert split_and_strip(get_command_stdout(proc), split_on="-f") == self.default_conf_list_order(tmp_build_dir)

0 comments on commit 95c6284

Please sign in to comment.