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

Please provide a docker image #30

Open
tacone opened this issue Apr 10, 2021 · 6 comments
Open

Please provide a docker image #30

tacone opened this issue Apr 10, 2021 · 6 comments
Labels
enhancement New feature or request

Comments

@tacone
Copy link

tacone commented Apr 10, 2021

Providing a Docker image on Docker Hub may allow users to grab the latest binaries via a multistage build without the need to hit your website every time they build.

@fatheyabdelslam
Copy link

i can't install it on docker !!

@wilsonzlin
Copy link
Owner

Adding another build variation is probably too much (especially an entire Docker image for a tiny self-contained tool), and I think this can trivially be done manually anyway, by either copying the binary into the image or building from source if desired.

@polarathene
Copy link

Adding another build variation is probably too much (especially an entire Docker image for a tiny self-contained tool)

It would actually provide a CLI equivalent option that is supported across platforms, instead of requiring to pull a platform specific binary from releases, everyone could use the same Docker image. That's useful for users.

It's also useful for you, as you can ensure you release the CLI tool with a much more reliable way to reproduce a testing environment, and run your tests against that in the CI.

The current x86_64 linux binary 0.9.2 outputs nothing when I tried it 0.9.2-linux-x86_64 index.html. While building from source works. I don't know why that is, but if you produce static builds for linux with musl you'll also have a more portable binary on linux. This issue has happened before for the project on a different platform.

Perhaps it's due to the CI building from Ubuntu 18.04?:

os: [macos-11.0, ubuntu-18.04, windows-2019, self-hosted-linux-arm64, self-hosted-macos-arm64]


I think this can trivially be done manually anyway, by either copying the binary into the image or building from source if desired.

Building from source isn't immediately obvious for others. I'm used to building a rust project, but was a bit confused about needing to run a script that uses NodeJS to prepare that build, especially since this project has multiple other build variants unrelated to the CLI including a NodeJS package.

When the binary isn't working like in my experience, copying it into the Docker image isn't going to be very helpful. It's far better when your project automates the build for releases with a Dockerfile, where you're able to publish an official release on DockerHub that is trusted, and tested by your own CI.

You could then take the binary built from the image to distribute directly for Linux if you like.

@wilsonzlin
Copy link
Owner

wilsonzlin commented Aug 6, 2022

Thanks @polarathene, those are good points raised. I'll reopen this issue for tracking the Docker image.

I've had issues in the past with cross-platform compatibility due to glibc (#12 #25 #78 #79 #88), but was required to target it due to bundling with esbuild-rs which includes the Cgo runtime and requires glibc. Now that I've replaced it with a Rust-based JS minifier I wrote from scratch, it should be possible to target musl and create fully static CLI binaries.

Note that the issue mentioned (#6) was due to a bug in the parser itself, not the underlying libc and platform issues.

@wilsonzlin wilsonzlin reopened this Aug 6, 2022
@wilsonzlin wilsonzlin added the enhancement New feature or request label Jan 5, 2023
@hoijui
Copy link

hoijui commented Jan 25, 2024

I wanted to add, that a docker image is also useful for running the tool on CI, which could make sense for anyone that uses static site generators on e.g. GH Pages, as a post-processing step, and .. that is a huge potential clientele!

@MaartenUreel
Copy link

I wanted to add, that a docker image is also useful for running the tool on CI, which could make sense for anyone that uses static site generators on e.g. GH Pages, as a post-processing step, and .. that is a huge potential clientele!

Not only for static sites. In our Django websites, we minify the HTML during the build step. So our templates are full of comments and other useful stuff, but when deploying, we use html-minifier to reduce the size of all templates and especially remove all our internal comments.

for HTML_FILE in `find -type f -name "*.html" -not -path "./node_modules/*"`
do
    npx html-minifier --collapse-whitespace --remove-comments --remove-tag-whitespace --minify-css --minify-js --ignore-custom-fragments '[/{{[\s\S]*?}}/, /{%[\s\S]*?%}/]'  -o "${HTML_FILE}" "$HTML_FILE"
done

Furthermore we also validate this step with a pre-commit stage:

  - repo: local
    hooks:
      - id: html-minifier
        name: validate HTML minification
        language: node
        additional_dependencies:
          - html-minifier@latest
        entry: html-minifier
        types: [html]

All this was very easy to set up because the CLI is available with a simple npm install.

For now we decided to stick to html-minifier for that...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

6 participants