-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile
More file actions
447 lines (402 loc) · 19 KB
/
Copy pathDockerfile
File metadata and controls
447 lines (402 loc) · 19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
# Multi-stage Dockerfile to build meos.js + meos.wasm from source (wasm64-only).
#
# Usage:
# docker build --output type=local,dest=./wasm --target wasm .
#
# Versions:
# emsdk 5.0.6 | MobilityDB master
# GEOS 3.14.1 | PROJ 9.8.1 | SQLite 3.46.1
# JSON-C 0.18 | GSL 2.8 | H3 4.2.1
# Track upstream MobilityDB master. The committed codegen/res/meos-idl.json is a
# snapshot of the MEOS-API catalog for that surface; refresh it (see README) when
# the MEOS surface changes.
ARG MOBILITYDB_REPO=https://github.com/MobilityDB/MobilityDB.git
ARG MOBILITYDB_BRANCH=master
# EMSCRIPTEN & EVERY NEEDED TOOL
FROM emscripten/emsdk:5.0.6 AS base
RUN apt-get update && apt-get install -y --no-install-recommends \
cmake ninja-build pkg-config git curl unzip ca-certificates tzdata \
sqlite3 automake \
&& rm -rf /var/lib/apt/lists/*
# COMPILING SQLite WITH EMSCRIPTEN (needed to compile PROJ)
FROM base AS sqlite
RUN curl -fL "https://www.sqlite.org/2024/sqlite-amalgamation-3460100.zip" -o /tmp/sqlite.zip \
&& unzip /tmp/sqlite.zip -d /tmp \
&& mkdir -p /root/sqlite3
WORKDIR /tmp/sqlite-amalgamation-3460100
RUN emcc -sMEMORY64=1 -O2 -c sqlite3.c -o sqlite3.o \
&& emar rcs /root/sqlite3/libsqlite3.a sqlite3.o \
&& cp sqlite3.h /root/sqlite3/
# COMPILING GEOS WITH EMSCRIPTEN
FROM base AS geos
RUN curl -fL "https://download.osgeo.org/geos/geos-3.14.1.tar.bz2" | tar xj -C /root \
&& mv /root/geos-3.14.1 /root/geos
WORKDIR /root/geos
RUN mkdir -p build && cd build \
&& emcmake cmake .. \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=OFF \
-DGEOS_BUILD_DEVELOPER=OFF \
-DBUILD_TESTING=OFF \
-DBUILD_GEOSOP=OFF \
-DCMAKE_C_FLAGS=-sMEMORY64=1 \
-DCMAKE_CXX_FLAGS=-sMEMORY64=1 \
&& emmake make -j"$(nproc)" geos geos_c
# COMPILING PROJ WITH EMSCRIPTEN
FROM base AS proj
COPY --from=sqlite /root/sqlite3 /root/sqlite3
RUN curl -fL "https://download.osgeo.org/proj/proj-9.8.1.tar.gz" \
| tar xz -C /root \
&& mv /root/proj-9.8.1 /root/PROJ
WORKDIR /root/PROJ
RUN mkdir -p build && cd build \
&& emcmake cmake .. \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=OFF \
-DBUILD_APPS=OFF \
-DBUILD_TESTING=OFF \
-DBUILD_PROJSYNC=OFF \
-DENABLE_TIFF=OFF \
-DENABLE_CURL=OFF \
-DFETCHCONTENT_FULLY_DISCONNECTED=ON \
-DEMBED_RESOURCE_FILES=OFF \
-DSQLITE3_INCLUDE_DIR=/root/sqlite3 \
-DSQLITE3_LIBRARY=/root/sqlite3/libsqlite3.a \
-DCMAKE_C_FLAGS=-sMEMORY64=1 \
-DCMAKE_CXX_FLAGS=-sMEMORY64=1 \
&& emmake make -j"$(nproc)"
# COMPILING JSON-C WITH EMSCRIPTEN
FROM base AS jsonc
RUN curl -fL "https://github.com/json-c/json-c/archive/refs/tags/json-c-0.18-20240915.tar.gz" \
| tar xz -C /root \
&& mv /root/json-c-json-c-0.18-20240915 /root/json-c
WORKDIR /root/json-c
RUN mkdir -p build && cd build \
&& emcmake cmake .. \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=OFF \
-DBUILD_TESTING=OFF \
-DCMAKE_C_FLAGS=-sMEMORY64=1 \
&& emmake make -j"$(nproc)" json-c \
&& mkdir -p /root/json-c-install/include/json-c /root/json-c-install/lib \
&& cp /root/json-c/*.h /root/json-c-install/include/json-c/ \
&& cp /root/json-c/build/*.h /root/json-c-install/include/json-c/ \
&& cp /root/json-c/build/libjson-c.a /root/json-c-install/lib/
# COMPILING ZLIB WITH EMSCRIPTEN
#
# pgPointCloud's libpc links zlib and libxml2, so POINTCLOUD needs both on the
# wasm build path. Emscripten ships a zlib port, but MEOS reaches it through
# find_package(ZLIB), which wants a prefix it can point at rather than a linker
# flag, so it is built here like every other dependency.
FROM base AS zlib
RUN curl -fL "https://github.com/madler/zlib/releases/download/v1.3.1/zlib-1.3.1.tar.gz" \
| tar xz -C /root \
&& mv /root/zlib-1.3.1 /root/zlib
WORKDIR /root/zlib
RUN mkdir -p build && cd build \
&& emcmake cmake .. \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/root/zlib-install \
-DBUILD_SHARED_LIBS=OFF \
-DZLIB_BUILD_EXAMPLES=OFF \
-DCMAKE_C_FLAGS=-sMEMORY64=1 \
&& emmake make -j"$(nproc)" zlibstatic \
&& emmake make install
# COMPILING LIBXML2 WITH EMSCRIPTEN
#
# The other half of libpc's link line. Every optional feature is off: libpc uses
# libxml2 to read a point cloud's XML schema, so the parser is all that is
# needed, and the extras (python, http, lzma, iconv) each drag in a dependency
# this image would then have to cross-compile too.
FROM base AS libxml2
COPY --from=zlib /root/zlib-install /root/zlib-install
RUN curl -fL "https://download.gnome.org/sources/libxml2/2.13/libxml2-2.13.5.tar.xz" \
| tar xJ -C /root \
&& mv /root/libxml2-2.13.5 /root/libxml2
WORKDIR /root/libxml2
RUN mkdir -p build && cd build \
&& emcmake cmake .. \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/root/libxml2-install \
-DZLIB_INCLUDE_DIR=/root/zlib-install/include \
-DZLIB_LIBRARY=/root/zlib-install/lib/libz.a \
-DBUILD_SHARED_LIBS=OFF \
-DLIBXML2_WITH_PYTHON=OFF \
-DLIBXML2_WITH_HTTP=OFF \
-DLIBXML2_WITH_LZMA=OFF \
-DLIBXML2_WITH_ICONV=OFF \
-DLIBXML2_WITH_ZLIB=ON \
-DLIBXML2_WITH_PROGRAMS=OFF \
-DLIBXML2_WITH_TESTS=OFF \
-DCMAKE_C_FLAGS=-sMEMORY64=1 \
&& emmake make -j"$(nproc)" \
&& emmake make install
# COMPILING GDAL WITH EMSCRIPTEN
#
# RASTER samples raster bands along a trajectory through GDAL, and -DALL=ON turns
# RASTER on, so GDAL has to be on the wasm build path for the family set
# MobilityDB's own CMakeLists defines.
#
# Every optional driver is off. GDAL's driver set is where its bulk and its
# dependency surface live (curl, netcdf, hdf5, the proprietary SDKs), and MEOS
# reads raster bands through the generic API rather than naming a format, so the
# core plus the built-in drivers is the whole requirement. The dependencies it
# does take — PROJ and SQLite — are ones this image already builds for MEOS
# itself, so GDAL adds no third-party library that was not already here.
#
# GEOS is off in GDAL: it backs OGR's geometry predicates, which raster band
# sampling does not reach, and MEOS links its own GEOS regardless. Handing it
# this tree's GEOS would also need two include directories — `geos_c.h` takes
# `geos/export.h` from the source tree while the header itself is generated into
# the build tree — and GEOS_INCLUDE_DIR names one.
FROM base AS gdal
COPY --from=sqlite /root/sqlite3 /root/sqlite3
COPY --from=proj /root/PROJ /root/PROJ
COPY --from=geos /root/geos /root/geos
COPY --from=zlib /root/zlib-install /root/zlib-install
RUN curl -fL "https://github.com/OSGeo/gdal/releases/download/v3.9.3/gdal-3.9.3.tar.gz" \
| tar xz -C /root \
&& mv /root/gdal-3.9.3 /root/gdal
WORKDIR /root/gdal
RUN mkdir -p build && cd build \
&& emcmake cmake .. \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/root/gdal-install \
-DBUILD_SHARED_LIBS=OFF \
-DBUILD_APPS=OFF \
-DBUILD_TESTING=OFF \
-DBUILD_DOCS=OFF \
-DBUILD_PYTHON_BINDINGS=OFF \
-DBUILD_JAVA_BINDINGS=OFF \
-DBUILD_CSHARP_BINDINGS=OFF \
-DGDAL_BUILD_OPTIONAL_DRIVERS=OFF \
-DOGR_BUILD_OPTIONAL_DRIVERS=OFF \
-DGDAL_USE_EXTERNAL_LIBS=OFF \
-DGDAL_USE_INTERNAL_LIBS=ON \
-DGDAL_USE_PROJ=ON \
-DPROJ_INCLUDE_DIR=/root/PROJ/src \
-DPROJ_LIBRARY=/root/PROJ/build/lib/libproj.a \
-DGDAL_USE_GEOS=OFF \
-DGDAL_USE_SQLITE3=ON \
-DSQLite3_INCLUDE_DIR=/root/sqlite3 \
-DSQLite3_LIBRARY=/root/sqlite3/libsqlite3.a \
-DGDAL_USE_ZLIB=ON \
-DZLIB_INCLUDE_DIR=/root/zlib-install/include \
-DZLIB_LIBRARY=/root/zlib-install/lib/libz.a \
-DCMAKE_C_FLAGS=-sMEMORY64=1 \
-DCMAKE_CXX_FLAGS=-sMEMORY64=1 \
&& emmake make -j"$(nproc)" \
&& emmake make install
# COMPILING GSL WITH EMSCRIPTEN
FROM base AS gsl
RUN curl -fL "https://ftpmirror.gnu.org/gsl/gsl-2.8.tar.gz" | tar xz -C /root
WORKDIR /root/gsl-2.8
RUN cp /usr/share/automake-*/config.sub config.sub \
&& cp /usr/share/automake-*/config.guess config.guess \
&& emconfigure ./configure \
--prefix=/root/gsl-wasm \
--host=wasm32-unknown-emscripten \
--disable-shared \
--enable-static \
CFLAGS="-O2 -sMEMORY64=1" \
&& emmake make -j"$(nproc)" \
&& emmake make install
# COMPILING H3 WITH EMSCRIPTEN (Uber libh3, required by the temporal H3 index family)
# BUILD_GENERATORS=OFF: the lib's generated coordinate tables are committed in the
# release tarball; only the standalone generator TOOLS would need native execution,
# so skipping them keeps the whole build cross-compilable. h3api.h is the single
# self-contained public header (produced from h3api.h.in by configure_file, so it
# exists regardless of the generators); copy it and libh3.a into a clean prefix.
FROM base AS h3
RUN curl -fL "https://github.com/uber/h3/archive/refs/tags/v4.2.1.tar.gz" \
| tar xz -C /root \
&& mv /root/h3-4.2.1 /root/h3
WORKDIR /root/h3
RUN mkdir -p build && cd build \
&& emcmake cmake .. \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=OFF \
-DBUILD_TESTING=OFF \
-DBUILD_BENCHMARKS=OFF \
-DBUILD_FILTERS=OFF \
-DBUILD_GENERATORS=OFF \
-DENABLE_COVERAGE=OFF \
-DENABLE_DOCS=OFF \
-DENABLE_FORMAT=OFF \
-DENABLE_LINTING=OFF \
-DCMAKE_C_FLAGS=-sMEMORY64=1 \
&& emmake make -j"$(nproc)" h3 \
&& mkdir -p /root/h3-install/lib /root/h3-install/include \
&& cp /root/h3/build/lib/libh3.a /root/h3-install/lib/ \
&& cp /root/h3/build/src/h3lib/include/h3api.h /root/h3-install/include/
# MOBILITYDB SOURCE (separate stage so /app/ changes don't invalidate the clone)
FROM base AS mobilitydb_src
ARG MOBILITYDB_REPO
ARG MOBILITYDB_BRANCH
RUN git clone --depth 1 --branch ${MOBILITYDB_BRANCH} ${MOBILITYDB_REPO} /root/MobilityDB
# BUILDING WASM
FROM base AS builder
COPY --from=sqlite /root/sqlite3 /root/sqlite3
COPY --from=geos /root/geos /root/geos
COPY --from=proj /root/PROJ /root/PROJ
COPY --from=jsonc /root/json-c-install /root/json-c-install
COPY --from=gsl /root/gsl-wasm /root/gsl-wasm
COPY --from=h3 /root/h3-install /root/h3-install
COPY --from=zlib /root/zlib-install /root/zlib-install
COPY --from=libxml2 /root/libxml2-install /root/libxml2-install
COPY --from=gdal /root/gdal-install /root/gdal-install
COPY --from=mobilitydb_src /root/MobilityDB /root/MobilityDB
WORKDIR /app
# The wrappers are taken from the tree rather than regenerated here. They are a
# projection of the MEOS-API catalog, and the catalog is derived from MobilityDB
# rather than committed, so an image that regenerates needs a catalog the tree
# does not carry. Compiling the committed wrappers also makes this build answer
# the question that matters to a consumer of the published package, who compiles
# exactly these: that they still build against the MEOS they are linked to.
COPY . .
# CMAKE: configure MobilityDB
#
# The install prefix is named HERE, not only on the install line: `meos.pc` is
# generated at configure time and records the prefix it is given then, so a
# prefix supplied later relocates the files while the `.pc` keeps pointing at
# the emscripten sysroot, and `pkg-config --cflags` then reports an include
# directory that holds no MEOS header.
RUN INCLUDES="-I/root/geos/include -I/root/geos/build/capi -I/root/json-c-install/include -I/root/json-c-install/include/json-c" \
&& emcmake cmake -S /root/MobilityDB -B /root/MobilityDB/build \
-DMEOS=ON \
-DALL=ON \
-DCMAKE_INSTALL_PREFIX=/root/meos-install \
-DH3_LIBRARY=/root/h3-install/lib/libh3.a \
-DH3_INCLUDE_DIR=/root/h3-install/include \
-DBUILD_SHARED_LIBS=OFF \
-DCMAKE_BUILD_TYPE=Release \
-DGEOS_INCLUDE_DIR=/root/geos/build/capi \
-DGEOS_LIBRARY=/root/geos/build/lib/libgeos.a \
-DPROJ_INCLUDE_DIRS=/root/PROJ/src \
-DPROJ_LIBRARIES=/root/PROJ/build/lib/libproj.a \
"-DJSON-C_INCLUDE_DIRS=/root/json-c-install/include" \
"-DJSON-C_LIBRARIES=/root/json-c-install/lib/libjson-c.a" \
-DGSL_INCLUDE_DIR=/root/gsl-wasm/include \
-DGSL_LIBRARY=/root/gsl-wasm/lib/libgsl.a \
-DGSL_CBLAS_LIBRARY=/root/gsl-wasm/lib/libgslcblas.a \
-DZLIB_INCLUDE_DIR=/root/zlib-install/include \
-DZLIB_LIBRARY=/root/zlib-install/lib/libz.a \
-DLIBXML2_INCLUDE_DIR=/root/libxml2-install/include/libxml2 \
-DLIBXML2_LIBRARY=/root/libxml2-install/lib/libxml2.a \
-DGDAL_INCLUDE_DIR=/root/gdal-install/include \
-DGDAL_LIBRARY=/root/gdal-install/lib/libgdal.a \
"-DCMAKE_C_FLAGS=-sMEMORY64=1 $INCLUDES" \
"-DCMAKE_CXX_FLAGS=-sMEMORY64=1 $INCLUDES"
# PATCHING: fix pg_config.h type sizes for wasm64
# SIZEOF_LONG is always 4 in Emscripten (ILP32 model, even in wasm64)
# SIZEOF_VOID_P / SIZEOF_SIZE_T: 8 for wasm64
# HAVE_LONG_LONG_INT_64: needed (long=32 bit -> int64 must use long long)
RUN PG_CONFIG_H=/root/MobilityDB/build/pgtypes/pg_config.h \
&& sed -i \
-e 's/^#define SIZEOF_LONG [0-9]\+/#define SIZEOF_LONG 4/' \
-e 's/^#define SIZEOF_VOID_P [0-9]\+/#define SIZEOF_VOID_P 8/' \
-e 's/^#define SIZEOF_SIZE_T [0-9]\+/#define SIZEOF_SIZE_T 8/' \
"$PG_CONFIG_H" \
&& grep -q SIZEOF_LONG_LONG "$PG_CONFIG_H" || \
sed -i 's/^#define SIZEOF_LONG 4$/#define SIZEOF_LONG 4\n#define SIZEOF_LONG_LONG 8/' "$PG_CONFIG_H" \
&& sed -i \
-e 's/^#define HAVE_LONG_INT_64 1/\/* #undef HAVE_LONG_INT_64 *\//' \
-e 's/^\/\* #undef HAVE_LONG_LONG_INT_64 \*\//#define HAVE_LONG_LONG_INT_64 1/' \
"$PG_CONFIG_H"
# COMPILING: libmeos.a
# The install step produces both the header and the archive this module is built
# against, so the prefix is the only thing the link line names and the build-tree
# layout is MEOS's business alone.
#
# MEOS assembles the installed <meos.h> rather than shipping the source one: it
# splices the PostgreSQL-compat definitions and the de-prefixed base I/O into it,
# so interval_in, date_in and their siblings are declared only there.
#
# The installed archive is self-contained: MEOS folds pgtypes, liblwgeom and ryu
# (and libpc, with POINTCLOUD on) into it precisely so a consumer that embeds MEOS
# in one relocatable module links one library. The sidecar libpgtypes.a and
# libpostgis.a it used to need are build-tree intermediates that `install` does not
# publish, and naming them again would duplicate what the archive already carries.
RUN cmake --build /root/MobilityDB/build --target meos --parallel "$(nproc)" \
&& cmake --install /root/MobilityDB/build --prefix /root/meos-install
# EMCC: link everything into meos.js + meos.wasm
#
# wasm64-specific flags:
# -sEMULATE_FUNCTION_POINTER_CASTS=1
# MEOS uses datum_func2 (Datum(*)(Datum,Datum)) as a generic callback type,
# passing concrete functions (datum_eq, int4pl, …) through it. In wasm64
# the Datum type widens to i64, which changes the indirect-call signature
# seen by the WASM engine. Without emulation the engine traps with
# "null function or function signature mismatch" for every arithmetic /
# ever-always / temporal-comparison path. The emulation shim wraps each
# indirect call so the engine always sees the exact expected type.
#
# -O1 (instead of -O2)
# Avoid LLVM optimisations that can merge or devirtualise indirect-call
# sites before the emulation shims are inserted; -O1 keeps the shims
# effective while still producing reasonably compact code.
#
# -sSTACK_SIZE=8MB
# The Emscripten default stack is only 64 KB. MEOS walks temporals
# instant-by-instant through indirect calls (datum_func2, interpolation,
# aggregation), and EMULATE_FUNCTION_POINTER_CASTS wraps every one of
# those calls in a trampoline that pushes extra args onto the stack.
# Deep call chains over a few thousand instants overflow 64 KB; because
# stack-overflow checking is off in release builds the overflow corrupts
# adjacent linear memory and surfaces as "memory access out of bounds".
# 8 MB is reserved address space, not committed RAM, so it is cheap and
# pushes the practical limit from ~2500 to hundreds of thousands of
# instants.
#
# The installed MEOS describes itself: `pkg-config --cflags meos` reports its
# include directory together with the family macros it is compiled with. Both
# halves matter, because the public headers gate declarations on those macros --
# `meos.h` holds `#if POINTCLOUD` and `#if JSON` blocks -- so an include path
# written here without them compiles the negative branch and loses declarations
# whose symbols the archive exports.
#
# EMULATE_FUNCTION_POINTER_CASTS makes wasm-opt give every indirect call one
# signature, as wide as the widest function type in the module, and it refuses
# to run when that exceeds its default cap. GDAL, which RASTER samples raster
# bands through, carries the widest of them. The pass names the minimum it needs
# in its own error, and the value is kept at that minimum because the width it
# sets is paid by every thunk.
RUN mkdir -p /app/wasm \
&& emcc -sMEMORY64=1 -sEMULATE_FUNCTION_POINTER_CASTS=1 -O1 \
-sBINARYEN_EXTRA_PASSES=pass-arg=max-func-params@23 \
/app/core/c-src/bindings.c \
/root/meos-install/lib/libmeos.a \
/root/geos/build/lib/libgeos.a \
/root/geos/build/lib/libgeos_c.a \
/root/PROJ/build/lib/libproj.a \
/root/sqlite3/libsqlite3.a \
/root/gsl-wasm/lib/libgsl.a \
/root/gsl-wasm/lib/libgslcblas.a \
/root/json-c-install/lib/libjson-c.a \
/root/h3-install/lib/libh3.a \
/root/gdal-install/lib/libgdal.a \
/root/libxml2-install/lib/libxml2.a \
/root/zlib-install/lib/libz.a \
$(PKG_CONFIG_PATH=/root/meos-install/lib/pkgconfig pkg-config --cflags meos) \
-I/root/geos/include \
-I/root/geos/build/capi \
-I/root/PROJ/src \
-I/root/json-c-install/include \
-I/root/gsl-wasm/include \
-I/root/h3-install/include \
--embed-file /usr/share/zoneinfo@/usr/share/zoneinfo \
--embed-file /root/meos-install/share/spatial_ref_sys.csv@/usr/local/share/spatial_ref_sys.csv \
--embed-file /root/PROJ/build/data/proj.db@/usr/local/share/proj/proj.db \
-o /app/wasm/meos.js \
-s MODULARIZE=1 \
-s EXPORT_NAME="createMeosModule" \
-s EXPORTED_RUNTIME_METHODS='["ccall","cwrap","UTF8ToString","allocate","ALLOC_NORMAL"]' \
-s ALLOW_MEMORY_GROWTH=1 \
-s STACK_SIZE=8MB \
-s ENVIRONMENT='web,node' \
-s EXPORT_ES6=1 \
-Wno-incompatible-pointer-types \
-Wno-int-conversion
FROM scratch AS wasm
COPY --from=builder /app/wasm/meos.js meos.js
COPY --from=builder /app/wasm/meos.wasm meos.wasm