From 08e7266c31e42b563ba7789c480b11a6b0e3646a Mon Sep 17 00:00:00 2001 From: Piero Toffanin Date: Sat, 1 Nov 2025 01:46:31 -0400 Subject: [PATCH 1/4] Install npm --- install_deps.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 install_deps.sh diff --git a/install_deps.sh b/install_deps.sh new file mode 100644 index 0000000..f0398a3 --- /dev/null +++ b/install_deps.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +for i in {1..20}; do + apt-get update && apt-get install -y curl gpg-agent && break + echo "apt-get failed, retrying... ($i/20)" + sleep 30 +done + +curl --silent --location https://deb.nodesource.com/setup_14.x | bash - + +for i in {1..20}; do + apt-get install -y nodejs npm unzip p7zip-full && npm install -g nodemon && break + echo "apt-get failed, retrying... ($i/20)" + sleep 30 +done \ No newline at end of file From 2dc1819b0b047e56529d7dd23182e853fa509077 Mon Sep 17 00:00:00 2001 From: Piero Toffanin Date: Sat, 1 Nov 2025 12:16:23 -0400 Subject: [PATCH 2/4] Upgrade to Python 3.12 --- helpers/odmOptionsToJson.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/helpers/odmOptionsToJson.py b/helpers/odmOptionsToJson.py index 9a4e0ce..be66f0f 100644 --- a/helpers/odmOptionsToJson.py +++ b/helpers/odmOptionsToJson.py @@ -18,24 +18,33 @@ ''' import sys -import imp +import importlib.util +import importlib.machinery +import types import argparse import json import os +def load_source(module_name, filename): + loader = importlib.machinery.SourceFileLoader(module_name, filename) + module = types.ModuleType(loader.name) + module.__file__ = filename + loader.exec_module(module) + return module + dest_file = os.environ.get("ODM_OPTIONS_TMP_FILE") sys.path.append(sys.argv[2]) try: - imp.load_source('opendm', sys.argv[2] + '/opendm/__init__.py') + load_source('opendm', sys.argv[2] + '/opendm/__init__.py') except: pass try: - imp.load_source('context', sys.argv[2] + '/opendm/context.py') + load_source('context', sys.argv[2] + '/opendm/context.py') except: pass -odm = imp.load_source('config', sys.argv[2] + '/opendm/config.py') +odm = load_source('config', sys.argv[2] + '/opendm/config.py') options = {} class ArgumentParserStub(argparse.ArgumentParser): From 301aaf073b652a7c5099ec4e4d1dccf8380a246a Mon Sep 17 00:00:00 2001 From: Piero Toffanin Date: Sat, 1 Nov 2025 12:38:23 -0400 Subject: [PATCH 3/4] Update Dockerfile, add node.sh wrapper --- Dockerfile | 45 +++++++++++++++++++++++---------------------- Dockerfile.gpu | 13 ++++++++----- install_deps.sh | 21 ++++++++++++++++++--- node.sh | 10 ++++++++++ 4 files changed, 59 insertions(+), 30 deletions(-) create mode 100755 node.sh diff --git a/Dockerfile b/Dockerfile index 48b24cc..c1f44b8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,22 +1,23 @@ -FROM opendronemap/odm:latest -MAINTAINER Piero Toffanin - -EXPOSE 3000 - -USER root -RUN apt-get update && apt-get install -y curl gpg-agent -RUN curl --silent --location https://deb.nodesource.com/setup_14.x | bash - -RUN apt-get install -y nodejs unzip p7zip-full && npm install -g nodemon && \ - ln -s /code/SuperBuild/install/bin/untwine /usr/bin/untwine && \ - ln -s /code/SuperBuild/install/bin/entwine /usr/bin/entwine && \ - ln -s /code/SuperBuild/install/bin/pdal /usr/bin/pdal - - -RUN mkdir /var/www - -WORKDIR "/var/www" -COPY . /var/www - -RUN npm install --production && mkdir -p tmp - -ENTRYPOINT ["/usr/bin/node", "/var/www/index.js"] +FROM opendronemap/odm:latest +MAINTAINER Piero Toffanin + +EXPOSE 3000 + +USER root + +RUN mkdir /var/www + +WORKDIR "/var/www" +COPY . /var/www + +ENV NVM_DIR /usr/local/nvm +ENV NODE_VERSION 14 + +RUN bash install_deps.sh && \ + ln -s /code/SuperBuild/install/bin/untwine /usr/bin/untwine && \ + ln -s /code/SuperBuild/install/bin/entwine /usr/bin/entwine && \ + ln -s /code/SuperBuild/install/bin/pdal /usr/bin/pdal && \ + ln -s /var/www/node.sh /usr/bin/node && \ + mkdir -p tmp && node index.js --powercycle + +ENTRYPOINT ["/usr/bin/node", "/var/www/index.js"] diff --git a/Dockerfile.gpu b/Dockerfile.gpu index 738bd04..434b4cb 100644 --- a/Dockerfile.gpu +++ b/Dockerfile.gpu @@ -4,12 +4,15 @@ MAINTAINER Piero Toffanin EXPOSE 3000 USER root -RUN apt-get update && apt-get install -y curl gpg-agent ca-certificates -RUN curl --silent --location https://deb.nodesource.com/setup_14.x | bash - -RUN apt-get install -y nodejs unzip p7zip-full && npm install -g nodemon && \ + +ENV NVM_DIR /usr/local/nvm +ENV NODE_VERSION 14 + +RUN bash install_deps.sh && \ ln -s /code/SuperBuild/install/bin/untwine /usr/bin/untwine && \ ln -s /code/SuperBuild/install/bin/entwine /usr/bin/entwine && \ - ln -s /code/SuperBuild/install/bin/pdal /usr/bin/pdal + ln -s /code/SuperBuild/install/bin/pdal /usr/bin/pdal && \ + ln -s /var/www/node.sh /usr/bin/node RUN echo /usr/local/cuda-11.2/compat >> /etc/ld.so.conf.d/989_cuda-11.conf && ldconfig @@ -19,7 +22,7 @@ WORKDIR "/var/www" RUN useradd -m -d "/home/odm" -s /bin/bash odm COPY --chown=odm:odm . /var/www -RUN npm install --production && mkdir -p tmp +RUN npm install --production && mkdir -p tmp && node index.js --powercycle RUN chown -R odm:odm /var/www RUN chown -R odm:odm /code diff --git a/install_deps.sh b/install_deps.sh index f0398a3..54d6395 100644 --- a/install_deps.sh +++ b/install_deps.sh @@ -1,15 +1,30 @@ #!/bin/bash +if [ -z "$NVM_DIR" ]; then + echo "Error: NVM_DIR environment variable is not set" >&2 + exit 1 +fi +if [ -z "$NODE_VERSION" ]; then + echo "Error: NODE_VERSION environment variable is not set" >&2 + exit 1 +fi + for i in {1..20}; do apt-get update && apt-get install -y curl gpg-agent && break echo "apt-get failed, retrying... ($i/20)" sleep 30 done -curl --silent --location https://deb.nodesource.com/setup_14.x | bash - +mkdir -p $NVM_DIR +curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash +source $NVM_DIR/nvm.sh +nvm install $NODE_VERSION +nvm alias default $NODE_VERSION for i in {1..20}; do - apt-get install -y nodejs npm unzip p7zip-full && npm install -g nodemon && break + apt-get install -y unzip p7zip-full && npm install -g nodemon && break echo "apt-get failed, retrying... ($i/20)" sleep 30 -done \ No newline at end of file +done + +npm install --production \ No newline at end of file diff --git a/node.sh b/node.sh new file mode 100755 index 0000000..30c59a5 --- /dev/null +++ b/node.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +if [ -z "$NVM_DIR" ]; then + echo "Error: NVM_DIR environment variable is not set" >&2 + exit 1 +fi + +source $NVM_DIR/nvm.sh +nvm use $NODE_VERSION +exec node "$@" \ No newline at end of file From e278739007d74e88b70ce3c614d94859c612a538 Mon Sep 17 00:00:00 2001 From: Piero Toffanin Date: Sat, 15 Nov 2025 00:09:46 -0500 Subject: [PATCH 4/4] Don't inherit stdio --- libs/odmRunner.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/odmRunner.js b/libs/odmRunner.js index 334bcea..2e54bd6 100644 --- a/libs/odmRunner.js +++ b/libs/odmRunner.js @@ -133,7 +133,7 @@ module.exports = { } let childProcess = spawn(pythonExe, [shQuote(path.join(__dirname, "..", "helpers", "odmOptionsToJson.py")), - "--project-path", shQuote(config.odm_path), "bogusname"], { env, stdio: 'inherit', shell: true }); + "--project-path", shQuote(config.odm_path), "bogusname"], { env, shell: true }); // Cleanup on done let handleResult = (err, result) => {