diff --git a/Dockerfile b/Dockerfile index 3ca132a..7793c26 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,12 +17,13 @@ RUN set -e; \ apt-get remove -y wget; \ rm -rf /var/lib/apt/lists/*; -COPY scripts/* ./ +COPY src/* ./ ENV ELECTRON_DISABLE_SECURITY_WARNINGS "true" ENV DRAWIO_DISABLE_UPDATE "true" ENV DRAWIO_DESKTOP_COMMAND_TIMEOUT "10s" ENV DRAWIO_DESKTOP_EXECUTABLE_PATH "/opt/drawio/drawio" +ENV DRAWIO_DESKTOP_SOURCE_FOLDER "/opt/drawio-desktop" ENV DRAWIO_DESKTOP_RUNNER_COMMAND_LINE "/opt/drawio-desktop/runner.sh" ENV XVFB_DISPLAY ":42" ENV XVFB_OPTIONS "" diff --git a/scripts/entrypoint.sh b/scripts/entrypoint.sh deleted file mode 100755 index f207e91..0000000 --- a/scripts/entrypoint.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail - -# Start Xvfb -export DISPLAY="${XVFB_DISPLAY}" -# shellcheck disable=SC2086 -Xvfb "${XVFB_DISPLAY}" ${XVFB_OPTIONS} & - -# shellcheck disable=SC2068 -timeout "${DRAWIO_DESKTOP_COMMAND_TIMEOUT}" "${DRAWIO_DESKTOP_RUNNER_COMMAND_LINE}" "$@" diff --git a/scripts/runner.sh b/scripts/runner.sh deleted file mode 100755 index f940b61..0000000 --- a/scripts/runner.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail - -if [ "${ELECTRON_DISABLE_SECURITY_WARNINGS}" == "true" ]; then - "$DRAWIO_DESKTOP_EXECUTABLE_PATH" "$@" --no-sandbox 2>&1 | - grep -v "Failed to connect to socket" | - grep -v "Could not parse server address" | - grep -v "Floss manager not present" | - grep -v "Exiting GPU process" | - grep -v "called with multiple threads" | - grep -v "extension not supported" | - grep -v "Failed to send GpuControl.CreateCommandBuffer" | - grep -v "Init observer found at shutdown" -else - "$DRAWIO_DESKTOP_EXECUTABLE_PATH" "$@" --no-sandbox 2>&1 -fi diff --git a/src/entrypoint.sh b/src/entrypoint.sh new file mode 100755 index 0000000..0f7daf2 --- /dev/null +++ b/src/entrypoint.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +set -euo pipefail + +# Prepare output cleaning +touch "${DRAWIO_DESKTOP_SOURCE_FOLDER:?}/unwanted-lines.txt" +if [[ "${ELECTRON_DISABLE_SECURITY_WARNINGS:?}" == "true" ]]; then + cat "${DRAWIO_DESKTOP_SOURCE_FOLDER:?}/unwanted-security-warnings.txt" >>"${DRAWIO_DESKTOP_SOURCE_FOLDER:?}/unwanted-lines.txt" +fi + +# Start Xvfb +export DISPLAY="${XVFB_DISPLAY:?}" +# shellcheck disable=SC2086 +# shellcheck disable=SC2154 +Xvfb "${XVFB_DISPLAY:?}" ${XVFB_OPTIONS} & + +# Run +timeout "${DRAWIO_DESKTOP_COMMAND_TIMEOUT:?}" "${DRAWIO_DESKTOP_SOURCE_FOLDER:?}/runner_wrapper.sh" "$@" diff --git a/src/runner.sh b/src/runner.sh new file mode 100755 index 0000000..a6eb41d --- /dev/null +++ b/src/runner.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +set -euo pipefail + +"${DRAWIO_DESKTOP_EXECUTABLE_PATH:?}" "$@" --no-sandbox diff --git a/src/runner_wrapper.sh b/src/runner_wrapper.sh new file mode 100755 index 0000000..8a9d9e7 --- /dev/null +++ b/src/runner_wrapper.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +set -euo pipefail + +# Run and filter output +"${DRAWIO_DESKTOP_RUNNER_COMMAND_LINE:?}" "$@" 2>&1 | grep -Fvf "${DRAWIO_DESKTOP_SOURCE_FOLDER:?}/unwanted-lines.txt" diff --git a/src/unwanted-security-warnings.txt b/src/unwanted-security-warnings.txt new file mode 100644 index 0000000..ea75e03 --- /dev/null +++ b/src/unwanted-security-warnings.txt @@ -0,0 +1,8 @@ +Failed to connect to socket +Could not parse server address +Floss manager not present +Exiting GPU process +called with multiple threads +extension not supported +Failed to send GpuControl.CreateCommandBuffer +Init observer found at shutdown