Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding pdfcpu as go dependency increases container size in 600mb #460

Closed
glserranv opened this issue Apr 27, 2022 · 6 comments
Closed

adding pdfcpu as go dependency increases container size in 600mb #460

glserranv opened this issue Apr 27, 2022 · 6 comments
Assignees

Comments

@glserranv
Copy link

glserranv commented Apr 27, 2022

Adding pdfcpu as a dependency increases 600MB to container size. Is this exepected/known?

@hhrutter
Copy link
Collaborator

hhrutter commented Apr 27, 2022

Hello!

I don't have a good explanation for this but
if you add pdfcpu as a dependency in your Go app this may be the case.
This may be related to pdfcpu's dependency - see go.mod

@hhrutter
Copy link
Collaborator

Can you investigate further?
Also is your container size increasing by or to 600MB?

@J-Rocke
Copy link

J-Rocke commented Mar 13, 2023

I can build docker container with less than 70MB including pdfcpu as a go library and many more libs. I only include the binary and not the source code in the container which is a common best practice. I don't think this is a issue with pdfcpu but with the way the container is build.

@hhrutter
Copy link
Collaborator

👍 good news!

Is your docker file any different from the one in the repo, if not would you mind sharing yours?

# Dockerfile References: https://docs.docker.com/engine/reference/builder/

# Start from the latest golang base image
FROM golang:latest as builder

# install
RUN go install github.com/pdfcpu/pdfcpu/cmd/pdfcpu@latest

######## Start a new stage from scratch #######

FROM alpine:latest

RUN apk --no-cache add ca-certificates

WORKDIR /root/

# Copy the Pre-built binary file from the previous stage
COPY --from=builder /go/bin .

# Command to run the executable
CMD ["./pdfcpu"]

@J-Rocke
Copy link

J-Rocke commented Mar 13, 2023

@hhrutter I have a very similar Dockerfile but in our usecase pdfcpu is called directly from the go code. Since there is no evidence that pdfcpu greatly inflates binary size / container size this issue is missleading in my opinion and should maybe be closed. If you want to investigate more you can of course keep it open.

@hhrutter
Copy link
Collaborator

sounds good to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants