Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
b315464
chore(deps): update Noto Color Emoji to Unicode 16.0
gulien Oct 5, 2024
7df786c
fix(webhook): retrieve values from echo.Context before it get recycled
gulien Oct 5, 2024
aa57b17
chore(deps): update Go dependencies
gulien Oct 6, 2024
bf205c5
fix(pdfcpu): switch to CLI
gulien Oct 6, 2024
119bba4
feat(api): add flag --api-bind-ip
gulien Oct 8, 2024
9daecc1
chore(deps): update Go dependencies
gulien Oct 8, 2024
8a9f0a2
chore(api): improve --api-body-limit flag description to include exam…
gulien Oct 8, 2024
99c328c
fix(ci): LINUX_AMD64_RELEASE is no more ignored thanks to curly braces
gulien Oct 10, 2024
8ff9d3b
feat(chromium): add scope to extraHttpHeaders
gulien Oct 11, 2024
249745f
feat(pdfengines): one flag per PDF engine method for a more granular …
gulien Oct 13, 2024
b2f957d
chore(pdfengines): update new flags with a description of the empty v…
gulien Oct 14, 2024
711b430
feat(chromium): add failOnResourceLoadingFailed and failOnResourceHtt…
gulien Nov 5, 2024
e65a5e6
chore(deps): update Go dependencies
gulien Nov 5, 2024
62ba487
chore(deps): update golangci-lint
gulien Nov 5, 2024
79f396f
feat(chromium): add GenerateDocumentOutline option
nktnet1 Nov 18, 2024
66dbdc0
chore(deps): update Go dependencies
gulien Nov 18, 2024
333ab70
chore(libreoffice): remove non-relevant comment about old gc module
gulien Nov 19, 2024
1b49b35
fix(exiftool): convert interface{} array to string array
gulien Nov 21, 2024
42ee593
chore(pdfengines): add stubs for common workflows
gulien Nov 25, 2024
c30da80
feat(pdfengines): add split feature
gulien Dec 20, 2024
51a913a
chore(deps): update Go depencies
gulien Dec 20, 2024
8bc29ad
feat(split): add splitUnify form field
gulien Dec 21, 2024
16807bd
fix(split): wrong output paths when converting to PDF/A & PDF/UA
gulien Dec 23, 2024
910eb9b
feat(state): improve clean up when LibreOffice and Chromium are resta…
gulien Dec 25, 2024
28adb50
Merge remote-tracking branch 'upstream/main' into bfichter/update-ups…
bfichter Dec 26, 2024
1f99a01
Update to support new pdfcpu stuff from upstream
bfichter Dec 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/continuous_integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Run linters
uses: golangci/golangci-lint-action@v6
with:
version: v1.60.3
version: v1.61.0

tests:
needs:
Expand Down
25 changes: 20 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ DOCKER_REPOSITORY=gotenberg
GOTENBERG_VERSION=snapshot
GOTENBERG_USER_GID=1001
GOTENBERG_USER_UID=1001
NOTO_COLOR_EMOJI_VERSION=v2.042 # See https://github.com/googlefonts/noto-emoji/releases.
NOTO_COLOR_EMOJI_VERSION=v2.047 # See https://github.com/googlefonts/noto-emoji/releases.
PDFTK_VERSION=v3.3.3 # See https://gitlab.com/pdftk-java/pdftk/-/releases - Binary package.
GOLANGCI_LINT_VERSION=v1.60.3 # See https://github.com/golangci/golangci-lint/releases.
PDFCPU_VERSION=v0.8.1 # See https://github.com/pdfcpu/pdfcpu/releases.
GOLANGCI_LINT_VERSION=v1.61.0 # See https://github.com/golangci/golangci-lint/releases.

.PHONY: build
build: ## Build the Gotenberg's Docker image
Expand All @@ -24,12 +25,14 @@ build: ## Build the Gotenberg's Docker image
--build-arg GOTENBERG_USER_UID=$(GOTENBERG_USER_UID) \
--build-arg NOTO_COLOR_EMOJI_VERSION=$(NOTO_COLOR_EMOJI_VERSION) \
--build-arg PDFTK_VERSION=$(PDFTK_VERSION) \
--build-arg PDFCPU_VERSION=$(PDFCPU_VERSION) \
-t $(DOCKER_REGISTRY)/$(DOCKER_REPOSITORY):$(GOTENBERG_VERSION) \
-f build/Dockerfile .

GOTENBERG_GRACEFUL_SHUTDOWN_DURATION=30s
API_PORT=3000
API_PORT_FROM_ENV=
API_BIND_IP=
API_START_TIMEOUT=30s
API_TIMEOUT=30s
API_BODY_LIMIT=
Expand Down Expand Up @@ -69,6 +72,11 @@ LOG_LEVEL=info
LOG_FORMAT=auto
LOG_FIELDS_PREFIX=
PDFENGINES_ENGINES=
PDFENGINES_MERGE_ENGINES=qpdf,pdfcpu,pdftk
PDFENGINES_SPLIT_ENGINES=pdfcpu,qpdf,pdftk
PDFENGINES_CONVERT_ENGINES=libreoffice-pdfengine
PDFENGINES_READ_METADATA_ENGINES=exiftool
PDFENGINES_WRITE_METADATA_ENGINES=exiftool
PDFENGINES_DISABLE_ROUTES=false
PROMETHEUS_NAMESPACE=gotenberg
PROMETHEUS_COLLECT_INTERVAL=1s
Expand All @@ -95,16 +103,17 @@ run: ## Start a Gotenberg container
--gotenberg-graceful-shutdown-duration=$(GOTENBERG_GRACEFUL_SHUTDOWN_DURATION) \
--api-port=$(API_PORT) \
--api-port-from-env=$(API_PORT_FROM_ENV) \
--api-bind-ip=$(API_BIND_IP) \
--api-start-timeout=$(API_START_TIMEOUT) \
--api-timeout=$(API_TIMEOUT) \
--api-body-limit="$(API_BODY_LIMIT)" \
--api-root-path=$(API_ROOT_PATH) \
--api-trace-header=$(API_TRACE_HEADER) \
--api-enable-basic-auth=$(API_ENABLE_BASIC_AUTH) \
--api-download-from-allow-list=$(API-DOWNLOAD-FROM-ALLOW-LIST) \
--api-download-from-deny-list=$(API-DOWNLOAD-FROM-DENY-LIST) \
--api-download-from-max-retry=$(API-DOWNLOAD-FROM-FROM-MAX-RETRY) \
--api-disable-download-from=$(API-DISABLE-DOWNLOAD-FROM) \
--api-download-from-deny-list=$(API-DOWNLOAD-FROM-DENY-LIST) \
--api-download-from-max-retry=$(API-DOWNLOAD-FROM-FROM-MAX-RETRY) \
--api-disable-download-from=$(API-DISABLE-DOWNLOAD-FROM) \
--api-disable-health-check-logging=$(API_DISABLE_HEALTH_CHECK_LOGGING) \
--chromium-restart-after=$(CHROMIUM_RESTART_AFTER) \
--chromium-auto-start=$(CHROMIUM_AUTO_START) \
Expand Down Expand Up @@ -132,6 +141,11 @@ run: ## Start a Gotenberg container
--log-format=$(LOG_FORMAT) \
--log-fields-prefix=$(LOG_FIELDS_PREFIX) \
--pdfengines-engines=$(PDFENGINES_ENGINES) \
--pdfengines-merge-engines=$(PDFENGINES_MERGE_ENGINES) \
--pdfengines-split-engines=$(PDFENGINES_SPLIT_ENGINES) \
--pdfengines-convert-engines=$(PDFENGINES_CONVERT_ENGINES) \
--pdfengines-read-metadata-engines=$(PDFENGINES_READ_METADATA_ENGINES) \
--pdfengines-write-metadata-engines=$(PDFENGINES_WRITE_METADATA_ENGINES) \
--pdfengines-disable-routes=$(PDFENGINES_DISABLE_ROUTES) \
--prometheus-namespace=$(PROMETHEUS_NAMESPACE) \
--prometheus-collect-interval=$(PROMETHEUS_COLLECT_INTERVAL) \
Expand Down Expand Up @@ -197,6 +211,7 @@ release: ## Build the Gotenberg's Docker image and push it to a Docker repositor
$(GOTENBERG_USER_UID) \
$(NOTO_COLOR_EMOJI_VERSION) \
$(PDFTK_VERSION) \
$(PDFCPU_VERSION) \
$(DOCKER_REGISTRY) \
$(DOCKER_REPOSITORY) \
$(LINUX_AMD64_RELEASE)
Expand Down
35 changes: 32 additions & 3 deletions build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,35 @@
# stage that uses them.
ARG GOLANG_VERSION

# ----------------------------------------------
# pdfcpu binary build stage
# ----------------------------------------------
# Note: this stage is required as pdfcpu does not release an armhf variant by
# default.

FROM golang:$GOLANG_VERSION AS pdfcpu-binary-stage

ARG PDFCPU_VERSION
ENV CGO_ENABLED=0

# Define the working directory outside of $GOPATH (we're using go modules).
WORKDIR /home

RUN curl -Ls "https://github.com/pdfcpu/pdfcpu/archive/refs/tags/$PDFCPU_VERSION.tar.gz" -o pdfcpu.tar.gz &&\
tar --strip-components=1 -xvzf pdfcpu.tar.gz

# Install module dependencies.
RUN go mod download &&\
go mod verify

RUN go build -o pdfcpu -ldflags "-s -w -X 'main.version=$PDFCPU_VERSION' -X 'github.com/pdfcpu/pdfcpu/pkg/pdfcpu.VersionStr=$PDFCPU_VERSION' -X main.builtBy=gotenberg" ./cmd/pdfcpu &&\
# Verify installation.
./pdfcpu version

# ----------------------------------------------
# Gotenberg binary build stage
# ----------------------------------------------
FROM golang:$GOLANG_VERSION AS binary-stage
FROM golang:$GOLANG_VERSION AS gotenberg-binary-stage

ARG GOTENBERG_VERSION
ENV CGO_ENABLED=0
Expand Down Expand Up @@ -187,8 +212,11 @@ RUN \
# https://github.com/arachnys/athenapdf/commit/ba25a8d80a25d08d58865519c4cd8756dc9a336d.
COPY build/fonts.conf /etc/fonts/conf.d/100-gotenberg.conf

# Copy the Gotenberg binary from the binary stage.
COPY --from=binary-stage /home/gotenberg /usr/bin/
# Copy the pdfcpu binary from the pdfcpu-binary-stage.
COPY --from=pdfcpu-binary-stage /home/pdfcpu /usr/bin/

# Copy the Gotenberg binary from the gotenberg-binary-stage.
COPY --from=gotenberg-binary-stage /home/gotenberg /usr/bin/

# Environment variables required by modules or else.
ENV CHROMIUM_BIN_PATH=/usr/bin/chromium
Expand All @@ -197,6 +225,7 @@ ENV UNOCONVERTER_BIN_PATH=/usr/bin/unoconverter
ENV PDFTK_BIN_PATH=/usr/bin/pdftk
ENV QPDF_BIN_PATH=/usr/bin/qpdf
ENV EXIFTOOL_BIN_PATH=/usr/bin/exiftool
ENV PDFCPU_BIN_PATH=/usr/bin/pdfcpu

USER gotenberg
WORKDIR /home/gotenberg
Expand Down
65 changes: 47 additions & 18 deletions build/Dockerfile.distroless
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,35 @@ ARG GOOGLE_DISTROLESS_BASE_IMAGE=gcr.io/distroless/cc-debian12:latest
# stage that uses them.
ARG GOLANG_VERSION

# ----------------------------------------------
# pdfcpu binary build stage
# ----------------------------------------------
# Note: this stage is required as pdfcpu does not release an armhf variant by
# default.

FROM golang:$GOLANG_VERSION AS pdfcpu-binary-stage

ARG PDFCPU_VERSION
ENV CGO_ENABLED=0

# Define the working directory outside of $GOPATH (we're using go modules).
WORKDIR /home

RUN curl -Ls "https://github.com/pdfcpu/pdfcpu/archive/refs/tags/$PDFCPU_VERSION.tar.gz" -o pdfcpu.tar.gz &&\
tar --strip-components=1 -xvzf pdfcpu.tar.gz

# Install module dependencies.
RUN go mod download &&\
go mod verify

RUN go build -o pdfcpu -ldflags "-s -w -X 'main.version=$PDFCPU_VERSION' -X 'github.com/pdfcpu/pdfcpu/pkg/pdfcpu.VersionStr=$PDFCPU_VERSION' -X main.builtBy=gotenberg" ./cmd/pdfcpu &&\
# Verify installation.
./pdfcpu version

# ----------------------------------------------
# Gotenberg binary build stage
# ----------------------------------------------
FROM golang:$GOLANG_VERSION AS binary-stage
FROM golang:$GOLANG_VERSION AS gotenberg-binary-stage

ARG GOTENBERG_VERSION
ENV CGO_ENABLED=0
Expand Down Expand Up @@ -174,45 +199,49 @@ ARG TARGETARCH
FROM base-${TARGETARCH}

# Required for unoconverter
COPY --from=binary-stage /usr/bin/python /usr/bin/python
COPY --from=binary-stage /usr/lib/python3 /usr/lib/python3
COPY --from=binary-stage /usr/lib/python3.11 /usr/lib/python3.11
COPY --from=gotenberg-binary-stage /usr/bin/python /usr/bin/python
COPY --from=gotenberg-binary-stage /usr/lib/python3 /usr/lib/python3
COPY --from=gotenberg-binary-stage /usr/lib/python3.11 /usr/lib/python3.11

ENV PYTHONPATH="/usr/local/lib/python3.11/dist-packages:"

# LibreOffice dependencies
# Just copied the entire directory as there were too many dependencies to justify finding/listing them individually
COPY --from=binary-stage /lib/${CHIPSET_ARCH} /lib/${CHIPSET_ARCH}
COPY --from=gotenberg-binary-stage /lib/${CHIPSET_ARCH} /lib/${CHIPSET_ARCH}

# Copy the pdfcpu binary from the pdfcpu-binary-stage.
COPY --from=pdfcpu-binary-stage /home/pdfcpu /usr/bin/

# Copy the Gotenberg binary from the binary stage
COPY --from=binary-stage /home/gotenberg /usr/bin/gotenberg
COPY --from=gotenberg-binary-stage /home/gotenberg /usr/bin/gotenberg

# Copy other neccessary binaries/libraries
COPY --from=binary-stage /usr/lib/libreoffice /usr/lib/libreoffice
COPY --from=binary-stage /etc/libreoffice /etc/libreoffice
COPY --from=binary-stage /etc/apparmor.d /etc/apparmor.d
COPY --from=binary-stage /usr/bin/libreoffice /usr/bin/unoconverter /usr/bin/pdftk /usr/bin/qpdf /usr/bin/exiftool /usr/bin/tini /usr/bin/
COPY --from=gotenberg-binary-stage /usr/lib/libreoffice /usr/lib/libreoffice
COPY --from=gotenberg-binary-stage /etc/libreoffice /etc/libreoffice
COPY --from=gotenberg-binary-stage /etc/apparmor.d /etc/apparmor.d
COPY --from=gotenberg-binary-stage /usr/bin/libreoffice /usr/bin/unoconverter /usr/bin/pdftk /usr/bin/qpdf /usr/bin/exiftool /usr/bin/tini /usr/bin/

# Fonts
COPY --from=binary-stage /usr/share/doc /usr/share/doc
COPY --from=binary-stage /usr/share/bug /usr/share/bug
COPY --from=binary-stage /usr/share/fonts /usr/share/fonts
COPY --from=binary-stage /usr/share/fontconfig /usr/share/fontconfig
COPY --from=binary-stage /usr/local/share/fonts /usr/local/share/fonts
COPY --from=binary-stage /etc/fonts /etc/fonts
COPY --from=gotenberg-binary-stage /usr/share/doc /usr/share/doc
COPY --from=gotenberg-binary-stage /usr/share/bug /usr/share/bug
COPY --from=gotenberg-binary-stage /usr/share/fonts /usr/share/fonts
COPY --from=gotenberg-binary-stage /usr/share/fontconfig /usr/share/fontconfig
COPY --from=gotenberg-binary-stage /usr/local/share/fonts /usr/local/share/fonts
COPY --from=gotenberg-binary-stage /etc/fonts /etc/fonts

# Other binaries (used in /usr/bin/libreoffice script)
COPY --from=binary-stage /usr/bin/dirname /usr/bin/uname /usr/bin/basename /usr/bin/grep /usr/bin/sed /usr/bin/
COPY --from=gotenberg-binary-stage /usr/bin/dirname /usr/bin/uname /usr/bin/basename /usr/bin/grep /usr/bin/sed /usr/bin/

# Required to allow unoconverter to be called without 'python' prefix
COPY --from=binary-stage /usr/bin/env /usr/bin/
COPY --from=gotenberg-binary-stage /usr/bin/env /usr/bin/

# Environment variables required by modules or else.
ENV LIBREOFFICE_BIN_PATH=/usr/lib/libreoffice/program/soffice.bin
ENV UNOCONVERTER_BIN_PATH=/usr/bin/unoconverter
ENV PDFTK_BIN_PATH=/usr/bin/pdftk
ENV QPDF_BIN_PATH=/usr/bin/qpdf
ENV EXIFTOOL_BIN_PATH=/usr/bin/exiftool
ENV PDFCPU_BIN_PATH=/usr/bin/pdfcpu

ARG GOTENBERG_USER_UID

Expand Down
57 changes: 29 additions & 28 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,68 +4,69 @@ go 1.23.0

require (
github.com/alexliesenfeld/health v0.8.0
github.com/andybalholm/brotli v1.1.0 // indirect
github.com/andybalholm/brotli v1.1.1 // indirect
github.com/barasher/go-exiftool v1.10.0
github.com/chromedp/cdproto v0.0.0-20240919203636-12af5e8a671f
github.com/chromedp/chromedp v0.10.0
github.com/chromedp/cdproto v0.0.0-20241222144035-c16d098c0fb6
github.com/chromedp/chromedp v0.11.2
github.com/golang/snappy v0.0.4 // indirect
github.com/google/uuid v1.6.0
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-retryablehttp v0.7.7
github.com/klauspost/compress v1.17.10 // indirect
github.com/klauspost/compress v1.17.11 // indirect
github.com/klauspost/pgzip v1.2.6 // indirect
github.com/labstack/echo/v4 v4.12.0
github.com/labstack/echo/v4 v4.13.3
github.com/labstack/gommon v0.4.2
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mholt/archiver/v3 v3.5.1
github.com/microcosm-cc/bluemonday v1.0.27
github.com/nwaples/rardecode v1.1.3 // indirect
github.com/pdfcpu/pdfcpu v0.8.1
github.com/pierrec/lz4/v4 v4.1.21 // indirect
github.com/prometheus/client_golang v1.20.4
github.com/pierrec/lz4/v4 v4.1.22 // indirect
github.com/prometheus/client_golang v1.20.5
github.com/russross/blackfriday/v2 v2.1.0
github.com/spf13/pflag v1.0.5
github.com/ulikunitz/xz v0.5.12 // indirect
go.uber.org/multierr v1.11.0
go.uber.org/zap v1.27.0
golang.org/x/crypto v0.27.0 // indirect
golang.org/x/image v0.20.0 // indirect
golang.org/x/net v0.29.0
golang.org/x/sync v0.8.0
golang.org/x/sys v0.25.0 // indirect
golang.org/x/term v0.24.0
golang.org/x/text v0.18.0
golang.org/x/crypto v0.31.0 // indirect
golang.org/x/net v0.33.0
golang.org/x/sync v0.10.0
golang.org/x/sys v0.28.0 // indirect
golang.org/x/term v0.27.0
golang.org/x/text v0.21.0
)

require github.com/dlclark/regexp2 v1.11.4
require (
github.com/dlclark/regexp2 v1.11.4
github.com/shirou/gopsutil/v4 v4.24.11
)

require (
github.com/aymerick/douceur v0.2.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/chromedp/sysutil v1.0.0 // indirect
github.com/chromedp/sysutil v1.1.0 // indirect
github.com/dsnet/compress v0.0.2-0.20210315054119-f66993602bf5 // indirect
github.com/ebitengine/purego v0.8.1 // indirect
github.com/go-ole/go-ole v1.3.0 // indirect
github.com/gobwas/httphead v0.1.0 // indirect
github.com/gobwas/pool v0.2.1 // indirect
github.com/gobwas/ws v1.4.0 // indirect
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
github.com/gorilla/css v1.0.1 // indirect
github.com/hhrutter/lzw v1.0.0 // indirect
github.com/hhrutter/tiff v1.0.1 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/lufia/plan9stats v0.0.0-20240909124753-873cd0166683 // indirect
github.com/mailru/easyjson v0.9.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-runewidth v0.0.16 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.59.1 // indirect
github.com/prometheus/common v0.61.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/tklauser/go-sysconf v0.3.14 // indirect
github.com/tklauser/numcpus v0.9.0 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasttemplate v1.2.2 // indirect
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
golang.org/x/time v0.6.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
github.com/yusufpapurcu/wmi v1.2.4 // indirect
golang.org/x/time v0.8.0 // indirect
google.golang.org/protobuf v1.36.1 // indirect
)
Loading
Loading