Skip to content

Commit

Permalink
chore(conversion): optimize Dockerfile using Alpine Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
bouassaba committed Jun 14, 2024
1 parent c2bd589 commit a438f46
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 62 deletions.
121 changes: 69 additions & 52 deletions conversion/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,73 +7,90 @@ COPY . .
RUN go mod download
RUN go build -o voltaserve-conversion

FROM mcr.microsoft.com/playwright:jammy AS runner
FROM zenika/alpine-chrome:124-with-playwright

RUN apt-get update
RUN apt-get install -y software-properties-common
RUN add-apt-repository universe
RUN apt-get update
USER root

RUN apt-get install -y \
RUN apk update

RUN apk add --no-cache \
curl \
ffmpeg \
gawk \
ghostscript \
imagemagick \
poppler-utils \
libimage-exiftool-perl \
exiftool \
perl-image-exiftool \
ocrmypdf \
unzip

RUN npm i -g gltf-pipeline
RUN npm i -g @koupr/screenshot-glb
RUN npm i -g @shopify/screenshot-glb

RUN apt-get install -y \
libreoffice-base-nogui \
libreoffice-core-nogui \
libreoffice-writer-nogui \
libreoffice-calc-nogui \
libreoffice-impress-nogui \
libreoffice-draw-nogui \
libreoffice-math-nogui
RUN apk add --no-cache \
libreoffice-base \
libreoffice-writer \
libreoffice-calc \
libreoffice-impress \
libreoffice-draw \
libreoffice-math

RUN apt-get install -y \
fonts-dejavu-core \
fonts-dejavu-extra \
fonts-droid-fallback \
fonts-font-awesome \
fonts-liberation \
fonts-liberation2 \
fonts-noto-cjk \
fonts-noto-color-emoji \
fonts-noto-core \
fonts-noto-mono \
fonts-ubuntu \
fonts-ubuntu-console \
fonts-inconsolata \
fonts-roboto \
fonts-roboto-slab \
fonts-open-sans \
fonts-hack \
fonts-firacode \
fonts-anonymous-pro \
fonts-comfortaa \
fonts-cantarell \
fonts-lobster \
fonts-monoid \
fonts-jetbrains-mono
RUN apk add --no-cache \
font-dejavu \
font-droid \
font-droid-nonlatin \
font-awesome \
font-liberation \
font-liberation-sans-narrow \
font-noto-cjk \
font-noto-all \
font-noto-cjk-extra \
font-noto-emoji \
font-ubuntu \
font-inconsolata \
font-roboto \
font-roboto-flex \
font-roboto-mono \
font-opensans \
font-hack \
font-cantarell \
font-jetbrains-mono \
font-adobe-source-code-pro \
font-adobe-utopia-100dpi \
font-adobe-utopia-75dpi \
font-adobe-utopia-type1 \
font-alias \
font-arimo \
font-b612 \
font-barlow \
font-bh-100dpi \
font-bh-75dpi \
font-bitstream-100dpi \
font-bitstream-75dpi \
font-bitstream-type1 \
font-carlito \
font-croscore \
font-eb-garamond \
font-freefont \
font-inter \
font-montserrat \
font-noto \
font-overpass \
font-vollkorn \
font-wqy-zenhei

RUN apt-get install -y \
RUN apk add --no-cache \
tesseract-ocr \
tesseract-ocr-osd \
tesseract-ocr-ara \
tesseract-ocr-chi-sim \
tesseract-ocr-chi-tra \
tesseract-ocr-eng \
tesseract-ocr-fra \
tesseract-ocr-deu \
tesseract-ocr-por \
tesseract-ocr-spa
tesseract-ocr-data-osd \
tesseract-ocr-data-ara \
tesseract-ocr-data-chi_sim \
tesseract-ocr-data-chi_tra \
tesseract-ocr-data-eng \
tesseract-ocr-data-fra \
tesseract-ocr-data-deu \
tesseract-ocr-data-por \
tesseract-ocr-data-spa

WORKDIR /app

Expand All @@ -82,4 +99,4 @@ COPY --from=builder /build/.env ./.env

ENTRYPOINT ["./voltaserve-conversion"]

EXPOSE 8083
EXPOSE 8083
12 changes: 2 additions & 10 deletions conversion/processor/glb_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package processor

import (
"fmt"
"runtime"
"voltaserve/config"
"voltaserve/infra"
)
Expand All @@ -22,15 +21,8 @@ func NewGLBProcessor() *GLBProcessor {
}

func (p *GLBProcessor) Thumbnail(inputPath string, width int, height int, color string, outputPath string) error {
switch os := runtime.GOOS; os {
case "darwin":
if err := infra.NewCommand().Exec("screenshot-glb", "-i", inputPath, "-o", outputPath, "--width", fmt.Sprintf("%d", width), "--height", fmt.Sprintf("%d", height), "--color", color); err != nil {
return err
}
case "linux":
if err := infra.NewCommand().Exec("xvfb-run", "--auto-servernum", "--server-args", "-screen 0 1280x1024x24", "screenshot-glb", "-i", inputPath, "-o", outputPath, "--width", fmt.Sprintf("%d", width), "--height", fmt.Sprintf("%d", height), "--color", color); err != nil {
return err
}
if err := infra.NewCommand().Exec("screenshot-glb", "-i", inputPath, "-o", outputPath, "--width", fmt.Sprintf("%d", width), "--height", fmt.Sprintf("%d", height), "--color", color); err != nil {
return err
}
return nil
}

0 comments on commit a438f46

Please sign in to comment.