mirror of
https://github.com/C4illin/ConvertX.git
synced 2025-10-23 04:52:18 +00:00
104 lines
2.8 KiB
Docker
104 lines
2.8 KiB
Docker
FROM debian:trixie-slim AS base
|
|
LABEL org.opencontainers.image.source="https://github.com/C4illin/ConvertX"
|
|
WORKDIR /app
|
|
|
|
# install bun
|
|
RUN apt-get update && apt-get install -y \
|
|
curl \
|
|
unzip \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# if architecture is arm64, use the arm64 version of bun
|
|
RUN ARCH=$(uname -m) && \
|
|
if [ "$ARCH" = "aarch64" ]; then \
|
|
curl -fsSL -o bun-linux-aarch64.zip https://github.com/oven-sh/bun/releases/download/bun-v1.2.2/bun-linux-aarch64.zip; \
|
|
else \
|
|
curl -fsSL -o bun-linux-x64-baseline.zip https://github.com/oven-sh/bun/releases/download/bun-v1.2.2/bun-linux-x64-baseline.zip; \
|
|
fi
|
|
|
|
RUN unzip -j bun-linux-*.zip -d /usr/local/bin && \
|
|
rm bun-linux-*.zip && \
|
|
chmod +x /usr/local/bin/bun
|
|
|
|
# install dependencies into temp directory
|
|
# this will cache them and speed up future builds
|
|
FROM base AS install
|
|
RUN mkdir -p /temp/dev
|
|
COPY package.json bun.lock /temp/dev/
|
|
RUN cd /temp/dev && bun install --frozen-lockfile
|
|
|
|
# install with --production (exclude devDependencies)
|
|
RUN mkdir -p /temp/prod
|
|
COPY package.json bun.lock /temp/prod/
|
|
RUN cd /temp/prod && bun install --frozen-lockfile --production
|
|
|
|
FROM base AS prerelease
|
|
WORKDIR /app
|
|
COPY --from=install /temp/dev/node_modules node_modules
|
|
COPY . .
|
|
|
|
# ENV NODE_ENV=production
|
|
RUN bun run build
|
|
|
|
# copy production dependencies and source code into final image
|
|
FROM base AS release
|
|
|
|
# install additional dependencies
|
|
RUN apt-get update && apt-get install -y \
|
|
assimp-utils \
|
|
calibre \
|
|
dasel \
|
|
dcraw \
|
|
dvisvgm \
|
|
ffmpeg \
|
|
ghostscript \
|
|
graphicsmagick \
|
|
imagemagick-7.q16 \
|
|
inkscape \
|
|
latexmk \
|
|
libheif-examples \
|
|
libjxl-tools \
|
|
libreoffice \
|
|
libva2 \
|
|
libvips-tools \
|
|
libemail-outlook-message-perl \
|
|
lmodern \
|
|
mupdf-tools \
|
|
pandoc \
|
|
poppler-utils \
|
|
potrace \
|
|
python3-numpy \
|
|
resvg \
|
|
texlive \
|
|
texlive-fonts-recommended \
|
|
texlive-latex-extra \
|
|
texlive-latex-recommended \
|
|
texlive-xetex \
|
|
--no-install-recommends \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# 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=install /temp/prod/node_modules node_modules
|
|
COPY --from=prerelease /app/public/ /app/public/
|
|
COPY --from=prerelease /app/dist /app/dist
|
|
|
|
# COPY . .
|
|
RUN mkdir data
|
|
|
|
EXPOSE 3000/tcp
|
|
# used for calibre
|
|
ENV QTWEBENGINE_CHROMIUM_FLAGS="--no-sandbox"
|
|
ENV NODE_ENV=production
|
|
ENTRYPOINT [ "bun", "run", "dist/src/index.js" ] |