diff --git a/Containerfile b/Containerfile index e573509..b153e0a 100644 --- a/Containerfile +++ b/Containerfile @@ -29,6 +29,7 @@ RUN TREK_TAG=$(fetch -qo - "${UPSTREAM_URL}" | jq -r .tag_name) && \ RUN cd /build && \ NODE_ENV=development npm ci && \ npm run build --workspace=shared && \ + npm run build --workspace=server && \ cd client && \ for spec in apple-touch-icon-180x180.png:180 icon-192x192.png:192 icon-512x512.png:512; do \ name=${spec%:*}; size=${spec#*:}; \ @@ -92,7 +93,8 @@ ENV NODE_ENV=production \ PORT=3000 COPY root/ / -RUN chmod +x /etc/services.d/trek/run /healthz +RUN chmod +x /etc/services.d/trek/run /healthz && \ + chmod 0644 /usr/local/share/trek/dom-polyfill.cjs EXPOSE 3000 VOLUME /config \ No newline at end of file diff --git a/Containerfile.j2 b/Containerfile.j2 index 97163f1..77332de 100644 --- a/Containerfile.j2 +++ b/Containerfile.j2 @@ -23,6 +23,7 @@ RUN TREK_TAG=$(fetch -qo - "${UPSTREAM_URL}" | jq -r .tag_name) && \ RUN cd /build && \ NODE_ENV=development npm ci && \ npm run build --workspace=shared && \ + npm run build --workspace=server && \ cd client && \ for spec in apple-touch-icon-180x180.png:180 icon-192x192.png:192 icon-512x512.png:512; do \ name=${spec%:*}; size=${spec#*:}; \ @@ -86,7 +87,8 @@ ENV NODE_ENV=production \ PORT=3000 COPY root/ / -RUN chmod +x /etc/services.d/trek/run /healthz +RUN chmod +x /etc/services.d/trek/run /healthz && \ + chmod 0644 /usr/local/share/trek/dom-polyfill.cjs EXPOSE 3000 VOLUME /config diff --git a/compose.yaml b/compose.yaml index b60e387..5ba1dc9 100644 --- a/compose.yaml +++ b/compose.yaml @@ -28,7 +28,6 @@ services: container_name: trek restart: unless-stopped - environment: - PUID=1000 - PGID=1000 diff --git a/root/etc/services.d/trek/run b/root/etc/services.d/trek/run index e684820..d33bdf2 100755 --- a/root/etc/services.d/trek/run +++ b/root/etc/services.d/trek/run @@ -8,4 +8,6 @@ export PORT=3000 # Signal readiness to CIT once the API answers s6-ready-when fetch -qo /dev/null http://localhost:3000/api/health -exec /usr/local/bin/s6-setuidgid bsd /usr/local/bin/node --import tsx src/index.ts +exec /usr/local/bin/s6-setuidgid bsd /usr/local/bin/node \ + --require /usr/local/share/trek/dom-polyfill.cjs \ + --require tsconfig-paths/register dist/index.js diff --git a/root/usr/local/share/trek/dom-polyfill.cjs b/root/usr/local/share/trek/dom-polyfill.cjs new file mode 100644 index 0000000..a54b789 --- /dev/null +++ b/root/usr/local/share/trek/dom-polyfill.cjs @@ -0,0 +1,9 @@ +// Canvas globals for pdf.js (bundled by pdf-parse). FreeBSD has no +// @napi-rs/canvas native binding, so these are otherwise undefined and +// pdf-parse throws "DOMMatrix is not defined" at import, crashing boot. +if (typeof globalThis.DOMMatrix === 'undefined') + globalThis.DOMMatrix = class DOMMatrix { constructor(){ this.a=1;this.b=0;this.c=0;this.d=1;this.e=0;this.f=0; } }; +if (typeof globalThis.ImageData === 'undefined') + globalThis.ImageData = class ImageData { constructor(w,h){ this.width=w;this.height=h; } }; +if (typeof globalThis.Path2D === 'undefined') + globalThis.Path2D = class Path2D {};