Skip to content

πŸ”₯ πŸ”₯ πŸ”₯ A Free & Self-hostable Airtable Alternative

fix: set office file generation to ee only

DarkPhoenix270439cc9cf3674c
diff --git a/packages/nocodb/Dockerfile b/packages/nocodb/Dockerfile
index 853b599d74..c6b4e8aeba 100644
--- a/packages/nocodb/Dockerfile
+++ b/packages/nocodb/Dockerfile
@@ -68,31 +68,17 @@ ENV LITESTREAM_S3_SKIP_VERIFY=false \
NC_DOCKER=0.6 \
NC_TOOL_DIR=/usr/app/data/ \
NODE_ENV=production \
- PORT=8080 \
- HOME=/tmp
-
-# Create non-root user
-RUN groupadd -g 1001 nocodb && \
- useradd -r -u 1001 -g nocodb nocodb
+ PORT=8080
# Install runtime dependencies
RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y --no-install-recommends \
- ca-certificates `# required by wget for HTTPS support` \
- curl \
- dumb-init \
- fontconfig \
- fonts-dejavu-core \
- fonts-liberation \
- # required for thumbnail generation
- libreoffice \
- wget `# for convenience of downstream users` \
- && curl -L "https://github.com/TomWright/dasel/releases/download/v2.8.1/dasel_linux_$(dpkg --print-architecture)" -o /usr/local/bin/dasel \
- && chmod +x /usr/local/bin/dasel \
- && fc-cache -f -v \
- && apt-get clean && rm -rf /var/lib/apt/lists/*
-
-# Set proper permissions
-RUN chown -R nocodb:nocodb /usr/src/app
+ ca-certificates `# required by wget for HTTPS support` \
+ curl \
+ dumb-init \
+ wget `# for convenience of downstream users` \
+ && curl -L "https://github.com/TomWright/dasel/releases/download/v2.8.1/dasel_linux_$(dpkg --print-architecture)" -o /usr/local/bin/dasel \
+ && chmod +x /usr/local/bin/dasel \
+ && apt-get clean && rm -rf /var/lib/apt/lists/*
# Copy litestream binary and config file
COPY --link --from=lt-builder /usr/src/lt /usr/local/bin/litestream
@@ -102,9 +88,6 @@ COPY --link ./docker/litestream.yml /etc/litestream.yml
COPY --link --from=builder /usr/src/app/ /usr/src/app/
COPY --link --from=builder /usr/src/appEntry/ /usr/src/appEntry/
-# Switch to non-root user
-USER nocodb
-
EXPOSE 8080
ENTRYPOINT ["/usr/bin/dumb-init", "--"]
diff --git a/packages/nocodb/Dockerfile.local b/packages/nocodb/Dockerfile.local
index 338ac217b1..5fedd4b95f 100644
--- a/packages/nocodb/Dockerfile.local
+++ b/packages/nocodb/Dockerfile.local
@@ -41,37 +41,20 @@ FROM alpine:3.20
WORKDIR /usr/src/app
ENV NC_DOCKER=0.6 \
- NC_TOOL_DIR=/usr/app/data/ \
- NODE_ENV=production \
- PORT=8080 \
- HOME=/tmp
-
-# Create non-root user
-RUN addgroup -g 1001 -S nocodb && \
- adduser -S nocodb -u 1001 -G nocodb
+ NC_TOOL_DIR=/usr/app/data/ \
+ NODE_ENV=production \
+ PORT=8080
RUN apk add --update --no-cache \
- curl \
- dumb-init \
- fontconfig \
- jq \
- nodejs \
- # required for thumbnail generation
- libreoffice \
- ttf-dejavu \
- ttf-liberation && \
- fc-cache -f -v
-
-# Set proper permissions
-RUN chown -R nocodb:nocodb /usr/src/app
+ curl \
+ dumb-init \
+ jq \
+ nodejs
# Copy production code & main entry file
COPY --link --from=builder /usr/src/app/ /usr/src/app/
COPY --link --from=builder /usr/src/appEntry/ /usr/src/appEntry/
-# Switch to non-root user
-USER nocodb
-
EXPOSE 8080
ENTRYPOINT ["/usr/bin/dumb-init", "--"]
diff --git a/packages/nocodb/Dockerfile.timely b/packages/nocodb/Dockerfile.timely
index acf7ea8ba1..483d38c1e4 100644
--- a/packages/nocodb/Dockerfile.timely
+++ b/packages/nocodb/Dockerfile.timely
@@ -97,24 +97,14 @@ ENV LITESTREAM_S3_SKIP_VERIFY=false \
NODE_ENV=production \
PORT=8080
-
-# Create non-root user
-RUN groupadd -g 1001 -r nocodb && \
- useradd -r -u 1001 -g nocodb nocodb
-
# Install runtime dependencies
RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y --no-install-recommends \
ca-certificates `# required by wget for HTTPS support` \
curl \
dumb-init \
wget `# for convenience of downstream users` \
- # required for thumbnail generation
- libreoffice \
- fonts-dejavu \
- fonts-liberation \
&& curl -L "https://github.com/TomWright/dasel/releases/download/v2.8.1/dasel_linux_$(dpkg --print-architecture)" -o /usr/local/bin/dasel \
&& chmod +x /usr/local/bin/dasel \
- && fc-cache -f -v \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
# Copy litestream binary and config file
@@ -127,14 +117,8 @@ COPY --link --from=builder /usr/src/appEntry/ /usr/src/appEn
COPY --link --from=bin-builder /usr/src/app/node_modules/sqlite3/ /usr/src/app/node_modules/sqlite3/
COPY --link --from=bin-builder /usr/src/app/node_modules/sharp/ /usr/src/app/node_modules/sharp/
-# Set proper permissions
-RUN chown -R nocodb:nocodb /usr/src/app
-
-# Switch to non-root user
-USER nocodb
-
EXPOSE 8080
ENTRYPOINT ["/usr/bin/dumb-init", "--"]
# Start NocoDB
-CMD ["/usr/src/appEntry/start.sh"]
+CMD ["/usr/src/appEntry/start.sh"]
\ No newline at end of file
diff --git a/packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/thumbnail-generator.processor.ts b/packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/thumbnail-generator.processor.ts
index 428973f9a0..ed36cbcffd 100644
--- a/packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/thumbnail-generator.processor.ts
+++ b/packages/nocodb/src/modules/jobs/jobs/thumbnail-generator/thumbnail-generator.processor.ts
@@ -89,8 +89,15 @@ export class ThumbnailGeneratorProcessor {
storageAdapter,
);
- case isOfficeDocument(mimeType, fileExtension) &&
- Noco.isOfficeThumbnailGenerationAvailable:
+ case isOfficeDocument(mimeType, fileExtension):
+ if (!Noco.isOfficeThumbnailGenerationAvailable) {
+ this.logger.warn({
+ message: `Thumbnail generation is not available for this file, skipping thumbnail generation`,
+ mimetype: mimeType,
+ filename: attachment.title,
+ });
+ return null;
+ }
return await this.officeGenerator.generateThumbnails(
file,
relativePath,
diff --git a/packages/nocodb/src/utils/attachmentUtils.ts b/packages/nocodb/src/utils/attachmentUtils.ts
index fcb1d90436..d58e8ded85 100644
--- a/packages/nocodb/src/utils/attachmentUtils.ts
+++ b/packages/nocodb/src/utils/attachmentUtils.ts
@@ -1,156 +1,11 @@
-import path from 'path';
-
-/**
- * Checks if a file is an Office document based on MIME type and file extension
- * @param mimeType - The MIME type of the file
- * @param fileExtension - The file extension (with or without leading dot)
- * @returns true if the file is an Office document, false otherwise
- */
-export function isOfficeDocument(
- mimeType: string,
- fileExtension: string,
-): boolean {
- const officeMimeTypes = [
- // Microsoft Office formats
- 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', // .docx
- 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', // .xlsx
- 'application/vnd.openxmlformats-officedocument.presentationml.presentation', // .pptx
- 'application/msword', // .doc
- 'application/vnd.ms-excel', // .xls
- 'application/vnd.ms-powerpoint', // .ppt
- 'application/rtf', // .rtf
-
- // OpenDocument formats (LibreOffice/OpenOffice)
- 'application/vnd.oasis.opendocument.text', // .odt
- 'application/vnd.oasis.opendocument.spreadsheet', // .ods
- 'application/vnd.oasis.opendocument.presentation', // .odp
- 'application/vnd.oasis.opendocument.graphics', // .odg
- 'application/vnd.oasis.opendocument.chart', // .odc
- 'application/vnd.oasis.opendocument.formula', // .odf
- 'application/vnd.oasis.opendocument.database', // .odb
- 'application/vnd.oasis.opendocument.image', // .odi
- 'application/vnd.oasis.opendocument.text-master', // .odm
- 'application/vnd.oasis.opendocument.text-web', // .oth
-
- // Flat OpenDocument formats
- 'application/vnd.oasis.opendocument.text-flat-xml', // .fodt
- 'application/vnd.oasis.opendocument.spreadsheet-flat-xml', // .fods
- 'application/vnd.oasis.opendocument.presentation-flat-xml', // .fodp
- 'application/vnd.oasis.opendocument.graphics-flat-xml', // .fodg
-
- // Legacy formats
- 'application/vnd.sun.xml.writer', // .sxw (OpenOffice 1.x Writer)
- 'application/vnd.sun.xml.calc', // .sxc (OpenOffice 1.x Calc)
- 'application/vnd.sun.xml.impress', // .sxi (OpenOffice 1.x Impress)
- 'application/vnd.sun.xml.draw', // .sxd (OpenOffice 1.x Draw)
- 'application/vnd.sun.xml.math', // .sxm (OpenOffice 1.x Math)
- 'application/vnd.sun.xml.writer.global', // .sxg (OpenOffice 1.x Master Document)
- 'application/vnd.sun.xml.writer.template', // .stw (OpenOffice 1.x Writer Template)
- 'application/vnd.sun.xml.calc.template', // .stc (OpenOffice 1.x Calc Template)
- 'application/vnd.sun.xml.impress.template', // .sti (OpenOffice 1.x Impress Template)
- 'application/vnd.sun.xml.draw.template', // .std (OpenOffice 1.x Draw Template)
-
- // Other office formats
- 'application/vnd.lotus-1-2-3', // .123 (Lotus 1-2-3)
- 'application/x-abiword', // .abw (AbiWord)
- 'application/x-gnumeric', // .gnumeric (Gnumeric)
- ];
-
- const officeExtensions = [
- // Microsoft Office
- '.docx',
- '.doc',
- '.xlsx',
- '.xls',
- '.pptx',
- '.ppt',
- '.rtf',
-
- // OpenDocument formats
- '.odt',
- '.ods',
- '.odp',
- '.odg',
- '.odc',
- '.odf',
- '.odb',
- '.odi',
- '.odm',
- '.oth',
-
- // Flat OpenDocument formats
- '.fodt',
- '.fods',
- '.fodp',
- '.fodg',
-
- // OpenOffice 1.x formats
- '.sxw',
- '.sxc',
- '.sxi',
- '.sxd',
- '.sxm',
- '.sxg',
- '.stw',
- '.stc',
- '.sti',
- '.std',
-
- // Other office formats
- '.abw',
- '.gnumeric',
-
- // Additional LibreOffice template formats
- '.ott', // OpenDocument Text Template
- '.ots', // OpenDocument Spreadsheet Template
- '.otp', // OpenDocument Presentation Template
- '.otg', // OpenDocument Graphics Template
- '.otf', // OpenDocument Formula Template
- '.oth', // OpenDocument Text Web Template
-
- // Legacy Microsoft templates
- '.dot', // Word Document Template
- '.xlt', // Excel Template
- '.pot', // PowerPoint Template
- '.dotx', // Word 2007+ Template
- '.xltx', // Excel 2007+ Template
- '.potx', // PowerPoint 2007+ Template
- '.dotm', // Word Macro-Enabled Template
- '.xltm', // Excel Macro-Enabled Template
- '.potm', // PowerPoint Macro-Enabled Template
-
- // Additional Microsoft formats
- '.docm', // Word Macro-Enabled Document
- '.xlsm', // Excel Macro-Enabled Workbook
- '.pptm', // PowerPoint Macro-Enabled Presentation
- '.xlsb', // Excel Binary Workbook
-
- '.tsv', // Tab Separated Values
- '.txt', // Plain text (when opened in office apps)
- ];
-
- // Normalize file extension to lowercase and ensure it starts with a dot
- const normalizedExtension = fileExtension.startsWith('.')
- ? fileExtension.toLowerCase()
- : `.${fileExtension.toLowerCase()}`;
-
- return (
- officeMimeTypes.includes(mimeType) ||
- officeExtensions.includes(normalizedExtension)
- );
-}
+export const isOfficeDocument = (..._args) => {
+ return false;
+};
export const supportsThumbnails = (attachment: any) => {
const mimetype = attachment.mimetype || attachment.mimeType;
- const filename =
- attachment.title || attachment.filename || attachment.name || '';
-
- // Extract file extension from filename
- const fileExtension = path.extname(filename);
- return (
- mimetype?.startsWith('image/') ||
- mimetype?.startsWith('application/pdf') ||
- isOfficeDocument(mimetype || '', fileExtension)
+ return !!(
+ mimetype.startsWith('image/') || mimetype.startsWith('application/pdf')
);
};