From feacb7320901149bd8228b1b8bc08ef18ea3151d Mon Sep 17 00:00:00 2001
From: Andrey Sobolev <haiodo@users.noreply.github.com>
Date: Fri, 8 Dec 2023 22:13:49 +0700
Subject: [PATCH] Fix sharp version (#4168)

Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
---
 common/config/rush/pnpm-lock.yaml | 76 +++++++++++++++++++++++--------
 pods/front/Dockerfile             |  2 +-
 pods/front/package.json           |  4 +-
 server/front/Dockerfile           | 13 ------
 server/front/package.json         |  4 +-
 server/front/src/index.ts         |  4 +-
 6 files changed, 64 insertions(+), 39 deletions(-)
 delete mode 100644 server/front/Dockerfile

diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml
index cedb0a1272..c3c460b9ac 100644
--- a/common/config/rush/pnpm-lock.yaml
+++ b/common/config/rush/pnpm-lock.yaml
@@ -798,8 +798,8 @@ dependencies:
     specifier: ~2.48.8
     version: 2.48.9
   '@types/sharp':
-    specifier: ~0.30.4
-    version: 0.30.5
+    specifier: ~0.32.0
+    version: 0.32.0
   '@types/tar-stream':
     specifier: ^2.2.2
     version: 2.2.3
@@ -1044,8 +1044,8 @@ dependencies:
     specifier: ^13.2.0
     version: 13.3.2(sass@1.69.0)(webpack@5.88.2)
   sharp:
-    specifier: ~0.30.7
-    version: 0.30.7
+    specifier: ~0.32.0
+    version: 0.32.6
   simplytyped:
     specifier: ^3.3.0
     version: 3.3.0(typescript@5.2.2)
@@ -7297,10 +7297,11 @@ packages:
       '@types/node': 16.11.68
     dev: false
 
-  /@types/sharp@0.30.5:
-    resolution: {integrity: sha512-EhO29617AIBqxoVtpd1qdBanWpspk/kD2B6qTFRJ31Q23Rdf+DNU1xlHSwtqvwq1vgOqBwq1i38SX+HGCymIQg==}
+  /@types/sharp@0.32.0:
+    resolution: {integrity: sha512-OOi3kL+FZDnPhVzsfD37J88FNeZh6gQsGcLc95NbeURRGvmSjeXiDcyWzF2o3yh/gQAUn2uhh/e+CPCa5nwAxw==}
+    deprecated: This is a stub types definition. sharp provides its own type definitions, so you do not need this installed.
     dependencies:
-      '@types/node': 16.11.68
+      sharp: 0.32.6
     dev: false
 
   /@types/sockjs@0.3.34:
@@ -8125,6 +8126,10 @@ packages:
       dequal: 2.0.3
     dev: false
 
+  /b4a@1.6.4:
+    resolution: {integrity: sha512-fpWrvyVHEKyeEvbKZTVOeZF3VSKKWtJxFIxX/jaVPf+cLbGUSitjb49pHLqPV2BUNNZ0LcoeEGfE/YCpyDYHIw==}
+    dev: false
+
   /babel-core@7.0.0-bridge.0(@babel/core@7.23.0):
     resolution: {integrity: sha512-poPX9mZH/5CSanm50Q+1toVci6pv5KSRv/5TWCwtzQS5XEwn40BcCrgIeMFWP9CKKIniKXNxoIOnOq4VVlGXhg==}
     peerDependencies:
@@ -10476,6 +10481,10 @@ packages:
     resolution: {integrity: sha512-caj/ZmjHljPrZtbzJ3kfH5ia/k4mTJe/qSiXAGzxZWRZgsgDV0cvNaQULqUX8t0/JVlzzEdYOwCN5DmzTxoD4w==}
     dev: false
 
+  /fast-fifo@1.3.2:
+    resolution: {integrity: sha512-/d9sfos4yxzpwkDkuN7k2SqFKtYNmCTzgfEpz82x34IM9/zc8KGxQoXg1liNC/izpRM/MBdt44Nmx41ZWqk+FQ==}
+    dev: false
+
   /fast-glob@3.3.1:
     resolution: {integrity: sha512-kNFPyjhh5cKjrUltxs+wFx+ZkbRaxxmZ+X0ZU31SOsxCEtP9VPgtq2teZw1DebupL5GmDaNQ6yKMMVcM41iqDg==}
     engines: {node: '>=8.6.0'}
@@ -13362,8 +13371,8 @@ packages:
     resolution: {integrity: sha512-AGK2yQKIjRuqnc6VkX2Xj5d+QW8xZ87pa1UK6yA6ouUyuxfHuMP6umE5QK7UmTeOAymo+Zx1Fxiuw9rVx8taHQ==}
     dev: false
 
-  /node-addon-api@5.1.0:
-    resolution: {integrity: sha512-eh0GgfEkpnoWDq+VY8OyvYhFEzBk6jIYbRKdIlyTiAXIVJ8PyBaKb0rp7oDtoddbdoHWhq8wwr+XZ81F1rpNdA==}
+  /node-addon-api@6.1.0:
+    resolution: {integrity: sha512-+eawOlIgy680F0kBzPUNFhMZGtJ1YmqM6l4+Crf4IkImjYrO/mqPwRMh352g23uIaQKFItcQ64I7KMaJxHgAVA==}
     dev: false
 
   /node-dir@0.1.17:
@@ -14470,6 +14479,10 @@ packages:
     resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==}
     dev: false
 
+  /queue-tick@1.0.1:
+    resolution: {integrity: sha512-kJt5qhMxoszgU/62PLP1CJytzd2NKetjSRnyuj31fDd3Rlcz3fzlFdFLD1SItunPwyqEOkca6GbV612BWfaBag==}
+    dev: false
+
   /quick-format-unescaped@4.0.4:
     resolution: {integrity: sha512-tYC1Q1hgyRuHgloV/YXs2w15unPVh8qfu/qCTfhTYamaw7fyhumKa2yGpdSo87vY32rIclj+4fWYQXUMs9EHvg==}
     dev: false
@@ -15179,18 +15192,18 @@ packages:
       kind-of: 6.0.3
     dev: false
 
-  /sharp@0.30.7:
-    resolution: {integrity: sha512-G+MY2YW33jgflKPTXXptVO28HvNOo9G3j0MybYAHeEmby+QuD2U98dT6ueht9cv/XDqZspSpIhoSW+BAKJ7Hig==}
-    engines: {node: '>=12.13.0'}
+  /sharp@0.32.6:
+    resolution: {integrity: sha512-KyLTWwgcR9Oe4d9HwCwNM2l7+J0dUQwn/yf7S0EnTtb0eVS4RxO0eUSvxPtzT4F3SY+C4K6fqdv/DO27sJ/v/w==}
+    engines: {node: '>=14.15.0'}
     requiresBuild: true
     dependencies:
       color: 4.2.3
       detect-libc: 2.0.2
-      node-addon-api: 5.1.0
+      node-addon-api: 6.1.0
       prebuild-install: 7.1.1
       semver: 7.5.4
       simple-get: 4.0.1
-      tar-fs: 2.1.1
+      tar-fs: 3.0.4
       tunnel-agent: 0.6.0
     dev: false
 
@@ -15519,6 +15532,13 @@ packages:
     engines: {node: '>=10.0.0'}
     dev: false
 
+  /streamx@2.15.5:
+    resolution: {integrity: sha512-9thPGMkKC2GctCzyCUjME3yR03x2xNo0GPKGkRw2UMYN+gqWa9uqpyNWhmsNCutU5zHmkUum0LsCRQTXUgUCAg==}
+    dependencies:
+      fast-fifo: 1.3.2
+      queue-tick: 1.0.1
+    dev: false
+
   /strict-uri-encode@2.0.0:
     resolution: {integrity: sha512-QwiXZgpRcKkhTj2Scnn++4PKtWsH0kpzZ62L2R6c/LUVYv7hVnZqcg2+sMuT6R7Jusu1vviK/MFsu6kNJfWlEQ==}
     engines: {node: '>=4'}
@@ -15879,6 +15899,14 @@ packages:
       tar-stream: 2.2.0
     dev: false
 
+  /tar-fs@3.0.4:
+    resolution: {integrity: sha512-5AFQU8b9qLfZCX9zp2duONhPmZv0hGYiBPJsyUdqMjzq/mqVpy/rEUSeHk1+YitmxugaptgBh5oDGU3VsAJq4w==}
+    dependencies:
+      mkdirp-classic: 0.5.3
+      pump: 3.0.0
+      tar-stream: 3.1.6
+    dev: false
+
   /tar-stream@2.2.0:
     resolution: {integrity: sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==}
     engines: {node: '>=6'}
@@ -15890,6 +15918,14 @@ packages:
       readable-stream: 3.6.2
     dev: false
 
+  /tar-stream@3.1.6:
+    resolution: {integrity: sha512-B/UyjYwPpMBv+PaFSWAmtYjwdrlEaZQEhMIBFNC5oEG8lpiW8XjcSdmEaClj28ArfKScKHs2nshz3k2le6crsg==}
+    dependencies:
+      b4a: 1.6.4
+      fast-fifo: 1.3.2
+      streamx: 2.15.5
+    dev: false
+
   /tar@6.2.0:
     resolution: {integrity: sha512-/Wo7DcT0u5HUV486xg675HtjNd3BXZ6xDbzsCUZPt5iw8bTQ63bP0Raut3mvro9u+CUyq7YQd8Cx55fsZXxqLQ==}
     engines: {node: '>=10'}
@@ -18429,7 +18465,7 @@ packages:
     dev: false
 
   file:projects/front.tgz(esbuild@0.16.17)(svelte@4.2.5):
-    resolution: {integrity: sha512-298XAhw9LgP0+S6S/JATUHTM6poKcIyMEfnea6awIsZJLvX1S3TUOjlTMjrEYbJpY1bwss1toPxvUtmwoau4Jw==, tarball: file:projects/front.tgz}
+    resolution: {integrity: sha512-xBechy2SGLSNUUN/rM60kyFJOJA8edlX2f/gqHk272BIfcsGXtUlPl8yPXv/H9zciOKSAUSy/6fMDZVNATVuqA==, tarball: file:projects/front.tgz}
     id: file:projects/front.tgz
     name: '@rush-temp/front'
     version: 0.0.0
@@ -18441,7 +18477,7 @@ packages:
       '@types/express-fileupload': 1.4.2
       '@types/jest': 29.5.5
       '@types/node': 16.11.68
-      '@types/sharp': 0.30.5
+      '@types/sharp': 0.32.0
       '@types/uuid': 8.3.4
       '@typescript-eslint/eslint-plugin': 6.11.0(@typescript-eslint/parser@6.11.0)(eslint@8.54.0)(typescript@5.2.2)
       '@typescript-eslint/parser': 6.11.0(eslint@8.54.0)(typescript@5.2.2)
@@ -18459,7 +18495,7 @@ packages:
       jest: 29.7.0(@types/node@16.11.68)(ts-node@10.9.1)
       prettier: 3.1.0
       prettier-plugin-svelte: 3.1.0(prettier@3.1.0)(svelte@4.2.5)
-      sharp: 0.30.7
+      sharp: 0.32.6
       ts-jest: 29.1.1(esbuild@0.16.17)(jest@29.7.0)(typescript@5.2.2)
       ts-node: 10.9.1(@types/node@16.11.68)(typescript@5.2.2)
       typescript: 5.2.2
@@ -20694,7 +20730,7 @@ packages:
     dev: false
 
   file:projects/pod-front.tgz(svelte@4.2.5):
-    resolution: {integrity: sha512-F0QHtIxi0ok4oRSFqnEx+QAp4XQyLIqvAWVcvdalNOEolZxY7FfqHiuMYOYaZ+QIK7l5ItFrHqsdaWfk3Im+mg==, tarball: file:projects/pod-front.tgz}
+    resolution: {integrity: sha512-zddL78pZTraJUeh9Bw71Z/OvME1mNxa6KHTBoCEo4Tla77Nl3bHyoziS5DgfJgCgXF3Y1Fc/3dCUM507YmHNlg==, tarball: file:projects/pod-front.tgz}
     id: file:projects/pod-front.tgz
     name: '@rush-temp/pod-front'
     version: 0.0.0
@@ -20706,7 +20742,7 @@ packages:
       '@types/express-fileupload': 1.4.2
       '@types/jest': 29.5.5
       '@types/node': 16.11.68
-      '@types/sharp': 0.30.5
+      '@types/sharp': 0.32.0
       '@types/uuid': 8.3.4
       '@typescript-eslint/eslint-plugin': 6.11.0(@typescript-eslint/parser@6.11.0)(eslint@8.54.0)(typescript@5.2.2)
       '@typescript-eslint/parser': 6.11.0(eslint@8.54.0)(typescript@5.2.2)
@@ -20725,7 +20761,7 @@ packages:
       jest: 29.7.0(@types/node@16.11.68)(ts-node@10.9.1)
       prettier: 3.1.0
       prettier-plugin-svelte: 3.1.0(prettier@3.1.0)(svelte@4.2.5)
-      sharp: 0.30.7
+      sharp: 0.32.6
       ts-jest: 29.1.1(esbuild@0.16.17)(jest@29.7.0)(typescript@5.2.2)
       ts-node: 10.9.1(@types/node@16.11.68)(typescript@5.2.2)
       typescript: 5.2.2
diff --git a/pods/front/Dockerfile b/pods/front/Dockerfile
index d10d4a34bb..88d49587e0 100644
--- a/pods/front/Dockerfile
+++ b/pods/front/Dockerfile
@@ -4,7 +4,7 @@ RUN apk add dumb-init
 ENV NODE_ENV production
 
 WORKDIR /app
-RUN npm install --ignore-scripts=false --verbose sharp --unsafe-perm
+RUN npm install --ignore-scripts=false --verbose sharp@v0.32.6 --unsafe-perm
 
 COPY bundle.js ./
 COPY dist/ ./dist/
diff --git a/pods/front/package.json b/pods/front/package.json
index 1ca6194c32..9a623c332d 100644
--- a/pods/front/package.json
+++ b/pods/front/package.json
@@ -39,7 +39,7 @@
     "cross-env": "~7.0.3",
     "ts-node": "^10.8.0",
     "@types/compression": "~1.7.2",
-    "@types/sharp": "~0.30.4",
+    "@types/sharp": "~0.32.0",
     "jest": "^29.7.0",
     "ts-jest": "^29.1.1",
     "@types/jest": "^29.5.5",
@@ -59,6 +59,6 @@
     "@hcengineering/attachment": "^0.6.9",
     "body-parser": "~1.19.1",
     "compression": "~1.7.4",
-    "sharp": "~0.30.7"
+    "sharp": "~0.32.0"
   }
 }
diff --git a/server/front/Dockerfile b/server/front/Dockerfile
deleted file mode 100644
index d10d4a34bb..0000000000
--- a/server/front/Dockerfile
+++ /dev/null
@@ -1,13 +0,0 @@
-FROM node:20-alpine
-
-RUN apk add dumb-init
-ENV NODE_ENV production
-
-WORKDIR /app
-RUN npm install --ignore-scripts=false --verbose sharp --unsafe-perm
-
-COPY bundle.js ./
-COPY dist/ ./dist/
-
-EXPOSE 8080
-CMD [ "dumb-init", "node", "./bundle.js" ]
diff --git a/server/front/package.json b/server/front/package.json
index 73ef7471ef..7ac9b4ff86 100644
--- a/server/front/package.json
+++ b/server/front/package.json
@@ -32,7 +32,7 @@
     "cross-env": "~7.0.3",
     "ts-node": "^10.8.0",
     "@types/compression": "~1.7.2",
-    "@types/sharp": "~0.30.4",
+    "@types/sharp": "~0.32.0",
     "jest": "^29.7.0",
     "ts-jest": "^29.1.1",
     "@types/jest": "^29.5.5",
@@ -51,7 +51,7 @@
     "@hcengineering/attachment": "^0.6.9",
     "body-parser": "~1.19.1",
     "compression": "~1.7.4",
-    "sharp": "~0.30.7",
+    "sharp": "~0.32.0",
     "@hcengineering/minio": "^0.6.0"
   }
 }
diff --git a/server/front/src/index.ts b/server/front/src/index.ts
index f290b2f93d..83d7b16d5c 100644
--- a/server/front/src/index.ts
+++ b/server/front/src/index.ts
@@ -562,7 +562,9 @@ async function getResizeID (
     try {
       const d = await config.minio.stat(payload.workspace, sizeId)
       hasSmall = d !== undefined && d.size > 0
-    } catch (err) {}
+    } catch (err: any) {
+      console.error(err)
+    }
     if (hasSmall) {
       // We have cached small document, let's proceed with it.
       uuid = sizeId