Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(server): allow running Outline on a server with another Watchtower #1255

Merged
merged 2 commits into from
Nov 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/server_manager/install_scripts/install_server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ function write_config() {
config+=("\"portForNewAccessKeys\": ${FLAGS_KEYS_PORT}")
fi
if [[ -n "${SB_DEFAULT_SERVER_NAME:-}" ]]; then
config+=("\"name\": \"$(escape_json_string "${SB_DEFAULT_SERVER_NAME}")\"")
config+=("\"name\": \"$(escape_json_string "${SB_DEFAULT_SERVER_NAME}")\"")
fi
config+=("\"hostname\": \"$(escape_json_string "${PUBLIC_HOSTNAME}")\"")
echo "{$(join , "${config[@]}")}" > "${STATE_DIR}/shadowbox_server_config.json"
Expand Down Expand Up @@ -323,13 +323,14 @@ docker_command=(

# Used by Watchtower to know which containers to monitor.
--label 'com.centurylinklabs.watchtower.enable=true'

--label 'com.centurylinklabs.watchtower.scope=outline'

# Use log rotation. See https://docs.docker.com/config/containers/logging/configure/.
--log-driver local

# The state that is persisted across restarts.
-v "${STATE_DIR}:${STATE_DIR}"

# Where the container keeps its persistent state.
-e "SB_STATE_DIR=${STATE_DIR}"

Expand Down Expand Up @@ -370,10 +371,12 @@ function start_watchtower() {
# testing). Otherwise refresh every hour.
local -ir WATCHTOWER_REFRESH_SECONDS="${WATCHTOWER_REFRESH_SECONDS:-3600}"
local -ar docker_watchtower_flags=(--name watchtower --log-driver local --restart always \
--label 'com.centurylinklabs.watchtower.enable=true' \
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

furthermore, this change now allows watchtower to update itself
right now every instance of outline-server has its watchtower image stuck on the installation version due to the presence of --label-enable

--label 'com.centurylinklabs.watchtower.scope=outline' \
-v /var/run/docker.sock:/var/run/docker.sock)
# By itself, local messes up the return code.
local STDERR_OUTPUT
STDERR_OUTPUT="$(docker run -d "${docker_watchtower_flags[@]}" containrrr/watchtower --cleanup --label-enable --tlsverify --interval "${WATCHTOWER_REFRESH_SECONDS}" 2>&1 >/dev/null)" && return
STDERR_OUTPUT="$(docker run -d "${docker_watchtower_flags[@]}" containrrr/watchtower --cleanup --label-enable --scope=outline --tlsverify --interval "${WATCHTOWER_REFRESH_SECONDS}" 2>&1 >/dev/null)" && return
readonly STDERR_OUTPUT
log_error "FAILED"
if docker_container_exists watchtower; then
Expand Down Expand Up @@ -555,7 +558,7 @@ function escape_json_string() {
$'\\') escaped="\\\\";;
*)
if [[ "${char}" < $'\x20' ]]; then
case "${char}" in
case "${char}" in
$'\b') escaped="\\b";;
$'\f') escaped="\\f";;
$'\n') escaped="\\n";;
Expand Down
Loading