[GH-ISSUE #72] Provide minimal docker image and binaries, possibly split docs to its own package. #60

Closed
opened 2026-05-07 00:19:21 +02:00 by BreizhHardware · 12 comments

Originally created by @jauderho on GitHub (Dec 29, 2021).
Original GitHub issue: https://github.com/binwiederhier/ntfy/issues/72

I was trying to compile my own container image using the following build command:

go build -o ntfy -v -trimpath -ldflags="-s -w -X main.version=v1.10.0" .

This failed with the error message of server/server.go:116:13: pattern docs: no matching files found which appears to be a go:embed directive for docs. Removing this line allows for the compilation to successfully complete.

Here's the line in question: github.com/binwiederhier/ntfy@9752bd7c30/server/server.go (L116)

Originally created by @jauderho on GitHub (Dec 29, 2021). Original GitHub issue: https://github.com/binwiederhier/ntfy/issues/72 I was trying to compile my own container image using the following build command: `go build -o ntfy -v -trimpath -ldflags="-s -w -X main.version=v1.10.0" .` This failed with the error message of `server/server.go:116:13: pattern docs: no matching files found` which appears to be a go:embed directive for docs. Removing this line allows for the compilation to successfully complete. Here's the line in question: https://github.com/binwiederhier/ntfy/blob/9752bd7c30d9b5620ccb610949f732fc847a8a18/server/server.go#L116
Author
Owner

@binwiederhier commented on GitHub (Dec 29, 2021):

@jauderho Ah yes, I'm sorry I had this the other day and it drove me mad, but I forgot to fix it: make docs will fix it.
You have to install mkdocs.

<!-- gh-comment-id:1002798307 --> @binwiederhier commented on GitHub (Dec 29, 2021): @jauderho Ah yes, I'm sorry I had this the other day and it drove me mad, but I forgot to fix it: `make docs` will fix it. You have to install `mkdocs`.
Author
Owner

@binwiederhier commented on GitHub (Dec 29, 2021):

My apologies this is so hard, I should make a github action that does the full build as an example. I haven't done a clean build in a while.

<!-- gh-comment-id:1002798433 --> @binwiederhier commented on GitHub (Dec 29, 2021): My apologies this is so hard, I should make a github action that does the full build as an example. I haven't done a clean build in a while.
Author
Owner

@binwiederhier commented on GitHub (Dec 29, 2021):

$ pip list |grep mkdocs
mkdocs                     1.2.3
mkdocs-material            8.0.1
mkdocs-material-extensions 1.0.3
mkdocs-minify-plugin       0.5.0

Should be enough to do pip install -r requirements.txt

<!-- gh-comment-id:1002798794 --> @binwiederhier commented on GitHub (Dec 29, 2021): ``` $ pip list |grep mkdocs mkdocs 1.2.3 mkdocs-material 8.0.1 mkdocs-material-extensions 1.0.3 mkdocs-minify-plugin 0.5.0 ``` Should be enough to do `pip install -r requirements.txt`
Author
Owner

@jauderho commented on GitHub (Dec 29, 2021):

@binwiederhier I don't suppose there is a way to avoid having to do the mkdocs step? I'm looking to build a minimal image which is why I was going with the singular build command. Removing that line seemed to allow the build to complete.

I suppose I could use a small patch to patch that out.

<!-- gh-comment-id:1002816200 --> @jauderho commented on GitHub (Dec 29, 2021): @binwiederhier I don't suppose there is a way to avoid having to do the mkdocs step? I'm looking to build a minimal image which is why I was going with the singular build command. Removing that line seemed to allow the build to complete. I suppose I could use a small patch to patch that out.
Author
Owner

@binwiederhier commented on GitHub (Dec 29, 2021):

@jauderho I'm happy to accept PRs and adjust the build to fit your needs, but removing the go:embed line basically removes the docs entirely and will likely lead to horrible errors. You could create an empty folder server/docs/, that would probably do it.

<!-- gh-comment-id:1002817218 --> @binwiederhier commented on GitHub (Dec 29, 2021): @jauderho I'm happy to accept PRs and adjust the build to fit your needs, but removing the go:embed line basically removes the docs entirely and will likely lead to horrible errors. You could create an empty folder `server/docs/`, that would probably do it.
Author
Owner

@jauderho commented on GitHub (Dec 30, 2021):

I just tried your suggestion of creating an empty server/docs/ but still run into the same error. Any other ideas?

I suppose I could just add the necessary commands to build the docs. Brb, editing Dockerfile.

<!-- gh-comment-id:1002819104 --> @jauderho commented on GitHub (Dec 30, 2021): I just tried your suggestion of creating an empty `server/docs/` but still run into the same error. Any other ideas? I suppose I could just add the necessary commands to build the docs. Brb, editing Dockerfile.
Author
Owner

@binwiederhier commented on GitHub (Dec 30, 2021):

I just pushed this: github.com/binwiederhier/ntfy@96ad49f675

This makes make build-simple work again. I think you could do something similar with the other targets, or create a target without docs. I think make is a little limited in that sense, but my Makefile is also a little stupid to be honest.

Anyway, I gotta go to bed. It's late. I can help more tomorrow.

<!-- gh-comment-id:1002822027 --> @binwiederhier commented on GitHub (Dec 30, 2021): I just pushed this: https://github.com/binwiederhier/ntfy/commit/96ad49f675b418245886f621481228948826e231 This makes `make build-simple` work again. I think you could do something similar with the other targets, or create a target without docs. I think `make` is a little limited in that sense, but my `Makefile` is also a little stupid to be honest. Anyway, I gotta go to bed. It's late. I can help more tomorrow.
Author
Owner

@jauderho commented on GitHub (Dec 30, 2021):

Having the dummy file did the trick! I ended up building the container both with and without docs and there's about 11MB in difference in the final image.

Anyways, I now have a working image for different archs: https://hub.docker.com/repository/docker/jauderho/ntfy

Dockerfile here: https://github.com/jauderho/dockerfiles/blob/main/ntfy/Dockerfile

<!-- gh-comment-id:1002854412 --> @jauderho commented on GitHub (Dec 30, 2021): Having the dummy file did the trick! I ended up building the container both with and without docs and there's about 11MB in difference in the final image. Anyways, I now have a working image for different archs: https://hub.docker.com/repository/docker/jauderho/ntfy Dockerfile here: https://github.com/jauderho/dockerfiles/blob/main/ntfy/Dockerfile
Author
Owner

@binwiederhier commented on GitHub (Dec 30, 2021):

I could probably build a ntfy-minimal image using the GoReleaser stuff. If that's something you desire. 🤷 Not any time soon though (too much other stuff).

<!-- gh-comment-id:1003029299 --> @binwiederhier commented on GitHub (Dec 30, 2021): I could probably build a ntfy-minimal image using the GoReleaser stuff. If that's something you desire. :shrug: Not any time soon though (too much other stuff).
Author
Owner

@jauderho commented on GitHub (Dec 31, 2021):

If you are willing to have a server/docs/dummy stub in your repo, I can create a basic .goreleaser.yml that should do the right thing.

This one should work (tested): https://gist.github.com/jauderho/451d1ca80c7734c51ef47ea87672d1e1

I can submit as a pull request if needed.

<!-- gh-comment-id:1003275143 --> @jauderho commented on GitHub (Dec 31, 2021): If you are willing to have a server/docs/dummy stub in your repo, I can create a basic .goreleaser.yml that should do the right thing. This one should work (tested): https://gist.github.com/jauderho/451d1ca80c7734c51ef47ea87672d1e1 I can submit as a pull request if needed.
Author
Owner

@binwiederhier commented on GitHub (Dec 31, 2021):

Thank you for the contribution. I if you can modify the existing GoReleaser file to build two images, one normal and one minimal would be fantastic.

<!-- gh-comment-id:1003366635 --> @binwiederhier commented on GitHub (Dec 31, 2021): Thank you for the contribution. I if you can modify the existing GoReleaser file to build two images, one normal and one minimal would be fantastic.
Author
Owner

@binwiederhier commented on GitHub (Mar 18, 2022):

I've overhauled the developer documentation (see https://github.com/binwiederhier/ntfy/blob/main/docs/develop.md), but I don't think I want to provide additional minimal packages for now. I realize that 17 MB as opposed to 7 MB is not great, but I think it's fine. If you feel strongly I may change my mind though. Closing this ticket for now.

<!-- gh-comment-id:1072819056 --> @binwiederhier commented on GitHub (Mar 18, 2022): I've overhauled the developer documentation (see https://github.com/binwiederhier/ntfy/blob/main/docs/develop.md), but I don't think I want to provide additional minimal packages for now. I realize that 17 MB as opposed to 7 MB is not great, but I think it's fine. If you feel strongly I may change my mind though. Closing this ticket for now.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ntfy#60
No description provided.