Skip to content
222 changes: 120 additions & 102 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,102 +1,120 @@
FROM oven/bun:1.4.5-slim AS base
WORKDIR /app
COPY package.json bun.lock /app/
RUN bun install --frozen-lockfile
COPY . .

RUN bun run build:bin

FROM debian:testing-slim AS release
LABEL org.opencontainers.image.source="https://github.com/C4illin/ConvertX"
WORKDIR /app

# install additional dependencies
ENV PIPX_HOME=/opt/pipx
ENV PIPX_BIN_DIR=/usr/local/bin

RUN apt-get update && apt-get install -y \
assimp-utils \
ca-certificates \
calibre \
curl \
dasel \
dcraw \
djvulibre-bin \
dvisvgm \
ffmpeg \
ghostscript \
gosu \
graphicsmagick \
imagemagick-7.q16 \
inkscape \
latexmk \
libheif-examples \
libjxl-tools \
libreoffice-calc-nogui \
libreoffice-draw-nogui \
libreoffice-writer-nogui \
libva2 \
libvips-tools \
libemail-address-perl \
libemail-outlook-message-perl \
lmodern \
mupdf-tools \
pandoc \
poppler-utils \
potrace \
python3-numpy \
python3-tinycss2 \
resvg \
texlive \
texlive-fonts-recommended \
texlive-latex-extra \
texlive-latex-recommended \
texlive-xetex \
python3 \
python3-pip \
pipx \
--no-install-recommends \
&& pipx install "markitdown[all]" \
&& rm -rf /var/lib/apt/lists/*

# Remove when patch is released
RUN pipx runpip markitdown install --upgrade --no-cache-dir "Brotli>=1.2.1" "brotlicffi>=1.2.1.0"

RUN groupadd -g 1000 convertx && \
useradd -u 1000 -g convertx -d /home/convertx -m -s /bin/bash convertx

# Install VTracer binary
RUN ARCH=$(uname -m) && \
if [ "$ARCH" = "aarch64" ]; then \
VTRACER_ASSET="vtracer-aarch64-unknown-linux-musl.tar.gz"; \
else \
VTRACER_ASSET="vtracer-x86_64-unknown-linux-musl.tar.gz"; \
fi && \
curl -L -o /tmp/vtracer.tar.gz "https://github.com/visioncortex/vtracer/releases/download/0.6.4/${VTRACER_ASSET}" && \
tar -xzf /tmp/vtracer.tar.gz -C /tmp/ && \
mv /tmp/vtracer /usr/local/bin/vtracer && \
chmod +x /usr/local/bin/vtracer && \
rm /tmp/vtracer.tar.gz

COPY --from=base /app/public/ /app/public/
COPY --from=base /app/dist/convertx /app/convertx

# COPY . .
RUN mkdir data

COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

EXPOSE 3000/tcp
# used for calibre
ENV QTWEBENGINE_CHROMIUM_FLAGS="--no-sandbox"
ENV NODE_ENV=production
ENTRYPOINT [ "/entrypoint.sh" ]
CMD [ "/app/convertx" ]

# test stage that includes Bun for running tests if needed
FROM release AS test
COPY --from=base /usr/local/bin/bun /usr/local/bin/bun

# default target remains release
FROM release
FROM oven/bun:1.4.5-slim AS base
WORKDIR /app
COPY package.json bun.lock /app/
RUN bun install --frozen-lockfile
COPY . .

RUN bun run build:bin

FROM debian:testing-slim AS release
LABEL org.opencontainers.image.source="https://github.com/C4illin/ConvertX"
WORKDIR /app

# install additional dependencies
ENV PIPX_HOME=/opt/pipx
ENV PIPX_BIN_DIR=/usr/local/bin

RUN apt-get update && apt-get install -y \
assimp-utils \
ca-certificates \
calibre \
curl \
dasel \
dcraw \
djvulibre-bin \
dvisvgm \
ffmpeg \
ghostscript \
gosu \
graphicsmagick \
imagemagick-7.q16 \
inkscape \
latexmk \
libheif-examples \
libjxl-tools \
libreoffice-calc-nogui \
libreoffice-draw-nogui \
libreoffice-writer-nogui \
libva2 \
libvips-tools \
libemail-address-perl \
libemail-outlook-message-perl \
lmodern \
mupdf-tools \
pandoc \
poppler-utils \
potrace \
python3-numpy \
python3-tinycss2 \
resvg \
texlive \
texlive-fonts-recommended \
texlive-latex-extra \
texlive-latex-recommended \
texlive-xetex \
python3 \
python3-pip \
pipx \
--no-install-recommends \
&& pipx install "markitdown[all]" \
&& rm -rf /var/lib/apt/lists/*

# Remove when patch is released
RUN pipx runpip markitdown install --upgrade --no-cache-dir "Brotli>=1.2.1" "brotlicffi>=1.2.1.0"

RUN groupadd -g 1000 convertx && \
useradd -u 1000 -g convertx -d /home/convertx -m -s /bin/bash convertx

# Install VTracer binary
RUN ARCH=$(uname -m) && \
if [ "$ARCH" = "aarch64" ]; then \
VTRACER_ASSET="vtracer-aarch64-unknown-linux-musl.tar.gz"; \
else \
VTRACER_ASSET="vtracer-x86_64-unknown-linux-musl.tar.gz"; \
fi && \
curl -L -o /tmp/vtracer.tar.gz "https://github.com/visioncortex/vtracer/releases/download/0.6.4/${VTRACER_ASSET}" && \
tar -xzf /tmp/vtracer.tar.gz -C /tmp/ && \
mv /tmp/vtracer /usr/local/bin/vtracer && \
chmod +x /usr/local/bin/vtracer && \
rm /tmp/vtracer.tar.gz

# Install oxidocs binary (docx, pptx and xlsx to pdf/png). It writes the fonts it
# carries next to itself on first use, so that is done here, as root: with PUID
# set, /usr/local/bin is not writable when it runs.
# renovate: datasource=github-releases depName=Ryujiyasu/oxi versioning=regex:^(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)(?:-static\.(?<build>\d+))?$ extractVersion=^oxidocs-v(?<version>.+)$
ARG OXIDOCS_VERSION=0.9.0-static.6
RUN ARCH=$(uname -m) && \
if [ "$ARCH" = "aarch64" ]; then \
OXIDOCS_ASSET="oxidocs-aarch64-unknown-linux-musl"; \
else \
OXIDOCS_ASSET="oxidocs-x86_64-unknown-linux-musl"; \
fi && \
curl -fL -o /tmp/oxidocs.tar.gz "https://github.com/Ryujiyasu/oxi/releases/download/oxidocs-v${OXIDOCS_VERSION}/${OXIDOCS_ASSET}.tar.gz" && \
tar -xzf /tmp/oxidocs.tar.gz -C /tmp/ && \
mv "/tmp/${OXIDOCS_ASSET}/oxidocs" /usr/local/bin/oxidocs && \
chmod +x /usr/local/bin/oxidocs && \
oxidocs fonts-index > /dev/null && \
rm -r /tmp/oxidocs.tar.gz "/tmp/${OXIDOCS_ASSET}"

COPY --from=base /app/public/ /app/public/
COPY --from=base /app/dist/convertx /app/convertx

# COPY . .
RUN mkdir data

COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

EXPOSE 3000/tcp
# used for calibre
ENV QTWEBENGINE_CHROMIUM_FLAGS="--no-sandbox"
ENV NODE_ENV=production
ENTRYPOINT [ "/entrypoint.sh" ]
CMD [ "/app/convertx" ]

# test stage that includes Bun for running tests if needed
FROM release AS test
COPY --from=base /usr/local/bin/bun /usr/local/bin/bun

# default target remains release
FROM release
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ A self-hosted online file converter. Supports over a thousand different formats.
| [XeLaTeX](https://tug.org/xetex/) | LaTeX | 1 | 1 |
| [Calibre](https://calibre-ebook.com/) | E-books | 26 | 19 |
| [LibreOffice](https://www.libreoffice.org/) | Documents | 41 | 22 |
| [Oxi](https://github.com/Ryujiyasu/oxi) | Word documents | 3 | 2 |
| [Dasel](https://github.com/TomWright/dasel) | Data Files | 5 | 4 |
| [DjVuLibre](https://djvu.sourceforge.net/) | Documents | 2 | 2 |
| [Pandoc](https://pandoc.org/) | Documents | 43 | 65 |
Expand Down
1 change: 1 addition & 0 deletions knip.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"heif-info",
"potrace",
"soffice",
"oxidocs",
"perl",
"markitdown"
],
Expand Down
6 changes: 5 additions & 1 deletion renovate.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["config:recommended", ":disableDependencyDashboard"],
"extends": [
"config:recommended",
":disableDependencyDashboard",
"customManagers:dockerfileVersions"
],
"lockFileMaintenance": {
"enabled": true,
"automerge": true
Expand Down
5 changes: 5 additions & 0 deletions src/converters/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { convert as convertLibjxl, properties as propertiesLibjxl } from "./libj
import { convert as convertLibreOffice, properties as propertiesLibreOffice } from "./libreoffice";
import { convert as convertMarkitdown, properties as propertiesMarkitdown } from "./markitdown";
import { convert as convertMsgconvert, properties as propertiesMsgconvert } from "./msgconvert";
import { convert as convertOxidocs, properties as propertiesOxidocs } from "./oxidocs";
import { convert as convertPandoc, properties as propertiesPandoc } from "./pandoc";
import { convert as convertPdftops, properties as propertiesPdftops } from "./pdftops";
import { convert as convertPotrace, properties as propertiesPotrace } from "./potrace";
Expand Down Expand Up @@ -108,6 +109,10 @@ const properties: Record<
properties: propertiesLibreOffice,
converter: convertLibreOffice,
},
oxidocs: {
properties: propertiesOxidocs,
converter: convertOxidocs,
},
pandoc: {
properties: propertiesPandoc,
converter: convertPandoc,
Expand Down
60 changes: 60 additions & 0 deletions src/converters/oxidocs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { execFile as execFileOriginal } from "node:child_process";

import { ExecFileFn } from "./types";

export const properties = {
from: {
text: ["docx", "docm", "dotx"],
presentation: ["pptx", "pptm", "potx"],
calc: ["xlsx", "xlsm", "xltx", "xltm"],
},
to: {
text: ["pdf", "png"],
presentation: ["pdf", "png"],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: The new category targets let the /convert endpoint accept xlsx→png through oxidocs, then run unsupported xlsx-to-png. Validate the target against the uploaded file's input category before starting conversion.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At src/converters/oxidocs.ts, line 13:

<comment>The new category targets let the `/convert` endpoint accept xlsx→png through oxidocs, then run unsupported `xlsx-to-png`. Validate the target against the uploaded file's input category before starting conversion.</comment>

<file context>
@@ -5,12 +5,19 @@ import { ExecFileFn } from "./types";
   },
   to: {
     text: ["pdf", "png"],
+    presentation: ["pdf", "png"],
+    calc: ["pdf"],
   },
</file context>

calc: ["pdf", "png"],
},
};

const presentations = new Set(properties.from.presentation);
const workbooks = new Set(properties.from.calc);

export function convert(
filePath: string,
fileType: string,
convertTo: string,
targetPath: string,
options?: unknown,
execFile: ExecFileFn = execFileOriginal, // to make it mockable
): Promise<string> {
// png draws the first page (the first slide, the first printed page of a
// workbook); pdf converts the whole
// document, every slide, or the print areas of every visible sheet.
// --strict: when the document holds content Oxi does not draw, it writes
// nothing and fails (naming the content) rather than hand back a file with
// parts missing; LibreOffice can then be chosen instead.
// --quiet: nothing is printed on success, only warnings and errors
const kind = presentations.has(fileType) ? "pptx" : workbooks.has(fileType) ? "xlsx" : "docx";
const command = `${kind}-to-${convertTo === "png" ? "png" : "pdf"}`;

return new Promise((resolve, reject) => {
execFile(
"oxidocs",
[command, "--strict", "--quiet", filePath, targetPath],
(error, stdout, stderr) => {
if (error) {
reject(`error: ${error}`);
}

if (stdout) {
console.log(`stdout: ${stdout}`);
}

if (stderr) {
console.error(`stderr: ${stderr}`);
}

resolve("Done");
},
);
});
}
11 changes: 11 additions & 0 deletions src/helpers/printVersions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,17 @@ if (process.env.NODE_ENV === "production") {
}
});

exec("oxidocs --version", (error, stdout) => {
if (error) {
console.error("oxidocs is not installed");
return;
}

if (stdout) {
console.log(`oxidocs v${stdout.replace("oxidocs", "").trim()}`);
}
});

exec("xelatex -version", (error, stdout) => {
if (error) {
console.error("Tex Live with XeTeX is not installed.");
Expand Down
1 change: 1 addition & 0 deletions tests/converters/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ describe("converter registry", () => {
"libreoffice",
"markitDown",
"msgconvert",
"oxidocs",
"pandoc",
"pdftops",
"potrace",
Expand Down
Loading