Skip to content

Add a Dockerfile for building a container image #8

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

Merged
merged 4 commits into from
Apr 11, 2022

Conversation

jihchi
Copy link
Contributor

@jihchi jihchi commented Apr 10, 2022

Inspired by #6 (comment).

Furthermore, It would be convenient to provide bore image in public registry (e.g. Docker Hub, Github Packages Registry) such that people can immediately pull and run it in cloud/container environments.

Usage

Build image

$ docker build -t bore .

Launch a container (e.g. a bore server)

$ docker run bore --port 7835:7835 server
2022-04-10T08:30:32.286590Z  INFO bore_cli::server: server listening addr=0.0.0.0:7835

Image Size

REPOSITORY      TAG       IMAGE ID       CREATED          SIZE
bore            latest    8f459317dfed   15 minutes ago   75.1MB

@jihchi jihchi marked this pull request as ready for review April 10, 2022 09:09
@praveenperera
Copy link
Contributor

@jihchi What about an alpine build for a tiny docker image?

@jihchi
Copy link
Contributor Author

jihchi commented Apr 10, 2022

@praveenperera sounds good to me but it is probably good to have a separate Dockerfile for alpine-based image? at least we'd need to compile bore with musl support?

@praveenperera
Copy link
Contributor

Sounds good I can make another PR with an alpine based Dockerimage

@ekzhang
Copy link
Owner

ekzhang commented Apr 10, 2022

Thanks for the contribution! I love how simple the cargo install --path . is. Agree with @praveenperera though that I don't see a benefit to using buster for something like this — it would work just as well with a rust:alpine tag and alpine:latest image, and probably be smaller (although 75 MB isn't bad!)?

(Actually with another application I've made, it seemed like it was possible to just copy a rust:alpine built image directly into scratch and avoid OS image files entirely. It will statically link to musl-dev if that is present. That image is <6 MB. But alpine is very small too; it doesn't really make a difference to me whether alpine or scratch is used.)

Happy to add a CI step on each tagged release to push a latest and versioned tag in a public Docker registry like docker.io/ekzhang/bore.

@jihchi
Copy link
Contributor Author

jihchi commented Apr 10, 2022

@ekzhang Alright, thanks for the reference, it is quite simple to switch to musl-based image and the size of image goes down to ~6MB.

REPOSITORY   TAG       IMAGE ID       CREATED          SIZE
bore         latest    3de2027d23f3   19 minutes ago   6.09MB

@ekzhang
Copy link
Owner

ekzhang commented Apr 11, 2022

I added /target to the .dockerignore so that it wouldn't send gigabytes of build context, and I also added a CI job that runs on releases to publish to DockerHub. Thanks for your contribution!

@ekzhang ekzhang merged commit c154a84 into ekzhang:main Apr 11, 2022
@jihchi jihchi deleted the add_Dockerfile branch April 11, 2022 05:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants