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

Improve Dockerfile: update base image and optimize image size #2649

Merged
merged 2 commits into from
Jul 4, 2023

Conversation

itchyny
Copy link
Contributor

@itchyny itchyny commented Jul 3, 2023

This PR improves Dockerfile to resolve endless reports about the Docker image in the next release. I update the base image to Debian 12, and use multi-stage build to optimize the image size. We stop re-building the parser/lexer codes since that's what we do on building the release executables. We no longer re-build docs and manpage in this image, so drop dependency on Python. Releasing multi-arch image to GHCR will be in the next PR.
This PR closes #845, closes #1631, closes #1900, closes #2004, and closes #2617.

@itchyny itchyny added the docker label Jul 3, 2023
@itchyny itchyny added this to the 1.7 release milestone Jul 3, 2023
Dockerfile Outdated
RUN autoreconf -i \
&& ./configure \
--disable-dependency-tracking \
--disable-silent-rules \
Copy link
Member

Choose a reason for hiding this comment

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

Got a curious about these options, seems --disable-silent-rules is the default? if so maybe can skip specify it? --disable-dependency-tracking seems to speed up one-time builds by not generate make dependency files, i suspect not much build speed up for jq?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree. I'll drop both flags.

rm -rf /app/modules/oniguruma/.git && \
rm -rf /app/modules/oniguruma/.gitignore && \
rm -rf /var/lib/apt/lists/* /var/lib/gems
FROM scratch
Copy link
Member

Choose a reason for hiding this comment

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

In dockerfiles like this i usually have a RUN ["/path/to/binary", "--version"] just as a sanity test that the binary can run correct in a scratch container, have saved me a couple of times

Dockerfile Outdated
CMD []
COPY --from=builder /app/AUTHORS /app/COPYING /usr/local/bin/jq /
ENTRYPOINT ["/jq"]
CMD ["--help"]
Copy link
Member

@wader wader Jul 3, 2023

Choose a reason for hiding this comment

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

Maybe skip or leave empty to make it behave as normal cli?

@itchyny
Copy link
Contributor Author

itchyny commented Jul 4, 2023

Thank you!

@itchyny itchyny merged commit 2270e20 into jqlang:master Jul 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dockerfile cleanup
2 participants