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

Interest in containerizing scalafmt? #1829

Closed
bsolomon1124 opened this issue Mar 30, 2020 · 6 comments
Closed

Interest in containerizing scalafmt? #1829

bsolomon1124 opened this issue Mar 30, 2020 · 6 comments
Labels

Comments

@bsolomon1124
Copy link
Contributor

bsolomon1124 commented Mar 30, 2020

scalafmt as a standalone CLI tool seems like a good candidate for containerization given its lack of support in package managers. (See for example: https://github.com/koalaman/shellcheck.)

Here is a working Dockerfile:

FROM openjdk:8
ARG SCALAFMT_VERSION=2.4.2
ARG SCALAFMT_INSTALL_LOCATION=/usr/local/bin/scalafmt
RUN set -ex \
    && apt-get update -y \
    && rm -rf /var/lib/apt/lists/* \
    && echo insecure > "$HOME/.curlrc" \
    && curl -Lo coursier https://git.io/coursier-cli \
    && chmod u+x coursier \
    && ./coursier bootstrap "org.scalameta:scalafmt-cli_2.12:$SCALAFMT_VERSION" \
        -r sonatype:snapshots \
        -o "$SCALAFMT_INSTALL_LOCATION" \
        --main org.scalafmt.cli.Cli \
    && rm -f coursier \
    && scalafmt --version
CMD ["/usr/local/bin/scalafmt"]

Verification:

$ docker container run --rm scalafmt-test:4 scalafmt --version
scalafmt 2.4.2

The resulting image is 573MB, which adds an incremental 60MB over openjdk:8.

@poslegm
Copy link
Collaborator

poslegm commented Mar 30, 2020

Related: #1678

Personally I don't see the need to create a Docker image for scalafmt.

But if some volunteer want to:

  1. create image
  2. publish it to public image registry
  3. integrate it into our release process
  4. and will support in the future

...

Contributions are welcome!

@poslegm poslegm added the build label Mar 30, 2020
@bsolomon1124
Copy link
Contributor Author

bsolomon1124 commented Mar 30, 2020

@poslegm would the maintainers of this project be willing to host the images under an organization page such as https://hub.docker.com/u/scalameta/? (I see that org doesn't exist on Docker Hub currently.)

@poslegm
Copy link
Collaborator

poslegm commented Mar 30, 2020

@olafurpg what about Docker Hub account for scalameta projects?

olafurpg pushed a commit to olafurpg/scalafmt that referenced this issue Mar 30, 2020
@olafurpg
Copy link
Member

I just pushed a docker container that you can run like this

❯ docker run scalameta/scalafmt:2.4.2 scalafmt --help

Does it work for you?

My biggest concern is keeping this image up-to-date with releases. The JVM binary dynamically downloads the appropriate Scalafmt version so in theory I think we don't have to push a new docker image for every release. Any thoughts?

@bsolomon1124
Copy link
Contributor Author

Looks good @olafurpg! The pull/run is working for me.

I left some suggestions on olafurpg@944cc2b for possible small improvements to image quality.

Regarding your comment,

My biggest concern is keeping this image up-to-date with releases. The JVM binary dynamically downloads the appropriate Scalafmt version so in theory I think we don't have to push a new docker image for every release. Any thoughts?

I'm afraid I won't be a ton of help on that since I don't know scalafmt all that well. Could you elaborate on how that happens? I see ./coursier bootstrap "org.scalameta:scalafmt-cli_2.12:$SCALAFMT_VERSION" which seems to imply a one-time pull of a specific version but I'm sure I am missing some steps.

bsolomon1124 added a commit to bsolomon1124/scalafmt that referenced this issue Mar 31, 2020
bsolomon1124 added a commit to bsolomon1124/scalafmt that referenced this issue Apr 16, 2020
@poslegm poslegm closed this as completed Jul 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants