From d7e7555c24e967ef8a96f95b48eb5b6074c65823 Mon Sep 17 00:00:00 2001 From: Michael March Date: Sun, 5 Jun 2022 21:53:02 -0700 Subject: [PATCH 1/4] Updates to fix the issue when morethan one container engine is installed on a host system. The ability to override container engine default is also added. --- README.md | 2 ++ env-set.sh | 14 +++++++------- resolve.sh | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 72f7370..8a530a6 100644 --- a/README.md +++ b/README.md @@ -399,6 +399,8 @@ Here are a few environment variables you can set when running `build.sh` and `re * `RESOLVE_NETWORK` -- Set to "host" to use the host's Internet/network connectivity. Other network driver options are described in the [Docker](https://docs.docker.com/network/) and [Podman](https://docs.podman.io/en/latest/markdown/podman-run.1.html) documentation. The default is "none", meaning the container will not have network access. +* `RESOLVE_CONTAINER_ENGINE` -- Should you have *both* Podman and Docker installed in your host environment, Podman will always be used as your default. To specify a specific container engine, set `RESOLVE_CONTAINER_ENGINE` to either `podman` or `docker`. + * `RESOLVE_BIND_SOURCES` and `RESOLVE_BIND_TARGETS` -- Use these to add your own custom bindings from the host to the container. Say you want to map `/tmp/garbage` on your host to `/tmp` in the container. You also want to map `/var/run/dbus/system_bus_socket` from the host to the container. You can do this like this. diff --git a/env-set.sh b/env-set.sh index 921893a..6297162 100644 --- a/env-set.sh +++ b/env-set.sh @@ -13,16 +13,16 @@ fi # determine if podman or docker installed -if ! command -v podman &> /dev/null; then - CONTAINER_TYPE="docker" - CONTAINER_BUILD="docker build ." - CONTAINER_EXISTS="docker images -q" - CONTAINER_RUN_ARGS=" --env PODMANOPT=no --env PODMANGROUPS=no" -elif ! command -v docker &> /dev/null; then - CONTAINER_TYPE="podman" +if [ -z "$(podman -v 2>&1 | grep -i 'not found')" ] && [ -z $(echo ${RESOLVE_CONTAINER_ENGINE} | grep -v -i podman) ]; then + CONTAINER_ENGINE="podman" CONTAINER_BUILD="buildah bud" CONTAINER_EXISTS="podman image exists" CONTAINER_RUN_ARGS=" --annotation run.oci.keep_original_groups=1 --userns=keep-id" +elif [ -z "$(docker -v 2>&1 | grep -i 'not found')" ] && [ -n "$(docker -v 2>&1 | grep -i 'version')" ] && [ -z $(echo ${RESOLVE_CONTAINER_ENGINE} | grep -v -i docker) ]; then + CONTAINER_ENGINE="docker" + CONTAINER_BUILD="docker build ." + CONTAINER_EXISTS="docker images -q" + CONTAINER_RUN_ARGS=" --env PODMANOPT=no --env PODMANGROUPS=no" else echo "You must install either podman or docker and try again." exit 1 diff --git a/resolve.sh b/resolve.sh index 7a30123..7528ffb 100755 --- a/resolve.sh +++ b/resolve.sh @@ -186,7 +186,7 @@ if [ -z "${XAUTHORITY}" ]; then echo "\$XAUTHORITY was not set. Defaulting to ${XAUTHORITY}" fi -"${CONTAINER_TYPE}" run -it \ +"${CONTAINER_ENGINE}" run -it \ --user resolve:resolve \ --env DISPLAY=$DISPLAY \ --env PULSE_SERVER=unix:${XDG_RUNTIME_DIR}/pulse/native \ From 39d60c9873eb5998987140fe79e4d44243bc15f3 Mon Sep 17 00:00:00 2001 From: fattire Date: Wed, 8 Jun 2022 16:41:26 -0700 Subject: [PATCH 2/4] Manjaro/Arch issue- "arch" missing so use "uname -m" instead. Thanks to @Hanziness for reporting this! --- build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sh b/build.sh index 9d528bb..f6fc89e 100755 --- a/build.sh +++ b/build.sh @@ -76,7 +76,7 @@ fi echo "Building the resolve:${TAG} image..." -${CONTAINER_BUILD} -t "resolve:${TAG}" -t "resolve" --build-arg ARCH=`arch` --build-arg ZIPNAME="${ZIPNAME}" --build-arg BASE_IMAGE="${BASE_IMAGE}" --build-arg NVIDIA_VERSION="${NVIDIA_VERSION}" +${CONTAINER_BUILD} -t "resolve:${TAG}" -t "resolve" --build-arg ARCH=`uname -m` --build-arg ZIPNAME="${ZIPNAME}" --build-arg BASE_IMAGE="${BASE_IMAGE}" --build-arg NVIDIA_VERSION="${NVIDIA_VERSION}" # remove any context link if [ -f "${CONTEXT_ZIP}" ]; then From 6b8053c6939c3e9ff95b3d5cd9178d7a318eb8b9 Mon Sep 17 00:00:00 2001 From: fattire Date: Sun, 12 Jun 2022 21:09:35 -0700 Subject: [PATCH 3/4] A fix for (Arch/Manjaro) - "magic bytes" in container breaks build. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See Issue #16 for discussion. Basically this checks to see if the problematic bytes are in the header, and if so, patches them out. Confirmed working on Ubuntu 22.04, Pop!_OS, and Manjaro. Thanks to @hanziness and @cowmix for helping to find the cause of the problem and for testing. Also thanks to @theassassin and the AppImage folks for identifying and fixing, which will hopefully be addressed by BMD if they use a newer AppImageKit, at which point this check will fail and this commit won't be needed on those systems. Still not sure why --endian=big is needed on x86_64 but apparently it is.. ¯\_(ツ)_/¯ --- Dockerfile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Dockerfile b/Dockerfile index 94420bb..7608422 100644 --- a/Dockerfile +++ b/Dockerfile @@ -52,8 +52,13 @@ RUN echo "${USER} ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-$USER COPY "${ZIPNAME}" /tmp/DaVinci_Resolve_Linux.zip +# Note: for Arch & Manjaro distributions, we need to work around a potential AppImage "magic bytes" bug that may be in the run file +# see https://github.com/fat-tire/resolve/issues/16 + RUN cd /tmp \ && unzip *DaVinci_Resolve_Linux.zip \ + && if [ "`od -An -j 8 -N 6 -x --endian=big *DaVinci_Resolve_*_Linux.run`" = " 4149 0200 0000" ]; then \ + sed '0,/AI\x02/{s|AI\x02|\x00\x00\x00|}' -i *DaVinci_Resolve_*_Linux.run; fi \ && ./*DaVinci_Resolve_*_Linux.run --appimage-extract \ && cd squashfs-root \ && ./AppRun -i -a -y \ From 4897200b33fc2712f2b581d366fa34f18eed7833 Mon Sep 17 00:00:00 2001 From: fattire Date: Tue, 14 Jun 2022 13:33:49 -0700 Subject: [PATCH 4/4] Use --device /dev/bus/usb instead of mount (works better on docker) --- resolve.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resolve.sh b/resolve.sh index 7528ffb..3175ef7 100755 --- a/resolve.sh +++ b/resolve.sh @@ -203,7 +203,7 @@ fi --device /dev/nvidia-modeset \ --device /dev/nvidia-uvm \ --device /dev/nvidia-uvm-tools \ - --mount type=bind,source=/dev/bus/usb,target=/dev/bus/usb \ + --device /dev/bus/usb \ --mount type=bind,source=$XAUTHORITY,target=/tmp/.host_Xauthority,readonly \ --mount type=bind,source=/etc/localtime,target=/etc/localtime,readonly \ --mount type=bind,source=/tmp/.X11-unix,target=/tmp/.X11-unix \