alessandro trinca tornidor commited on
Commit
d6f09d7
1 Parent(s): add7a21

ci: try removing dockerfiles folder to avoid keep using it during HuggingFace build

Browse files
.idea/vcs.xml CHANGED
@@ -2,5 +2,6 @@
2
  <project version="4">
3
  <component name="VcsDirectoryMappings">
4
  <mapping directory="" vcs="Git" />
 
5
  </component>
6
  </project>
 
2
  <project version="4">
3
  <component name="VcsDirectoryMappings">
4
  <mapping directory="" vcs="Git" />
5
+ <mapping directory="$PROJECT_DIR$/sam-quantized" vcs="Git" />
6
  </component>
7
  </project>
dockerfiles/Dockerfile DELETED
@@ -1,207 +0,0 @@
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
- ARG DEPENDENCY_GROUP=fastapi
11
-
12
-
13
- FROM pytorch/pytorch:2.2.2-cuda12.1-cudnn8-runtime as builder_global
14
-
15
- LABEL authors="alessandro@trinca.tornidor.com"
16
-
17
- ARG ARCH
18
- ARG LAMBDA_TASK_ROOT
19
- ARG PYTHONPATH
20
- ARG POETRY_NO_INTERACTION
21
- ARG POETRY_VIRTUALENVS_IN_PROJECT
22
- ARG POETRY_VIRTUALENVS_CREATE
23
- ARG POETRY_CACHE_DIR
24
- ARG DEPENDENCY_GROUP
25
-
26
- RUN echo "ARCH: $ARCH ..."
27
-
28
- RUN echo "ARG POETRY_CACHE_DIR: ${POETRY_CACHE_DIR} ..."
29
- RUN echo "ARG PYTHONPATH: $PYTHONPATH ..."
30
- RUN test -n ${DEPENDENCY_GROUP:?}
31
- RUN echo "python DEPENDENCY_GROUP: ${DEPENDENCY_GROUP} ..."
32
- RUN echo "arg dep:"
33
-
34
- # Set working directory to function root directory
35
- WORKDIR ${LAMBDA_TASK_ROOT}
36
- COPY requirements_poetry.txt pyproject.toml poetry.lock README.md ${LAMBDA_TASK_ROOT}/
37
-
38
- RUN cat /etc/lsb-release
39
- # avoid segment-geospatial exception caused by missing libGL.so.1 library
40
- RUN echo "BUILDER: check libz.s* before start" && ls -l /usr/lib/${ARCH}-linux-gnu/libz.so*
41
-
42
- RUN apt update && apt upgrade -y && apt install -y libgl1 curl python3-pip git-lfs && apt clean
43
- COPY ./dockerfiles/apt_preferences_ubuntu /etc/apt/preferences
44
- COPY ./dockerfiles/ubuntu.sources /etc/apt/sources.list.d/ubuntu.sources
45
- #RUN echo "run update noble..."
46
- #RUN apt update
47
- #RUN apt update && apt install -t noble zlib1g -y
48
- RUN git lfs install
49
- RUN echo "BUILDER: check libz.s* after install from trixie" && ls -l /usr/lib/${ARCH}-linux-gnu/libz.so*
50
-
51
- RUN ls -l /etc/apt/sources* /etc/apt/preferences*
52
-
53
- # poetry installation path is NOT within ${LAMBDA_TASK_ROOT}: not needed for runtime docker image
54
- RUN python -m pip install -r ${LAMBDA_TASK_ROOT}/requirements_poetry.txt
55
-
56
- RUN which poetry && poetry --version && poetry config --list
57
- RUN poetry config virtualenvs.path ${LAMBDA_TASK_ROOT}
58
- RUN poetry config installer.max-workers 7
59
- RUN echo "# poetry config --list #" && poetry config --list
60
- RUN ls -ld ${LAMBDA_TASK_ROOT}/
61
- #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
62
- RUN poetry run python -m pip install pip wheel setuptools --upgrade
63
- RUN poetry install --with ${DEPENDENCY_GROUP} --no-root --no-cache
64
-
65
- RUN git clone https://huggingface.co/aletrn/sam-quantized/ ${LAMBDA_TASK_ROOT}/sam-quantized
66
- RUN git clone -n --depth=1 --filter=tree:0 https://huggingface.co/spaces/aletrn/lisa-on-cuda ${LAMBDA_TASK_ROOT}/lisa-on-cuda && \
67
- cd ${LAMBDA_TASK_ROOT}/lisa-on-cuda && \
68
- git sparse-checkout set --no-cone resources && \
69
- git checkout
70
- WORKDIR ${LAMBDA_TASK_ROOT}
71
- RUN ls -l ${LAMBDA_TASK_ROOT}/*
72
-
73
-
74
- FROM pytorch/pytorch:2.2.2-cuda12.1-cudnn8-runtime as runtime
75
-
76
- ARG ARCH
77
- ARG LAMBDA_TASK_ROOT
78
-
79
- ENV VIRTUAL_ENV=${LAMBDA_TASK_ROOT}/.venv \
80
- PATH="${LAMBDA_TASK_ROOT}/.venv/bin:$PATH"
81
-
82
- RUN echo "COPY --from=builder_global /usr/lib/${ARCH}-linux-gnu/libGL.so* /usr/lib/${ARCH}-linux-gnu/"
83
- COPY --from=builder_global /usr/lib/${ARCH}-linux-gnu/libGL.so* /usr/lib/${ARCH}-linux-gnu/
84
- RUN echo "RUNTIME: check libz.s* before upgrade" && ls -l /usr/lib/${ARCH}-linux-gnu/libz.so*
85
- RUN echo "RUNTIME: remove libz.s* to force upgrade" && rm /usr/lib/${ARCH}-linux-gnu/libz.so*
86
- COPY --from=builder_global /usr/lib/${ARCH}-linux-gnu/libz.so* /usr/lib/${ARCH}-linux-gnu/
87
- RUN echo "RUNTIME: check libz.s* after copy" && ls -l /usr/lib/${ARCH}-linux-gnu/libz.so*
88
- COPY --from=builder_global ${LAMBDA_TASK_ROOT}/.venv ${LAMBDA_TASK_ROOT}/.venv
89
-
90
- RUN echo "new LAMBDA_TASK_ROOT after hidden venv copy => ${LAMBDA_TASK_ROOT}"
91
- RUN ls -ld ${LAMBDA_TASK_ROOT}/
92
- RUN ls -lA ${LAMBDA_TASK_ROOT}/
93
- RUN echo "content of LAMBDA_TASK_ROOT/.venv => ${LAMBDA_TASK_ROOT}/.venv"
94
- RUN ls -ld ${LAMBDA_TASK_ROOT}/.venv
95
- RUN ls -lA ${LAMBDA_TASK_ROOT}/.venv
96
-
97
-
98
- ### conditional section
99
- FROM node:20-slim AS node_fastapi
100
-
101
- ARG DEPENDENCY_GROUP
102
- ENV PNPM_HOME="/pnpm"
103
- ENV PATH="$PNPM_HOME:$PATH"
104
-
105
- RUN corepack enable
106
-
107
- COPY ./static /appnode
108
- WORKDIR /appnode
109
- # RUN if [ "${DEPENDENCY_GROUP}" = "fastapi" ]; then echo "pnpm store path:" && pnpm store path; fi
110
- RUN ls -l /appnode
111
- RUN ls -l /appnode/list_files.html
112
-
113
-
114
- FROM node_fastapi AS node_prod_deps
115
-
116
- ARG DEPENDENCY_GROUP
117
- RUN --mount=type=cache,id=pnpm,target=/pnpm/store if [ "${DEPENDENCY_GROUP}" = "fastapi" ]; then \
118
- pnpm install --prod --frozen-lockfile; else \
119
- echo "DEPENDENCY_GROUP 1: ${DEPENDENCY_GROUP} ..."; fi
120
- # here multiple conditions concatenated to avoid failing on check
121
- RUN if [ "${DEPENDENCY_GROUP}" = "fastapi" ]; then if [ ! -d /appnode/node_modules ]; then \
122
- echo "no node_modules folder" && exit 1; fi; fi
123
-
124
-
125
- FROM node_fastapi AS node_build
126
-
127
- ARG DEPENDENCY_GROUP
128
- ARG VITE__MAP_DESCRIPTION
129
- ARG VITE__SAMGIS_SPACE
130
- RUN echo "VITE__MAP_DESCRIPTION:" ${VITE__MAP_DESCRIPTION}
131
- RUN echo "VITE__SAMGIS_SPACE:" ${VITE__SAMGIS_SPACE}
132
-
133
- RUN --mount=type=cache,id=pnpm,target=/pnpm/store if [ "${DEPENDENCY_GROUP}" = "fastapi" ]; then \
134
- pnpm install --frozen-lockfile; else \
135
- echo "DEPENDENCY_GROUP 2: ${DEPENDENCY_GROUP} ..."; fi
136
- RUN --mount=type=cache,id=pnpm,target=/pnpm/store if [ "${DEPENDENCY_GROUP}" = "fastapi" ]; then pnpm build; fi
137
- RUN --mount=type=cache,id=pnpm,target=/pnpm/store if [ "${DEPENDENCY_GROUP}" = "fastapi" ]; then \
138
- pnpm tailwindcss -i /appnode/src/input.css -o /appnode/dist/output.css; fi
139
- RUN if [ "${DEPENDENCY_GROUP}" = "fastapi" ]; then if [ ! -d /appnode/dist ]; then echo "no dist folder" && exit 1; fi; fi
140
-
141
-
142
- FROM runtime
143
- ARG FASTAPI_STATIC
144
-
145
- RUN echo "show disk space, df -h ..."
146
- RUN df -h
147
- RUN echo "creating FASTAPI_STATIC folder: ${FASTAPI_STATIC}, use `mkdir -p` to avoid failure if missing parent folder ..."
148
- RUN mkdir -p ${FASTAPI_STATIC}
149
-
150
- COPY --from=builder_global ${LAMBDA_TASK_ROOT}/sam-quantized/machine_learning_models \
151
- ${LAMBDA_TASK_ROOT}/machine_learning_models
152
- RUN ls -ld ${LAMBDA_TASK_ROOT}/machine_learning_models
153
- RUN ls -lh ${LAMBDA_TASK_ROOT}/machine_learning_models
154
- COPY --from=builder_global ${LAMBDA_TASK_ROOT}/lisa-on-cuda/resources ${LAMBDA_TASK_ROOT}/resources
155
- COPY --from=node_prod_deps /appnode/node_modules* ${FASTAPI_STATIC}/node_modules
156
- COPY --from=node_build /appnode/dist* ${FASTAPI_STATIC}/dist
157
- COPY --from=node_build /appnode/list_files.html ${FASTAPI_STATIC}/list_files.html
158
- RUN ls -l ${FASTAPI_STATIC}/
159
- RUN ls -l ${FASTAPI_STATIC}/list_files.html
160
-
161
-
162
- # Include global arg in this stage of the build
163
- ARG LAMBDA_TASK_ROOT="/var/task"
164
- ARG PYTHONPATH="${LAMBDA_TASK_ROOT}:${PYTHONPATH}:/usr/local/lib/python3/dist-packages"
165
- ENV VIRTUAL_ENV=${LAMBDA_TASK_ROOT}/.venv \
166
- PATH="${LAMBDA_TASK_ROOT}/.venv/bin:$PATH"
167
- ENV IS_AWS_LAMBDA=""
168
-
169
- # Set working directory to function root directory
170
- WORKDIR ${LAMBDA_TASK_ROOT}
171
-
172
- COPY samgis_lisa_on_cuda ${LAMBDA_TASK_ROOT}/samgis_lisa_on_cuda
173
- COPY wrappers ${LAMBDA_TASK_ROOT}/wrappers
174
- COPY scripts ${LAMBDA_TASK_ROOT}/scripts
175
- RUN chmod +x ${LAMBDA_TASK_ROOT}/scripts/entrypoint.sh
176
- RUN chmod +x ${LAMBDA_TASK_ROOT}/scripts/docker_entrypoint.sh
177
- RUN ls -l ${LAMBDA_TASK_ROOT}/scripts/entrypoint.sh ${LAMBDA_TASK_ROOT}/scripts/docker_entrypoint.sh
178
-
179
- RUN ls -l /usr/bin/which
180
- RUN /usr/bin/which python
181
- RUN python --version
182
- RUN echo "PYTHONPATH: ${PYTHONPATH}."
183
- RUN echo "PATH: ${PATH}."
184
- RUN echo "LAMBDA_TASK_ROOT: ${LAMBDA_TASK_ROOT}."
185
- RUN ls -l ${LAMBDA_TASK_ROOT}
186
- RUN ls -ld ${LAMBDA_TASK_ROOT}
187
- RUN ls -l ${LAMBDA_TASK_ROOT}/machine_learning_models
188
- RUN python -c "import sys; print(sys.path)"
189
- RUN python -c "import cv2"
190
- RUN python -c "import fastapi"
191
- RUN python -c "import geopandas"
192
- RUN python -c "import loguru"
193
- RUN python -c "import rasterio"
194
- RUN python -c "import uvicorn"
195
- RUN df -h
196
- RUN ls -l ${LAMBDA_TASK_ROOT}/samgis_lisa_on_cuda/
197
- RUN ls -l ${LAMBDA_TASK_ROOT}/wrappers/
198
- RUN echo "LAMBDA_TASK_ROOT /static/:"
199
- RUN ls -l ${LAMBDA_TASK_ROOT}/static/ || true
200
- RUN ls -l ${LAMBDA_TASK_ROOT}/static/dist || true
201
- RUN ls -l ${LAMBDA_TASK_ROOT}/static/node_modules || true
202
- RUN echo "FASTAPI_STATIC:"
203
- RUN ls -l ${FASTAPI_STATIC}/ || true
204
- RUN ls -l ${FASTAPI_STATIC}/dist || true
205
- RUN ls -l ${FASTAPI_STATIC}/node_modules || true
206
-
207
- CMD ["/var/task/scripts/docker_entrypoint.sh"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
dockerfiles/apt_preferences_debian DELETED
@@ -1,9 +0,0 @@
1
- Explanation: Uninstall or do not install any Debian-originated
2
- Explanation: package versions other than those in the stable distro
3
- Package: *
4
- Pin: release a=stable
5
- Pin-Priority: 900
6
-
7
- Package: zlib1g
8
- Pin: release a=trixie
9
- Pin-Priority: -10
 
 
 
 
 
 
 
 
 
 
dockerfiles/apt_preferences_ubuntu DELETED
@@ -1,9 +0,0 @@
1
- Explanation: Uninstall or do not install any Debian-originated
2
- Explanation: package versions other than those in the stable distro
3
- Package: *
4
- Pin: release a=stable
5
- Pin-Priority: 900
6
-
7
- Package: zlib1g
8
- Pin: release a=noble
9
- Pin-Priority: -10
 
 
 
 
 
 
 
 
 
 
dockerfiles/debian.sources DELETED
@@ -1,17 +0,0 @@
1
- Types: deb deb-src
2
- URIs: http://deb.debian.org/debian
3
- Suites: bookworm bookworm-updates
4
- Components: main
5
- Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
6
-
7
- Types: deb deb-src
8
- URIs: http://deb.debian.org/debian-security
9
- Suites: bookworm-security
10
- Components: main
11
- Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
12
-
13
- Types: deb
14
- URIs: http://deb.debian.org/debian
15
- Suites: trixie
16
- Components: main
17
- Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
dockerfiles/dockerfile-lisa-base DELETED
@@ -1,139 +0,0 @@
1
- # Include global ARGs at the dockerfile top
2
- ARG ARCH="x86_64"
3
- ARG LAMBDA_TASK_ROOT="/var/task"
4
- ENV XDG_CACHE_HOME="/data"
5
- ARG FASTAPI_STATIC="${XDG_CACHE_HOME}/static"
6
- ARG PYTHONPATH="${LAMBDA_TASK_ROOT}:${PYTHONPATH}:/usr/local/lib/python3/dist-packages"
7
- ARG POETRY_NO_INTERACTION=1
8
- ARG POETRY_VIRTUALENVS_IN_PROJECT=1
9
- ARG POETRY_VIRTUALENVS_CREATE=1
10
- ARG POETRY_CACHE_DIR=/tmp/poetry_cache
11
- ARG DEPENDENCY_GROUP=fastapi
12
-
13
-
14
- FROM nvcr.io/nvidia/pytorch:24.01-py3 as builder_global
15
-
16
- LABEL authors="alessandro@trinca.tornidor.com"
17
-
18
- ARG ARCH
19
- ARG LAMBDA_TASK_ROOT
20
- ARG PYTHONPATH
21
- ARG POETRY_NO_INTERACTION
22
- ARG POETRY_VIRTUALENVS_IN_PROJECT
23
- ARG POETRY_VIRTUALENVS_CREATE
24
- ARG POETRY_CACHE_DIR
25
- ARG DEPENDENCY_GROUP
26
-
27
- RUN echo "ARCH: $ARCH ..."
28
-
29
- RUN echo "ARG POETRY_CACHE_DIR: ${POETRY_CACHE_DIR} ..."
30
- RUN echo "ARG PYTHONPATH: $PYTHONPATH ..."
31
- RUN test -n ${DEPENDENCY_GROUP:?}
32
- RUN echo "python DEPENDENCY_GROUP: ${DEPENDENCY_GROUP} ..."
33
- RUN echo "arg dep:"
34
-
35
- # Set working directory to function root directory
36
- WORKDIR ${LAMBDA_TASK_ROOT}
37
- COPY requirements_poetry.txt pyproject.toml poetry.lock README.md ${LAMBDA_TASK_ROOT}/
38
-
39
- RUN cat /etc/lsb-release
40
- # avoid segment-geospatial exception caused by missing libGL.so.1 library
41
- RUN echo "BUILDER: check libz.s* before start" && ls -l /usr/lib/${ARCH}-linux-gnu/libz.so*
42
-
43
- RUN apt update && apt upgrade -y && apt install -y libgl1 curl python3-pip git-lfs && apt clean
44
- COPY ./dockerfiles/apt_preferences_ubuntu /etc/apt/preferences
45
- COPY ./dockerfiles/ubuntu.sources /etc/apt/sources.list.d/ubuntu.sources
46
- #RUN echo "run update noble..."
47
- #RUN apt update
48
- #RUN apt update && apt install -t noble zlib1g -y
49
- RUN git lfs install
50
- RUN echo "BUILDER: check libz.s* after install from trixie" && ls -l /usr/lib/${ARCH}-linux-gnu/libz.so*
51
-
52
- RUN ls -l /etc/apt/sources* /etc/apt/preferences*
53
-
54
- # poetry installation path is NOT within ${LAMBDA_TASK_ROOT}: not needed for runtime docker image
55
- RUN python -m pip install -r ${LAMBDA_TASK_ROOT}/requirements_poetry.txt
56
-
57
- RUN which poetry && poetry --version && poetry config --list
58
- RUN poetry config virtualenvs.path ${LAMBDA_TASK_ROOT}
59
- RUN poetry config installer.max-workers 7
60
- RUN echo "# poetry config --list #" && poetry config --list
61
- RUN ls -ld ${LAMBDA_TASK_ROOT}/
62
- #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
63
- RUN poetry run python -m pip install pip wheel setuptools --upgrade
64
- RUN poetry install --with ${DEPENDENCY_GROUP} --no-root -vvv
65
-
66
- RUN git clone https://huggingface.co/aletrn/sam-quantized/ ${LAMBDA_TASK_ROOT}/sam-quantized
67
-
68
- FROM nvcr.io/nvidia/pytorch:24.01-py3 as runtime
69
-
70
- ARG ARCH
71
- ARG LAMBDA_TASK_ROOT
72
-
73
- ENV VIRTUAL_ENV=${LAMBDA_TASK_ROOT}/.venv \
74
- PATH="${LAMBDA_TASK_ROOT}/.venv/bin:$PATH"
75
-
76
- RUN echo "COPY --from=builder_global /usr/lib/${ARCH}-linux-gnu/libGL.so* /usr/lib/${ARCH}-linux-gnu/"
77
- COPY --from=builder_global /usr/lib/${ARCH}-linux-gnu/libGL.so* /usr/lib/${ARCH}-linux-gnu/
78
- RUN echo "RUNTIME: check libz.s* before upgrade" && ls -l /usr/lib/${ARCH}-linux-gnu/libz.so*
79
- RUN echo "RUNTIME: remove libz.s* to force upgrade" && rm /usr/lib/${ARCH}-linux-gnu/libz.so*
80
- COPY --from=builder_global /usr/lib/${ARCH}-linux-gnu/libz.so* /usr/lib/${ARCH}-linux-gnu/
81
- RUN echo "RUNTIME: check libz.s* after copy" && ls -l /usr/lib/${ARCH}-linux-gnu/libz.so*
82
- COPY --from=builder_global ${LAMBDA_TASK_ROOT}/.venv ${LAMBDA_TASK_ROOT}/.venv
83
-
84
- RUN echo "new LAMBDA_TASK_ROOT after hidden venv copy => ${LAMBDA_TASK_ROOT}"
85
- RUN ls -ld ${LAMBDA_TASK_ROOT}/
86
- RUN ls -lA ${LAMBDA_TASK_ROOT}/
87
- RUN ls -ld ${LAMBDA_TASK_ROOT}/.venv
88
- RUN ls -lA ${LAMBDA_TASK_ROOT}/.venv
89
-
90
-
91
- ### conditional section
92
- FROM node:20-slim AS node_fastapi
93
-
94
- ARG DEPENDENCY_GROUP
95
- ENV PNPM_HOME="/pnpm"
96
- ENV PATH="$PNPM_HOME:$PATH"
97
-
98
- RUN corepack enable
99
-
100
- COPY ./static /appnode
101
- WORKDIR /appnode
102
- # RUN if [ "${DEPENDENCY_GROUP}" = "fastapi" ]; then echo "pnpm store path:" && pnpm store path; fi
103
-
104
-
105
- FROM node_fastapi AS node_prod_deps
106
-
107
- ARG DEPENDENCY_GROUP
108
- RUN --mount=type=cache,id=pnpm,target=/pnpm/store if [ "${DEPENDENCY_GROUP}" = "fastapi" ]; then \
109
- pnpm install --prod --frozen-lockfile; else \
110
- echo "DEPENDENCY_GROUP 1: ${DEPENDENCY_GROUP} ..."; fi
111
- # here multiple conditions concatenated to avoid failing on check
112
- RUN if [ "${DEPENDENCY_GROUP}" = "fastapi" ]; then if [ ! -d /appnode/node_modules ]; then echo "no node_modules folder" && exit 1; fi; fi
113
-
114
-
115
- FROM node_fastapi AS node_build
116
-
117
- ARG DEPENDENCY_GROUP
118
- ARG VITE__MAP_DESCRIPTION
119
- ARG VITE__SAMGIS_SPACE
120
- RUN echo "VITE__MAP_DESCRIPTION:" ${VITE__MAP_DESCRIPTION}
121
- RUN echo "VITE__SAMGIS_SPACE:" ${VITE__SAMGIS_SPACE}
122
-
123
- RUN --mount=type=cache,id=pnpm,target=/pnpm/store if [ "${DEPENDENCY_GROUP}" = "fastapi" ]; then \
124
- pnpm install --frozen-lockfile; else \
125
- echo "DEPENDENCY_GROUP 2: ${DEPENDENCY_GROUP} ..."; fi
126
- RUN --mount=type=cache,id=pnpm,target=/pnpm/store if [ "${DEPENDENCY_GROUP}" = "fastapi" ]; then pnpm build; fi
127
- RUN --mount=type=cache,id=pnpm,target=/pnpm/store if [ "${DEPENDENCY_GROUP}" = "fastapi" ]; then \
128
- pnpm tailwindcss -i /appnode/src/input.css -o /appnode/dist/output.css; fi
129
- RUN if [ "${DEPENDENCY_GROUP}" = "fastapi" ]; then if [ ! -d /appnode/dist ]; then echo "no dist folder" && exit 1; fi; fi
130
-
131
-
132
- FROM runtime
133
- ARG FASTAPI_STATIC
134
- RUN mkdir ${FASTAPI_STATIC}
135
-
136
- COPY --from=builder_global ${LAMBDA_TASK_ROOT}/sam-quantized/machine_learning_models \
137
- ${LAMBDA_TASK_ROOT}/machine_learning_models
138
- COPY --from=node_prod_deps /appnode/node_modules* ${FASTAPI_STATIC}/node_modules
139
- COPY --from=node_build /appnode/dist* ${FASTAPI_STATIC}/dist
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
dockerfiles/dockerfile-lisa-predictions DELETED
@@ -1,38 +0,0 @@
1
- FROM registry.gitlab.com/aletrn/gis-lisa-base:1.2.3
2
-
3
- # Include global arg in this stage of the build
4
- ARG LAMBDA_TASK_ROOT="/var/task"
5
- ARG PYTHONPATH="${LAMBDA_TASK_ROOT}:${PYTHONPATH}:/usr/local/lib/python3/dist-packages"
6
- ENV VIRTUAL_ENV=${LAMBDA_TASK_ROOT}/.venv \
7
- PATH="${LAMBDA_TASK_ROOT}/.venv/bin:$PATH"
8
- ENV IS_AWS_LAMBDA=""
9
-
10
- # Set working directory to function root directory
11
- WORKDIR ${LAMBDA_TASK_ROOT}
12
-
13
- COPY samgis_lisa_on_cuda ${LAMBDA_TASK_ROOT}/samgis_lisa_on_cuda
14
- COPY wrappers ${LAMBDA_TASK_ROOT}/wrappers
15
-
16
- RUN ls -l /usr/bin/which
17
- RUN /usr/bin/which python
18
- RUN python -v
19
- RUN echo "PYTHONPATH: ${PYTHONPATH}."
20
- RUN echo "PATH: ${PATH}."
21
- RUN echo "LAMBDA_TASK_ROOT: ${LAMBDA_TASK_ROOT}."
22
- RUN ls -l ${LAMBDA_TASK_ROOT}
23
- RUN ls -ld ${LAMBDA_TASK_ROOT}
24
- RUN ls -l ${LAMBDA_TASK_ROOT}/machine_learning_models
25
- RUN python -c "import sys; print(sys.path)"
26
- RUN python -c "import fastapi"
27
- RUN python -c "import geopandas"
28
- RUN python -c "import loguru"
29
- RUN python -c "import rasterio"
30
- RUN python -c "import uvicorn"
31
- RUN df -h
32
- RUN ls -l ${LAMBDA_TASK_ROOT}/samgis_lisa_on_cuda/
33
- RUN ls -l ${LAMBDA_TASK_ROOT}/wrappers/
34
- RUN ls -l ${FASTAPI_STATIC}/
35
- RUN ls -l ${FASTAPI_STATIC}/dist
36
- RUN ls -l ${FASTAPI_STATIC}/node_modules
37
-
38
- CMD ["uvicorn", "wrappers.fastapi_wrapper:app", "--host", "0.0.0.0", "--port", "7860"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
dockerfiles/dockerfile-samgis-base DELETED
@@ -1,132 +0,0 @@
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
- ARG RIE="https://github.com/aws/aws-lambda-runtime-interface-emulator/releases/latest/download/aws-lambda-rie"
11
-
12
-
13
- FROM nvcr.io/nvidia/pytorch:24.01-py3 as builder_global
14
-
15
- ARG ARCH
16
- ARG LAMBDA_TASK_ROOT
17
- ARG PYTHONPATH
18
- ARG POETRY_NO_INTERACTION
19
- ARG POETRY_VIRTUALENVS_IN_PROJECT
20
- ARG POETRY_VIRTUALENVS_CREATE
21
- ARG POETRY_CACHE_DIR
22
- ARG RIE
23
- ARG DEPENDENCY_GROUP
24
- ARG ZLIB1G="http://ftp.it.debian.org/debian/pool/main/z/zlib/zlib1g_1.3.dfsg-3+b1_amd64.deb"
25
-
26
- RUN echo "ARCH: $ARCH ..."
27
-
28
- RUN echo "ARG RIE: $RIE ..."
29
- RUN echo "ARG POETRY_CACHE_DIR: ${POETRY_CACHE_DIR} ..."
30
- RUN echo "ARG PYTHONPATH: $PYTHONPATH ..."
31
- RUN test -n ${DEPENDENCY_GROUP:?}
32
- RUN echo "python DEPENDENCY_GROUP: ${DEPENDENCY_GROUP} ..."
33
- RUN echo "arg dep:"
34
-
35
- # Set working directory to function root directory
36
- WORKDIR ${LAMBDA_TASK_ROOT}
37
- COPY requirements_poetry.txt pyproject.toml poetry.lock README.md ${LAMBDA_TASK_ROOT}/
38
-
39
- RUN cat /etc/lsb-release
40
- # avoid segment-geospatial exception caused by missing libGL.so.1 library
41
- RUN echo "BUILDER: check libz.s* before start" && ls -l /usr/lib/${ARCH}-linux-gnu/libz.so*
42
- RUN apt update && apt install -y libgl1 curl python3-pip && apt clean
43
- COPY ./dockerfiles/apt_preferences_debian /etc/apt/preferences
44
- COPY ./dockerfiles/debian.sources /etc/apt/sources.list.d/debian.sources
45
- RUN apt update && apt install -t trixie zlib1g -y && apt clean
46
- RUN echo "BUILDER: check libz.s* after install from trixie" && ls -l /usr/lib/${ARCH}-linux-gnu/libz.so*
47
-
48
- RUN ls -l /etc/apt/sources* /etc/apt/preferences*
49
- RUN curl -Lo /usr/local/bin/aws-lambda-rie ${RIE}
50
-
51
- # poetry installation path is NOT within ${LAMBDA_TASK_ROOT}: not needed for runtime docker image
52
- RUN python -m pip install -r ${LAMBDA_TASK_ROOT}/requirements_poetry.txt
53
-
54
- RUN which poetry && poetry --version && poetry config --list
55
- RUN poetry config virtualenvs.path ${LAMBDA_TASK_ROOT}
56
- RUN echo "# poetry config --list #" && poetry config --list
57
- RUN poetry install --with ${DEPENDENCY_GROUP} --no-root
58
-
59
-
60
- FROM python:3.11-slim-bookworm as runtime
61
-
62
- ARG ARCH
63
- ARG LAMBDA_TASK_ROOT
64
-
65
- ENV VIRTUAL_ENV=${LAMBDA_TASK_ROOT}/.venv \
66
- PATH="${LAMBDA_TASK_ROOT}/.venv/bin:$PATH"
67
-
68
- RUN echo "COPY --from=builder_global /usr/lib/${ARCH}-linux-gnu/libGL.so* /usr/lib/${ARCH}-linux-gnu/"
69
- COPY --from=builder_global /usr/lib/${ARCH}-linux-gnu/libGL.so* /usr/lib/${ARCH}-linux-gnu/
70
- RUN echo "RUNTIME: check libz.s* before upgrade" && ls -l /usr/lib/${ARCH}-linux-gnu/libz.so*
71
- RUN echo "RUNTIME: remove libz.s* to force upgrade" && rm /usr/lib/${ARCH}-linux-gnu/libz.so*
72
- COPY --from=builder_global /usr/lib/${ARCH}-linux-gnu/libz.so* /usr/lib/${ARCH}-linux-gnu/
73
- RUN echo "RUNTIME: check libz.s* after copy" && ls -l /usr/lib/${ARCH}-linux-gnu/libz.so*
74
- COPY --from=builder_global ${LAMBDA_TASK_ROOT}/.venv ${LAMBDA_TASK_ROOT}/.venv
75
-
76
- RUN echo "new LAMBDA_TASK_ROOT after hidden venv copy => ${LAMBDA_TASK_ROOT}"
77
- RUN ls -ld ${LAMBDA_TASK_ROOT}/
78
- RUN ls -lA ${LAMBDA_TASK_ROOT}/
79
-
80
- COPY --from=builder_global /usr/local/bin/aws-lambda-rie /usr/local/bin/aws-lambda-rie
81
- RUN chmod +x /usr/local/bin/aws-lambda-rie
82
- COPY ./scripts/lambda-entrypoint.sh /lambda-entrypoint.sh
83
- RUN chmod +x /lambda-entrypoint.sh
84
-
85
-
86
- ### conditional section
87
- FROM node:20-slim AS node_fastapi
88
-
89
- ARG DEPENDENCY_GROUP
90
- ENV PNPM_HOME="/pnpm"
91
- ENV PATH="$PNPM_HOME:$PATH"
92
- RUN corepack enable
93
-
94
- COPY ./static /appnode
95
- WORKDIR /appnode
96
- # RUN if [ "${DEPENDENCY_GROUP}" = "fastapi" ]; then echo "pnpm store path:" && pnpm store path; fi
97
-
98
-
99
- FROM node_fastapi AS node_prod_deps
100
-
101
- ARG DEPENDENCY_GROUP
102
- RUN --mount=type=cache,id=pnpm,target=/pnpm/store if [ "${DEPENDENCY_GROUP}" = "fastapi" ]; then \
103
- pnpm install --prod --frozen-lockfile; else \
104
- echo "DEPENDENCY_GROUP 1: ${DEPENDENCY_GROUP} ..."; fi
105
- # here multiple conditions concatenated to avoid failing on check
106
- RUN if [ "${DEPENDENCY_GROUP}" = "fastapi" ]; then if [ ! -d /appnode/node_modules ]; then echo "no node_modules folder" && exit 1; fi; fi
107
-
108
-
109
- FROM node_fastapi AS node_build
110
-
111
- ARG DEPENDENCY_GROUP
112
- ARG VITE__MAP_DESCRIPTION
113
- ARG VITE__SAMGIS_SPACE
114
- RUN echo "VITE__MAP_DESCRIPTION:" ${VITE__MAP_DESCRIPTION}
115
- RUN echo "VITE__SAMGIS_SPACE:" ${VITE__SAMGIS_SPACE}
116
-
117
- RUN --mount=type=cache,id=pnpm,target=/pnpm/store if [ "${DEPENDENCY_GROUP}" = "fastapi" ]; then \
118
- pnpm install --frozen-lockfile; else \
119
- echo "DEPENDENCY_GROUP 2: ${DEPENDENCY_GROUP} ..."; fi
120
- RUN --mount=type=cache,id=pnpm,target=/pnpm/store if [ "${DEPENDENCY_GROUP}" = "fastapi" ]; then pnpm build; fi
121
- RUN --mount=type=cache,id=pnpm,target=/pnpm/store if [ "${DEPENDENCY_GROUP}" = "fastapi" ]; then \
122
- pnpm tailwindcss -i /appnode/src/input.css -o /appnode/dist/output.css; fi
123
- RUN if [ "${DEPENDENCY_GROUP}" = "fastapi" ]; then if [ ! -d /appnode/dist ]; then echo "no dist folder" && exit 1; fi; fi
124
-
125
-
126
- FROM runtime
127
- ARG FASTAPI_STATIC
128
- RUN mkdir ${FASTAPI_STATIC}
129
-
130
- COPY ./machine_learning_models ${LAMBDA_TASK_ROOT}/machine_learning_models
131
- COPY --from=node_prod_deps /appnode/node_modules* ${FASTAPI_STATIC}/node_modules
132
- COPY --from=node_build /appnode/dist* ${FASTAPI_STATIC}/dist
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
dockerfiles/ubuntu.sources DELETED
@@ -1,18 +0,0 @@
1
- deb http://it.archive.ubuntu.com/ubuntu/ jammy main universe restricted multiverse
2
- deb-src http://it.archive.ubuntu.com/ubuntu/ jammy main universe restricted multiverse
3
-
4
- deb http://security.ubuntu.com/ubuntu jammy-security main universe restricted multiverse
5
- deb-src http://security.ubuntu.com/ubuntu jammy-security main universe restricted multiverse
6
-
7
- deb http://it.archive.ubuntu.com/ubuntu/ jammy-updates main universe restricted multiverse
8
- deb-src http://it.archive.ubuntu.com/ubuntu/ jammy-updates main universe restricted multiverse
9
-
10
-
11
- deb http://it.archive.ubuntu.com/ubuntu/ noble main universe restricted multiverse
12
- deb-src http://it.archive.ubuntu.com/ubuntu/ noble main universe restricted multiverse
13
-
14
- deb http://security.ubuntu.com/ubuntu noble-security main universe restricted multiverse
15
- deb-src http://security.ubuntu.com/ubuntu noble-security main universe restricted multiverse
16
-
17
- deb http://it.archive.ubuntu.com/ubuntu/ noble-updates main universe restricted multiverse
18
- deb-src http://it.archive.ubuntu.com/ubuntu/ noble-updates main universe restricted multiverse