Skip to content

Commit b0a5ef3

Browse files
authored
Merge pull request #253 from OpenDroneMap/2404
24.04
2 parents eb970da + e278739 commit b0a5ef3

File tree

6 files changed

+85
-32
lines changed

6 files changed

+85
-32
lines changed

Dockerfile

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
1-
FROM opendronemap/odm:latest
2-
MAINTAINER Piero Toffanin <[email protected]>
3-
4-
EXPOSE 3000
5-
6-
USER root
7-
RUN apt-get update && apt-get install -y curl gpg-agent
8-
RUN curl --silent --location https://deb.nodesource.com/setup_14.x | bash -
9-
RUN apt-get install -y nodejs unzip p7zip-full && npm install -g nodemon && \
10-
ln -s /code/SuperBuild/install/bin/untwine /usr/bin/untwine && \
11-
ln -s /code/SuperBuild/install/bin/entwine /usr/bin/entwine && \
12-
ln -s /code/SuperBuild/install/bin/pdal /usr/bin/pdal
13-
14-
15-
RUN mkdir /var/www
16-
17-
WORKDIR "/var/www"
18-
COPY . /var/www
19-
20-
RUN npm install --production && mkdir -p tmp
21-
22-
ENTRYPOINT ["/usr/bin/node", "/var/www/index.js"]
1+
FROM opendronemap/odm:latest
2+
MAINTAINER Piero Toffanin <[email protected]>
3+
4+
EXPOSE 3000
5+
6+
USER root
7+
8+
RUN mkdir /var/www
9+
10+
WORKDIR "/var/www"
11+
COPY . /var/www
12+
13+
ENV NVM_DIR /usr/local/nvm
14+
ENV NODE_VERSION 14
15+
16+
RUN bash install_deps.sh && \
17+
ln -s /code/SuperBuild/install/bin/untwine /usr/bin/untwine && \
18+
ln -s /code/SuperBuild/install/bin/entwine /usr/bin/entwine && \
19+
ln -s /code/SuperBuild/install/bin/pdal /usr/bin/pdal && \
20+
ln -s /var/www/node.sh /usr/bin/node && \
21+
mkdir -p tmp && node index.js --powercycle
22+
23+
ENTRYPOINT ["/usr/bin/node", "/var/www/index.js"]

Dockerfile.gpu

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,15 @@ MAINTAINER Piero Toffanin <[email protected]>
44
EXPOSE 3000
55

66
USER root
7-
RUN apt-get update && apt-get install -y curl gpg-agent ca-certificates
8-
RUN curl --silent --location https://deb.nodesource.com/setup_14.x | bash -
9-
RUN apt-get install -y nodejs unzip p7zip-full && npm install -g nodemon && \
7+
8+
ENV NVM_DIR /usr/local/nvm
9+
ENV NODE_VERSION 14
10+
11+
RUN bash install_deps.sh && \
1012
ln -s /code/SuperBuild/install/bin/untwine /usr/bin/untwine && \
1113
ln -s /code/SuperBuild/install/bin/entwine /usr/bin/entwine && \
12-
ln -s /code/SuperBuild/install/bin/pdal /usr/bin/pdal
14+
ln -s /code/SuperBuild/install/bin/pdal /usr/bin/pdal && \
15+
ln -s /var/www/node.sh /usr/bin/node
1316

1417
RUN echo /usr/local/cuda-11.2/compat >> /etc/ld.so.conf.d/989_cuda-11.conf && ldconfig
1518

@@ -19,7 +22,7 @@ WORKDIR "/var/www"
1922
RUN useradd -m -d "/home/odm" -s /bin/bash odm
2023
COPY --chown=odm:odm . /var/www
2124

22-
RUN npm install --production && mkdir -p tmp
25+
RUN npm install --production && mkdir -p tmp && node index.js --powercycle
2326

2427
RUN chown -R odm:odm /var/www
2528
RUN chown -R odm:odm /code

helpers/odmOptionsToJson.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,33 @@
1818
'''
1919

2020
import sys
21-
import imp
21+
import importlib.util
22+
import importlib.machinery
23+
import types
2224
import argparse
2325
import json
2426
import os
2527

28+
def load_source(module_name, filename):
29+
loader = importlib.machinery.SourceFileLoader(module_name, filename)
30+
module = types.ModuleType(loader.name)
31+
module.__file__ = filename
32+
loader.exec_module(module)
33+
return module
34+
2635
dest_file = os.environ.get("ODM_OPTIONS_TMP_FILE")
2736

2837
sys.path.append(sys.argv[2])
2938

3039
try:
31-
imp.load_source('opendm', sys.argv[2] + '/opendm/__init__.py')
40+
load_source('opendm', sys.argv[2] + '/opendm/__init__.py')
3241
except:
3342
pass
3443
try:
35-
imp.load_source('context', sys.argv[2] + '/opendm/context.py')
44+
load_source('context', sys.argv[2] + '/opendm/context.py')
3645
except:
3746
pass
38-
odm = imp.load_source('config', sys.argv[2] + '/opendm/config.py')
47+
odm = load_source('config', sys.argv[2] + '/opendm/config.py')
3948

4049
options = {}
4150
class ArgumentParserStub(argparse.ArgumentParser):

install_deps.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
3+
if [ -z "$NVM_DIR" ]; then
4+
echo "Error: NVM_DIR environment variable is not set" >&2
5+
exit 1
6+
fi
7+
if [ -z "$NODE_VERSION" ]; then
8+
echo "Error: NODE_VERSION environment variable is not set" >&2
9+
exit 1
10+
fi
11+
12+
for i in {1..20}; do
13+
apt-get update && apt-get install -y curl gpg-agent && break
14+
echo "apt-get failed, retrying... ($i/20)"
15+
sleep 30
16+
done
17+
18+
mkdir -p $NVM_DIR
19+
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash
20+
source $NVM_DIR/nvm.sh
21+
nvm install $NODE_VERSION
22+
nvm alias default $NODE_VERSION
23+
24+
for i in {1..20}; do
25+
apt-get install -y unzip p7zip-full && npm install -g nodemon && break
26+
echo "apt-get failed, retrying... ($i/20)"
27+
sleep 30
28+
done
29+
30+
npm install --production

libs/odmRunner.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ module.exports = {
133133
}
134134

135135
let childProcess = spawn(pythonExe, [shQuote(path.join(__dirname, "..", "helpers", "odmOptionsToJson.py")),
136-
"--project-path", shQuote(config.odm_path), "bogusname"], { env, stdio: 'inherit', shell: true });
136+
"--project-path", shQuote(config.odm_path), "bogusname"], { env, shell: true });
137137

138138
// Cleanup on done
139139
let handleResult = (err, result) => {

node.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
if [ -z "$NVM_DIR" ]; then
4+
echo "Error: NVM_DIR environment variable is not set" >&2
5+
exit 1
6+
fi
7+
8+
source $NVM_DIR/nvm.sh
9+
nvm use $NODE_VERSION
10+
exec node "$@"

0 commit comments

Comments
 (0)