alessandro trinca tornidor commited on
Commit
32656c4
1 Parent(s): 422b339

ci: refactor Dockerfile using nvcr.io/nvidia/pytorch:24.10-py3 as base image, use samgis-lisa==1.0.9

Browse files
Dockerfile CHANGED
@@ -1,19 +1,19 @@
1
  # Include global ARGs at the dockerfile top
2
  ARG ARCH="x86_64"
3
- ARG LAMBDA_TASK_ROOT="/var/task"
4
- ARG FASTAPI_STATIC="${LAMBDA_TASK_ROOT}/static"
5
- ARG PYTHONPATH="${LAMBDA_TASK_ROOT}:${PYTHONPATH}:/usr/local/lib/python3/dist-packages"
6
  ARG POETRY_NO_INTERACTION=1
7
  ARG POETRY_VIRTUALENVS_IN_PROJECT=1
8
  ARG POETRY_VIRTUALENVS_CREATE=1
9
  ARG POETRY_CACHE_DIR=/tmp/poetry_cache
10
 
11
- FROM pytorch/pytorch:2.4.1-cuda12.4-cudnn9-runtime as builder_global
12
 
13
  LABEL authors="alessandro@trinca.tornidor.com"
14
 
15
  ARG ARCH
16
- ARG LAMBDA_TASK_ROOT
17
  ARG PYTHONPATH
18
  ARG POETRY_NO_INTERACTION
19
  ARG POETRY_VIRTUALENVS_IN_PROJECT
@@ -23,24 +23,28 @@ ARG POETRY_CACHE_DIR
23
  RUN echo "ARCH: $ARCH ..."
24
 
25
  RUN echo "ARG POETRY_CACHE_DIR: ${POETRY_CACHE_DIR} ..."
26
- RUN echo "ARG PYTHONPATH: $PYTHONPATH ..."
 
 
 
 
 
27
 
28
  # Set working directory to function root directory
29
- WORKDIR ${LAMBDA_TASK_ROOT}
30
- RUN apt update && apt install git git-lfs software-properties-common -y
31
- RUN git lfs install
32
- RUN git clone https://huggingface.co/spaces/aletrn/samgis-lisa-on-cuda ${LAMBDA_TASK_ROOT}/samgis-lisa-on-cuda && \
33
- ls -l ${LAMBDA_TASK_ROOT}/samgis-lisa-on-cuda/dockerfiles/apt_preferences_ubuntu && \
34
- cp ${LAMBDA_TASK_ROOT}/samgis-lisa-on-cuda/dockerfiles/apt_preferences_ubuntu /etc/apt/preferences && \
35
- ls -l ${LAMBDA_TASK_ROOT}/samgis-lisa-on-cuda/pyproject.toml && \
36
- cp ${LAMBDA_TASK_ROOT}/samgis-lisa-on-cuda/pyproject.toml ${LAMBDA_TASK_ROOT}/pyproject.toml && \
37
- ls -l ${LAMBDA_TASK_ROOT}/samgis-lisa-on-cuda/poetry.lock && \
38
- cp ${LAMBDA_TASK_ROOT}/samgis-lisa-on-cuda/poetry.lock ${LAMBDA_TASK_ROOT}/poetry.lock
39
- COPY ${LAMBDA_TASK_ROOT}/samgis-lisa-on-cuda/dockerfiles/ubuntu.sources /etc/apt/ubuntu.sources
40
- RUN echo "ls samgis-lisa-on-cuda ..."
41
- RUN ls -l /etc/apt/preferences ${LAMBDA_TASK_ROOT}/pyproject.toml ${LAMBDA_TASK_ROOT}/samgis-lisa-on-cuda
42
- RUN ls -l ${LAMBDA_TASK_ROOT}/samgis-lisa-on-cuda/static
43
- RUN add-apt-repository "deb http://archive.ubuntu.com/ubuntu jammy main universe restricted multiverse" && \
44
  add-apt-repository "deb http://archive.ubuntu.com/ubuntu jammy-security main universe restricted multiverse" && \
45
  add-apt-repository "deb http://archive.ubuntu.com/ubuntu jammy-updates main universe restricted multiverse" && \
46
  add-apt-repository "deb http://archive.ubuntu.com/ubuntu noble main universe restricted multiverse" && \
@@ -49,89 +53,92 @@ RUN add-apt-repository "deb http://archive.ubuntu.com/ubuntu jammy main universe
49
 
50
  RUN cat /etc/lsb-release
51
  # avoid segment-geospatial exception caused by missing libGL.so.1 library
52
- RUN echo "BUILDER: check libz.s* before start" && ls -l /usr/lib/${ARCH}-linux-gnu/libz.so*
53
 
54
- RUN apt update && apt upgrade -y && apt install -y libgl1 curl python3-pip && apt clean
55
- #RUN echo "run update noble..."
56
- #RUN apt update
57
- #RUN apt update && apt install -t noble zlib1g -y
58
- RUN echo "BUILDER: check libz.s* after install from trixie" && ls -l /usr/lib/${ARCH}-linux-gnu/libz.so*
 
 
 
59
 
60
  RUN ls -l /etc/apt/sources* /etc/apt/preferences*
61
 
62
- # poetry installation path is NOT within ${LAMBDA_TASK_ROOT}: not needed for runtime docker image
63
- RUN python -m pip install -r ${LAMBDA_TASK_ROOT}/samgis-lisa-on-cuda/requirements_poetry.txt
 
64
 
65
  RUN which poetry && poetry --version && poetry config --list
66
- RUN poetry config virtualenvs.path ${LAMBDA_TASK_ROOT}
67
  RUN poetry config installer.max-workers 7
68
  RUN echo "# poetry config --list #" && poetry config --list
69
- RUN ls -ld ${LAMBDA_TASK_ROOT}/
70
- #RUN . ${LAMBDA_TASK_ROOT}/.venv/bin/activate && ${LAMBDA_TASK_ROOT}/.venv/bin/python --version && ${LAMBDA_TASK_ROOT}/.venv/bin/python -m pip install pip wheel setuptools --upgrade
71
- RUN poetry run python -m pip install pip wheel setuptools --upgrade
 
 
 
72
  RUN poetry install --no-root --no-cache
73
 
74
- RUN git clone https://huggingface.co/aletrn/sam-quantized/ ${LAMBDA_TASK_ROOT}/sam-quantized
75
- RUN git clone -n --depth=1 --filter=tree:0 https://huggingface.co/spaces/aletrn/lisa-on-cuda ${LAMBDA_TASK_ROOT}/lisa-on-cuda && \
76
- cd ${LAMBDA_TASK_ROOT}/lisa-on-cuda && \
77
- git sparse-checkout set --no-cone resources && \
78
- git checkout
79
- WORKDIR ${LAMBDA_TASK_ROOT}
80
- RUN ls -l ${LAMBDA_TASK_ROOT}/*
81
 
 
 
82
 
83
- FROM pytorch/pytorch:2.4.1-cuda12.4-cudnn9-runtime as runtime
 
 
 
 
84
 
85
  ARG ARCH
86
- ARG LAMBDA_TASK_ROOT
87
 
88
- ENV VIRTUAL_ENV=${LAMBDA_TASK_ROOT}/.venv \
89
- PATH="${LAMBDA_TASK_ROOT}/.venv/bin:$PATH"
 
90
 
91
- RUN echo "COPY --from=builder_global /usr/lib/${ARCH}-linux-gnu/libGL.so* /usr/lib/${ARCH}-linux-gnu/"
92
- COPY --from=builder_global /usr/lib/${ARCH}-linux-gnu/libGL.so* /usr/lib/${ARCH}-linux-gnu/
 
93
  RUN echo "RUNTIME: check libz.s* before upgrade" && ls -l /usr/lib/${ARCH}-linux-gnu/libz.so*
94
  RUN echo "RUNTIME: remove libz.s* to force upgrade" && rm /usr/lib/${ARCH}-linux-gnu/libz.so*
95
- COPY --from=builder_global /usr/lib/${ARCH}-linux-gnu/libz.so* /usr/lib/${ARCH}-linux-gnu/
96
  RUN echo "RUNTIME: check libz.s* after copy" && ls -l /usr/lib/${ARCH}-linux-gnu/libz.so*
97
- COPY --from=builder_global ${LAMBDA_TASK_ROOT}/.venv ${LAMBDA_TASK_ROOT}/.venv
98
- RUN echo "COPY --from=builder_global ${LAMBDA_TASK_ROOT}/samgis-lisa-on-cuda/scripts/docker_entrypoint.sh ${LAMBDA_TASK_ROOT}/"
99
- COPY --from=builder_global ${LAMBDA_TASK_ROOT}/samgis-lisa-on-cuda/scripts/docker_entrypoint.sh ${LAMBDA_TASK_ROOT}/
100
- RUN echo "COPY --from=builder_global ${LAMBDA_TASK_ROOT}/samgis-lisa-on-cuda/scripts/entrypoint.sh ${LAMBDA_TASK_ROOT}/"
101
- COPY --from=builder_global ${LAMBDA_TASK_ROOT}/samgis-lisa-on-cuda/scripts/entrypoint.sh ${LAMBDA_TASK_ROOT}/
102
-
103
- RUN echo "new LAMBDA_TASK_ROOT after hidden venv copy => ${LAMBDA_TASK_ROOT}"
104
- RUN ls -ld ${LAMBDA_TASK_ROOT}/
105
- RUN ls -lA ${LAMBDA_TASK_ROOT}/
106
- RUN echo "content of LAMBDA_TASK_ROOT/.venv => ${LAMBDA_TASK_ROOT}/.venv"
107
- RUN ls -ld ${LAMBDA_TASK_ROOT}/.venv
108
- RUN ls -lA ${LAMBDA_TASK_ROOT}/.venv
109
- RUN ls -lA ${LAMBDA_TASK_ROOT}/docker_entrypoint.sh
110
- RUN ls -lA ${LAMBDA_TASK_ROOT}/entrypoint.sh
 
 
 
111
  RUN cat /etc/lsb-release
112
- # deb-src http://it.archive.ubuntu.com/ubuntu/ noble main universe restricted multiverse
113
- # add-apt-repository "deb http://archive.ubuntu.com/ubuntu noble main universe restricted multiverse"
114
- RUN echo "install software-properties-common ..."
115
- COPY --from=builder_global /etc/apt/ubuntu.sources /etc/apt/ubuntu.sources
116
- RUN apt update && apt install software-properties-common -y
117
- RUN echo "install nodejs from source ..."
118
- RUN add-apt-repository "deb-src http://archive.ubuntu.com/ubuntu noble main universe restricted multiverse"
119
- RUN apt update && apt build-dep nodejs && apt -b source -t noble nodejs && apt remove software-properties-common -y && \
120
- apt autoremove && apt clean
121
- RUN which node
122
- RUN which npm
123
 
124
 
125
  ### conditional section
126
- FROM node:20-slim AS node_fastapi
127
 
128
  ENV PNPM_HOME="/pnpm"
129
  ENV PATH="$PNPM_HOME:$PATH"
130
- ARG LAMBDA_TASK_ROOT
131
 
132
  RUN corepack enable
133
 
134
- COPY --from=builder_global ${LAMBDA_TASK_ROOT}/samgis-lisa-on-cuda/static /appnode
135
  WORKDIR /appnode
136
  # RUN echo "pnpm store path:" && pnpm store path
137
  RUN ls -l /appnode
@@ -140,7 +147,7 @@ RUN ls -l /appnode/list_files.html
140
 
141
  FROM node_fastapi AS node_prod_deps
142
 
143
- RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile
144
  # here multiple conditions concatenated to avoid failing on check
145
  RUN if [ ! -d /appnode/node_modules ]; then echo "no node_modules folder" && exit 1; fi
146
 
@@ -160,65 +167,58 @@ RUN if [ ! -d /appnode/dist ]; then echo "no dist folder" && exit 1; fi
160
 
161
  FROM runtime
162
  ARG FASTAPI_STATIC
 
 
 
 
 
163
 
164
- RUN echo "show disk space, df -h ..."
165
- RUN df -h
166
- RUN echo "creating FASTAPI_STATIC folder: ${FASTAPI_STATIC}, use `mkdir -p` to avoid failure if missing parent folder ..."
167
- RUN mkdir -p ${FASTAPI_STATIC}
168
-
169
- COPY --from=builder_global ${LAMBDA_TASK_ROOT}/sam-quantized/machine_learning_models \
170
- ${LAMBDA_TASK_ROOT}/machine_learning_models
171
- RUN ls -ld ${LAMBDA_TASK_ROOT}/machine_learning_models
172
- RUN ls -lh ${LAMBDA_TASK_ROOT}/machine_learning_models
173
- COPY --from=builder_global ${LAMBDA_TASK_ROOT}/lisa-on-cuda/resources ${LAMBDA_TASK_ROOT}/resources
174
- COPY --from=node_prod_deps /appnode/node_modules* ${FASTAPI_STATIC}/node_modules
175
- COPY --from=node_build /appnode/dist* ${FASTAPI_STATIC}/dist
176
- COPY --from=node_build /appnode/list_files.html ${FASTAPI_STATIC}/list_files.html
177
  RUN ls -l ${FASTAPI_STATIC}/
178
  RUN ls -l ${FASTAPI_STATIC}/list_files.html
179
 
180
-
181
- # Include global arg in this stage of the build
182
- ARG LAMBDA_TASK_ROOT="/var/task"
183
- ARG PYTHONPATH="${LAMBDA_TASK_ROOT}:${PYTHONPATH}:/usr/local/lib/python3/dist-packages"
184
- ENV VIRTUAL_ENV=${LAMBDA_TASK_ROOT}/.venv \
185
- PATH="${LAMBDA_TASK_ROOT}/.venv/bin:$PATH"
186
- ENV IS_AWS_LAMBDA=""
187
-
188
  # Set working directory to function root directory
189
- WORKDIR ${LAMBDA_TASK_ROOT}
190
 
 
 
 
191
  RUN ls -l /usr/bin/which
192
- RUN /usr/bin/which python
193
- RUN python --version
194
- RUN node --version
195
- RUN npm --version
196
  RUN echo "PYTHONPATH: ${PYTHONPATH}."
197
  RUN echo "PATH: ${PATH}."
198
- RUN echo "LAMBDA_TASK_ROOT: ${LAMBDA_TASK_ROOT}."
199
- RUN ls -l ${LAMBDA_TASK_ROOT}
200
- RUN ls -ld ${LAMBDA_TASK_ROOT}
201
- RUN ls -l ${LAMBDA_TASK_ROOT}/machine_learning_models
202
- RUN python -c "import sys; print(sys.path)"
203
- RUN python -c "import cv2"
204
- RUN python -c "import fastapi"
205
- RUN python -c "import geopandas"
206
- RUN python -c "import loguru"
207
- RUN python -c "import rasterio"
208
- RUN python -c "import uvicorn"
209
  RUN df -h
210
- RUN echo "LAMBDA_TASK_ROOT /static/:"
211
- RUN ls -l ${LAMBDA_TASK_ROOT}/static/ || true
212
- RUN ls -l ${LAMBDA_TASK_ROOT}/static/dist || true
213
- RUN ls -l ${LAMBDA_TASK_ROOT}/static/node_modules || true
214
  RUN echo "FASTAPI_STATIC:"
215
  RUN ls -l ${FASTAPI_STATIC}/ || true
216
  RUN ls -l ${FASTAPI_STATIC}/dist || true
217
  RUN ls -l ${FASTAPI_STATIC}/node_modules || true
218
- RUN ls -ld ${LAMBDA_TASK_ROOT}/
219
- RUN ls -lA ${LAMBDA_TASK_ROOT}/
220
- RUN ls -l ${LAMBDA_TASK_ROOT}/.venv
221
- RUN ls -l ${LAMBDA_TASK_ROOT}/.venv/bin/activate
222
 
223
  #CMD [
224
  # "source", "/var/task/.venv/bin/activate", "&&",
 
1
  # Include global ARGs at the dockerfile top
2
  ARG ARCH="x86_64"
3
+ ARG WORKDIR_ROOT="/var/task"
4
+ ARG FASTAPI_STATIC="${WORKDIR_ROOT}/static"
5
+ ARG PYTHONPATH="${WORKDIR_ROOT}:${PYTHONPATH}:/usr/local/lib/python3/dist-packages"
6
  ARG POETRY_NO_INTERACTION=1
7
  ARG POETRY_VIRTUALENVS_IN_PROJECT=1
8
  ARG POETRY_VIRTUALENVS_CREATE=1
9
  ARG POETRY_CACHE_DIR=/tmp/poetry_cache
10
 
11
+ FROM nvcr.io/nvidia/pytorch:24.10-py3 AS builder_global
12
 
13
  LABEL authors="alessandro@trinca.tornidor.com"
14
 
15
  ARG ARCH
16
+ ARG WORKDIR_ROOT
17
  ARG PYTHONPATH
18
  ARG POETRY_NO_INTERACTION
19
  ARG POETRY_VIRTUALENVS_IN_PROJECT
 
23
  RUN echo "ARCH: $ARCH ..."
24
 
25
  RUN echo "ARG POETRY_CACHE_DIR: ${POETRY_CACHE_DIR} ..."
26
+ RUN echo "ARG PYTHONPATH: $PYTHONPATH, check for python3 and pip"
27
+ RUN which python3
28
+ RUN python3 --version
29
+ RUN python --version
30
+ RUN which pip
31
+ RUN echo "arg dep:"
32
 
33
  # Set working directory to function root directory
34
+ RUN groupadd -g 999 python && useradd -r -u 999 -g python python
35
+ # Set working directory to function root directory
36
+ RUN mkdir ${WORKDIR_ROOT} && chown python:python ${WORKDIR_ROOT}
37
+ WORKDIR ${WORKDIR_ROOT}
38
+ COPY --chown=python:python requirements_poetry.txt pyproject.toml poetry.lock README.md ${WORKDIR_ROOT}/
39
+
40
+ WORKDIR ${WORKDIR_ROOT}
41
+ COPY --chown=python:python ./requirements_poetry.txt pyproject.toml poetry.lock README.md ${WORKDIR_ROOT}/
42
+ RUN apt update && apt install software-properties-common -y
43
+ COPY --chown=python:python ./dockerfiles/ubuntu.sources /etc/apt/ubuntu.sources
44
+ COPY --chown=python:python ./dockerfiles/apt_preferences_ubuntu /etc/apt/preferences
45
+
46
+ RUN ls -l /etc/apt/preferences ${WORKDIR_ROOT}/pyproject.toml
47
+ RUN apt update && add-apt-repository "deb http://archive.ubuntu.com/ubuntu jammy main universe restricted multiverse" && \
 
48
  add-apt-repository "deb http://archive.ubuntu.com/ubuntu jammy-security main universe restricted multiverse" && \
49
  add-apt-repository "deb http://archive.ubuntu.com/ubuntu jammy-updates main universe restricted multiverse" && \
50
  add-apt-repository "deb http://archive.ubuntu.com/ubuntu noble main universe restricted multiverse" && \
 
53
 
54
  RUN cat /etc/lsb-release
55
  # avoid segment-geospatial exception caused by missing libGL.so.1 library
56
+ RUN echo "BUILDER: check libz.s* before start:" && ls -l /usr/lib/${ARCH}-linux-gnu/libz.so* /lib/${ARCH}-linux-gnu/libz.so*
57
 
58
+ RUN apt update && apt upgrade -y && apt install -y libgl1 curl && apt clean
59
+ RUN echo "run update noble..."
60
+ RUN apt update && apt install -t noble zlib1g -y
61
+ RUN rm /lib/x86_64-linux-gnu/libz.so.1.2* || echo "BUILDER: no /lib/${ARCH}-linux-gnu/libz.so.1.2* found"
62
+ RUN rm /usr/lib/${ARCH}-linux-gnu/libz.so.1.2* || echo "BUILDER: no /usr/lib/${ARCH}-linux-gnu/libz.so.1.2* found"
63
+ RUN ln -sf /usr/lib/${ARCH}-linux-gnu/libz.so.1 /usr/lib/${ARCH}-linux-gnu/libz.so
64
+ RUN ln -sf /lib/${ARCH}-linux-gnu/libz.so.1 /lib/${ARCH}-linux-gnu/libz.so
65
+ RUN echo "BUILDER: check libz.s* after install from noble" && ls -l /usr/lib/${ARCH}-linux-gnu/libz.so* /lib/${ARCH}-linux-gnu/libz.so*
66
 
67
  RUN ls -l /etc/apt/sources* /etc/apt/preferences*
68
 
69
+ # ADD "https://www.random.org/cgi-bin/randbyte?nbytes=10&format=h" skipcache
70
+ # poetry installation path is NOT within ${WORKDIR_ROOT}: not needed for runtime docker image
71
+ RUN python3 -m pip install -r ${WORKDIR_ROOT}/requirements_poetry.txt
72
 
73
  RUN which poetry && poetry --version && poetry config --list
74
+ RUN poetry config virtualenvs.path ${WORKDIR_ROOT}
75
  RUN poetry config installer.max-workers 7
76
  RUN echo "# poetry config --list #" && poetry config --list
77
+ RUN ls -ld ${WORKDIR_ROOT}/
78
+ #RUN . ${WORKDIR_ROOT}/.venv/bin/activate && ${WORKDIR_ROOT}/.venv/bin/python --version && ${WORKDIR_ROOT}/.venv/bin/python -m pip install pip wheel setuptools --upgrade
79
+ RUN echo "current path:"
80
+ RUN pwd
81
+ RUN echo "installing poetry dependencies..."
82
+ RUN poetry run python3 -m pip install pip wheel setuptools --upgrade
83
  RUN poetry install --no-root --no-cache
84
 
85
+ ENV VIRTUAL_ENV=${WORKDIR_ROOT}/.venv \
86
+ PATH="${WORKDIR_ROOT}/.venv/bin:$PATH" \
87
+ PYTHONPATH="${WORKDIR_ROOT}:${WORKDIR_ROOT}/.venv/bin:/usr/local/lib/python3/dist-packages:${PYTHONPATH}"
 
 
 
 
88
 
89
+ RUN ls -l ${WORKDIR_ROOT}/.venv/bin
90
+ RUN ls -ld ${WORKDIR_ROOT}/.venv/bin
91
 
92
+ RUN which python3
93
+ RUN python3 -c "import sys; print(sys.path)"
94
+ RUN python3 -c "import cv2"
95
+
96
+ FROM nvcr.io/nvidia/pytorch:24.10-py3 AS runtime
97
 
98
  ARG ARCH
99
+ ARG WORKDIR_ROOT
100
 
101
+ ENV VIRTUAL_ENV=${WORKDIR_ROOT}/.venv \
102
+ PATH="${WORKDIR_ROOT}/.venv/bin:$PATH" \
103
+ PYTHONPATH="${WORKDIR_ROOT}:${WORKDIR_ROOT}/.venv/bin:/usr/local/lib/python3/dist-packages:${PYTHONPATH}"
104
 
105
+ RUN which python3
106
+ RUN echo "COPY --chown=python:python --from=builder_global /usr/lib/${ARCH}-linux-gnu/libGL.so* /usr/lib/${ARCH}-linux-gnu/"
107
+ COPY --chown=python:python --from=builder_global /usr/lib/${ARCH}-linux-gnu/libGL.so* /usr/lib/${ARCH}-linux-gnu/
108
  RUN echo "RUNTIME: check libz.s* before upgrade" && ls -l /usr/lib/${ARCH}-linux-gnu/libz.so*
109
  RUN echo "RUNTIME: remove libz.s* to force upgrade" && rm /usr/lib/${ARCH}-linux-gnu/libz.so*
110
+ COPY --chown=python:python --from=builder_global /usr/lib/${ARCH}-linux-gnu/libz.so* /usr/lib/${ARCH}-linux-gnu/
111
  RUN echo "RUNTIME: check libz.s* after copy" && ls -l /usr/lib/${ARCH}-linux-gnu/libz.so*
112
+
113
+ COPY --chown=python:python --from=builder_global ${WORKDIR_ROOT}/.venv ${WORKDIR_ROOT}/.venv
114
+ RUN echo "COPY --chown=python:python scripts/docker_entrypoint.sh ${WORKDIR_ROOT}/"
115
+ COPY --chown=python:python ./scripts/docker_entrypoint.sh ${WORKDIR_ROOT}/
116
+ RUN echo "COPY --chown=python:python scripts/entrypoint.sh ${WORKDIR_ROOT}/"
117
+ COPY --chown=python:python ./scripts/entrypoint.sh ${WORKDIR_ROOT}/
118
+ RUN chmod 700 ${WORKDIR_ROOT}/docker_entrypoint.sh ${WORKDIR_ROOT}/entrypoint.sh
119
+ RUN apt update && apt upgrade -y && apt clean
120
+
121
+ RUN echo "new WORKDIR_ROOT after hidden venv COPY --chown=python:python => ${WORKDIR_ROOT}"
122
+ RUN ls -ld ${WORKDIR_ROOT}/
123
+ RUN ls -lA ${WORKDIR_ROOT}/
124
+ RUN echo "content of WORKDIR_ROOT/.venv => ${WORKDIR_ROOT}/.venv"
125
+ RUN ls -ld ${WORKDIR_ROOT}/.venv
126
+ RUN ls -lA ${WORKDIR_ROOT}/.venv
127
+ RUN ls -lA ${WORKDIR_ROOT}/docker_entrypoint.sh
128
+ RUN ls -lA ${WORKDIR_ROOT}/entrypoint.sh
129
  RUN cat /etc/lsb-release
 
 
 
 
 
 
 
 
 
 
 
130
 
131
 
132
  ### conditional section
133
+ FROM node:22 AS node_fastapi
134
 
135
  ENV PNPM_HOME="/pnpm"
136
  ENV PATH="$PNPM_HOME:$PATH"
137
+ ARG WORKDIR_ROOT
138
 
139
  RUN corepack enable
140
 
141
+ COPY ./static /appnode
142
  WORKDIR /appnode
143
  # RUN echo "pnpm store path:" && pnpm store path
144
  RUN ls -l /appnode
 
147
 
148
  FROM node_fastapi AS node_prod_deps
149
 
150
+ RUN --mount=type=cache,id=pnpm,target=/pnpm/store; pnpm install --prod --frozen-lockfile
151
  # here multiple conditions concatenated to avoid failing on check
152
  RUN if [ ! -d /appnode/node_modules ]; then echo "no node_modules folder" && exit 1; fi
153
 
 
167
 
168
  FROM runtime
169
  ARG FASTAPI_STATIC
170
+ # Include global arg in this stage of the build
171
+ ARG WORKDIR_ROOT="/var/task"
172
+ ENV VIRTUAL_ENV=${WORKDIR_ROOT}/.venv \
173
+ PATH="${WORKDIR_ROOT}/.venv/bin:$PATH"
174
+ ENV IS_AWS_LAMBDA=""
175
 
176
+ RUN mkdir ${FASTAPI_STATIC}
177
+
178
+ COPY --chown=python:python ./app.py ${WORKDIR_ROOT}/
179
+ COPY --chown=python:python ./sam-quantized/machine_learning_models ${WORKDIR_ROOT}/machine_learning_models
180
+ COPY --chown=python:python --from=node_prod_deps /appnode/node_modules* ${FASTAPI_STATIC}/node_modules
181
+ COPY --chown=python:python --from=node_build /appnode/dist* ${FASTAPI_STATIC}/dist
182
+ COPY --chown=python:python static/list_files.html ${FASTAPI_STATIC}/
 
 
 
 
 
 
183
  RUN ls -l ${FASTAPI_STATIC}/
184
  RUN ls -l ${FASTAPI_STATIC}/list_files.html
185
 
 
 
 
 
 
 
 
 
186
  # Set working directory to function root directory
187
+ WORKDIR ${WORKDIR_ROOT}
188
 
189
+ # ADD "https://www.random.org/cgi-bin/randbyte?nbytes=10&format=h" skipcache
190
+ RUN ls -lA ${WORKDIR_ROOT}/
191
+ RUN ls -ld ${WORKDIR_ROOT}/.venv
192
  RUN ls -l /usr/bin/which
193
+ RUN /usr/bin/which python3
194
+ RUN python3 --version
195
+ # RUN node --version
196
+ # RUN npm --version
197
  RUN echo "PYTHONPATH: ${PYTHONPATH}."
198
  RUN echo "PATH: ${PATH}."
199
+ RUN echo "WORKDIR_ROOT: ${WORKDIR_ROOT}."
200
+ RUN ls -l ${WORKDIR_ROOT}
201
+ RUN ls -ld ${WORKDIR_ROOT}
202
+ RUN ls -l ${WORKDIR_ROOT}/machine_learning_models
203
+ RUN python3 -c "import sys; print(sys.path)"
204
+ RUN python3 -c "import cv2"
205
+ RUN python3 -c "import fastapi"
206
+ RUN python3 -c "import geopandas"
207
+ RUN python3 -c "import rasterio"
208
+ RUN python3 -c "import uvicorn"
 
209
  RUN df -h
210
+ RUN echo "WORKDIR_ROOT /static/:"
211
+ RUN ls -l ${WORKDIR_ROOT}/static/ || true
212
+ RUN ls -l ${WORKDIR_ROOT}/static/dist || true
213
+ RUN ls -l ${WORKDIR_ROOT}/static/node_modules || true
214
  RUN echo "FASTAPI_STATIC:"
215
  RUN ls -l ${FASTAPI_STATIC}/ || true
216
  RUN ls -l ${FASTAPI_STATIC}/dist || true
217
  RUN ls -l ${FASTAPI_STATIC}/node_modules || true
218
+ RUN ls -ld ${WORKDIR_ROOT}/
219
+ RUN ls -lA ${WORKDIR_ROOT}/
220
+ RUN ls -l ${WORKDIR_ROOT}/.venv
221
+ RUN ls -l ${WORKDIR_ROOT}/.venv/bin/activate
222
 
223
  #CMD [
224
  # "source", "/var/task/.venv/bin/activate", "&&",
app.py CHANGED
@@ -240,7 +240,7 @@ async def index() -> FileResponse:
240
  return FileResponse(path=str(static_dist_folder / "index.html"), media_type="text/html")
241
 
242
 
243
- app_logger.info(f"creating gradio interface...")
244
  gr_interface = get_gradio_interface_geojson(infer_lisa_gradio)
245
  app_logger.info(f"gradio interface created, mounting gradio app on url {vite_gradio_url} within FastAPI...")
246
  app = gr.mount_gradio_app(app, gr_interface, path=vite_gradio_url)
 
240
  return FileResponse(path=str(static_dist_folder / "index.html"), media_type="text/html")
241
 
242
 
243
+ app_logger.info("creating gradio interface...")
244
  gr_interface = get_gradio_interface_geojson(infer_lisa_gradio)
245
  app_logger.info(f"gradio interface created, mounting gradio app on url {vite_gradio_url} within FastAPI...")
246
  app = gr.mount_gradio_app(app, gr_interface, path=vite_gradio_url)
poetry.lock CHANGED
The diff for this file is too large to render. See raw diff
 
pyproject.toml CHANGED
@@ -1,6 +1,6 @@
1
  [tool.poetry]
2
  name = "samgis-lisa-on-cuda"
3
- version = "1.6.0"
4
  description = "A VLM backend for machine learning instance segmentation on geospatial data that uses LISA (Reasoning Segmentation via Large Language Model). This demo uses a dedicated GPU."
5
  authors = ["alessandro trinca tornidor <alessandro@trinca.tornidor.com>"]
6
  license = "MIT license"
@@ -9,11 +9,11 @@ package-mode = false
9
 
10
  [metadata]
11
  name = "samgis-lisa-on-cuda"
12
- version = "1.6.0"
13
 
14
  [tool.poetry.dependencies]
15
  python = ">=3.10,<3.11"
16
- samgis-lisa = "1.0.8"
17
 
18
  [tool.poetry.group.test]
19
  optional = true
 
1
  [tool.poetry]
2
  name = "samgis-lisa-on-cuda"
3
+ version = "1.6.1"
4
  description = "A VLM backend for machine learning instance segmentation on geospatial data that uses LISA (Reasoning Segmentation via Large Language Model). This demo uses a dedicated GPU."
5
  authors = ["alessandro trinca tornidor <alessandro@trinca.tornidor.com>"]
6
  license = "MIT license"
 
9
 
10
  [metadata]
11
  name = "samgis-lisa-on-cuda"
12
+ version = "1.6.1"
13
 
14
  [tool.poetry.dependencies]
15
  python = ">=3.10,<3.11"
16
+ samgis-lisa = "1.0.9"
17
 
18
  [tool.poetry.group.test]
19
  optional = true
requirements.txt CHANGED
@@ -1 +1 @@
1
- samgis-lisa==1.0.8
 
1
+ samgis-lisa==1.0.9
requirements_no_versions.txt CHANGED
@@ -1,2 +1 @@
1
- samgis-lisa
2
- samgis_lisa
 
1
+ samgis-lisa
 
requirements_poetry.txt CHANGED
@@ -1 +1 @@
1
- poetry==1.8.3
 
1
+ poetry==1.8.5
scripts/docker_entrypoint.sh CHANGED
@@ -9,7 +9,7 @@ source ${WORKDIR}/.venv/bin/activate
9
  which python
10
  python --version
11
 
12
- chmod +x ${WORKDIR}/entrypoint.sh
13
  bash ${WORKDIR}/entrypoint.sh
14
 
15
  exit 0
 
9
  which python
10
  python --version
11
 
12
+ chmod 700 ${WORKDIR}/entrypoint.sh
13
  bash ${WORKDIR}/entrypoint.sh
14
 
15
  exit 0
scripts/entrypoint.sh CHANGED
@@ -19,7 +19,7 @@ CUDA_VISIBLE_DEVICES=$(nvidia-smi --query-gpu=memory.free,index --format=csv,nou
19
  echo "calculated CUDA_VISIBLE_DEVICES env variable: ${CUDA_VISIBLE_DEVICES}."
20
  export CUDA_VISIBLE_DEVICES
21
 
22
- echo "running command 'uvicorn wrappers.fastapi_wrapper:app --host 0.0.0.0 --port 7860'..."
23
- uvicorn wrappers.fastapi_wrapper:app --host 0.0.0.0 --port 7860
24
 
25
  exit 0
 
19
  echo "calculated CUDA_VISIBLE_DEVICES env variable: ${CUDA_VISIBLE_DEVICES}."
20
  export CUDA_VISIBLE_DEVICES
21
 
22
+ echo "running command 'uvicorn app:app --host 0.0.0.0 --port 7860'..."
23
+ uvicorn app:app --host 0.0.0.0 --port 7860
24
 
25
  exit 0