Skip to content

Commit c6cf2ad

Browse files
committed
fix: populate ARCH and CONTAINER_RUNTIME after upgrade
add `--env-file` argument to docker-compose calls
1 parent 39a8059 commit c6cf2ad

File tree

4 files changed

+38
-5
lines changed

4 files changed

+38
-5
lines changed

src/env.sh

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
source ./constants.sh
77
source ./util.sh
8+
source ./patches.sh
89

910
env_file_exists() {
1011
[ -f "${ENV_FILE}" ]
@@ -14,6 +15,8 @@ env_barrier() {
1415
if ! env_file_exists; then
1516
error "Initial configuration outstanding (run $(highlight "'./migrator install'"))"
1617
fi
18+
19+
v3_20_0_add_arch_and_container_runtime
1720
}
1821

1922
print_env() {

src/patches.sh

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env bash
2+
3+
# SPDX-License-Identifier: MIT
4+
# SPDX-FileCopyrightText: 2022-2024 CYBERTEC PostgreSQL International GmbH <office@cybertec.at>
5+
6+
source ./constants.sh
7+
source ./util.sh
8+
9+
v3_20_0_add_arch_and_container_runtime() {
10+
if [ -z "$(print_env 'ARCH')" ]; then
11+
local architecture=""
12+
case $(uname -m) in
13+
x86_64) architecture="amd64" ;;
14+
aarch64|arm64) architecture="arm64" ;;
15+
*)
16+
error "Unable to detect architecture $(highlight "$(uname -m)")"
17+
error "Please file a ticket so we may resolve this issue:"
18+
error " Public: https://github.com/cybertec-postgresql/cybertec_migrator/issues/new/choose"
19+
error " Customers: https://cybertec.atlassian.net/servicedesk/customer/portal/3/group/4/create/23"
20+
exit 1
21+
;;
22+
esac
23+
set_env_file_variable "ARCH" "$architecture"
24+
fi
25+
26+
if [ -z "$(print_env 'CONTAINER_RUNTIME')" ]; then
27+
set_env_file_variable "CONTAINER_RUNTIME" "docker"
28+
fi
29+
}

src/runtime.docker.sh

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@
44
# SPDX-FileCopyrightText: 2022-2024 CYBERTEC PostgreSQL International GmbH <office@cybertec.at>
55

66
runtime_up() {
7-
docker compose up -d
7+
docker compose --env-file ../.env up -d
88
}
99

1010
runtime_down() {
11-
docker compose down
11+
docker compose --env-file ../.env down
1212
}
1313

1414
runtime_pull() {
15-
docker compose pull 2>&1 > /dev/null
15+
docker compose --env-file ../.env pull 2>&1 > /dev/null
1616
}
1717

1818
runtime_logs() {
19-
docker compose logs --timestamps --tail='all' $1
19+
docker compose --env-file ../.env logs --timestamps --tail='all' $1
2020
}
2121

2222
runtime_load() {
@@ -29,7 +29,7 @@ runtime_run() {
2929
local mount="${3}"
3030

3131
if [ -n "${mount}" ]; then
32-
mount="--mount ${mount}"
32+
mount="--volume ${mount}"
3333
fi
3434

3535
eval "docker run ${mount} ${image} bash -c \"${cmd}\""

src/runtime.sh

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ source ./env.sh
77
source ./console.sh
88

99
if env_file_exists; then
10+
v3_20_0_add_arch_and_container_runtime
1011
case "$(print_env 'CONTAINER_RUNTIME')" in
1112
docker) source ./runtime.docker.sh ;;
1213
podman) source ./runtime.podman.sh ;;

0 commit comments

Comments
 (0)