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

CI/CD and Dockerfile updates #278

Closed
wants to merge 4 commits into from
Closed

CI/CD and Dockerfile updates #278

wants to merge 4 commits into from

Conversation

n8225
Copy link
Contributor

@n8225 n8225 commented Oct 4, 2020

  • Dockerfile changes

    • Added .dockerignore so unneded files aren't copied over
    • Smaller docker image using scratch image
    • Binaries are statically linked and build with cgo so that they can run on a scratch image.
    • docker image does run as root (could be a security issue) this could be easily changed but may also be harder to setup for some
  • Releases

    • When a tag is created github actions will create a release and upload binaries.
    • Binaries for linux and windows are statically linked and built with cgo, so they should have no dependencies.
    • Built with -extldflags -s -w flags for a smaller binary this strips dwarf tables used in debuggers and doesn't affect stack traces.
      • Release Targets:
        • linux-amd64 (tested)
        • linux-arm64 (untested)
        • linux-armv7 (untested)
        • win-amd64 (tested)
        • darwin-amd64 (untested)
    • Docker files will be created and uploaded to docker hub.
    • Tagged latest and with tag
      • linux-amd64 (tested)
      • linux-arm64 (untested)
      • linux-armv7 (untested)
  • Continous Integration

    • uses v1.x for latest version of golang
    • added go vet in linting stage
    • go build is run for all release targets as well(maintainers will have access to build artifacts).
    • added docker build and upload to docker hub for push to master, images tagged with commit sha1.
  • A go-shiori account will need to be made on docker hub

  • A personal access token will need to be created on docker hub

  • The following gihub actions secrets will need to be set in github

    • DOCKER_HUB_USERNAME
    • DOCKER_HUB_ACCESS_TOKEN

-Examples:
https://github.com/n8225/shiori/actions
https://github.com/n8225/shiori/releases
https://hub.docker.com/r/nrew225/shiori

Related Issues: #263 #260

Closes #254 #267 #238 #273

@hacdias
Copy link

hacdias commented Oct 4, 2020

Yes ^^!

@deanishe
Copy link
Contributor

deanishe commented Oct 7, 2020

Thanks for this. Looks fantastic. I've been trying to figure out how to publish releases via GH Actions because I don't have a Windows box to build on, and CGO makes cross-compiling a no-go.

docker image does run as root (could be a security issue) this could be easily changed but may also be harder to setup for some

I'm not sure exactly how this Docker image works. "Scratch image" means there's no OS, right? As I understand it, the proper way to use Docker (normally) is to create a user account in the guest OS to run the application, so it isn't running as root and therefore doesn't inherit the Docker daemon/container's root rights.

But with no OS, Shiori would be effectively running as root, and the user would have to configure their Docker daemon to run this image under another user? Which Docker doesn't do by default?

@symgryph
Copy link

symgryph commented Oct 7, 2020 via email

@n8225
Copy link
Contributor Author

n8225 commented Oct 7, 2020

Docker image is now running as a user. It is still using the scratch image. Using a scratch image removes vulnerabilities that could be in the OS or preinstalled packages.

@deanishe
Copy link
Contributor

deanishe commented Oct 9, 2020

If you look at my previous paul requests you can see an example where I actually created a user and ran as a non-root user.

Yeah, that's the solution I'm familiar with. And which is missing from so many Dockerfiles… 😭

Using a scratch image removes vulnerabilities that could be in the OS or preinstalled packages.

I'm more worried about Shiori running as root, tbh. That should be the only service that's actually accessible (and exploitable). And it just makes me twitch…

@symgryph Does this look good to you? In your PR, you were compressing the shiori binary? Does that add much?

@deanishe
Copy link
Contributor

deanishe commented Oct 9, 2020

Meh. "shiori" and "goshiori" are already taken on Docker Hub. Anyone got any good suggestions?

I've created a "deanishe" account, but I'd rather host Shiori under its own namespace.

@symgryph
Copy link

symgryph commented Oct 9, 2020 via email

@symgryph
Copy link

symgryph commented Oct 9, 2020 via email

@symgryph
Copy link

symgryph commented Oct 9, 2020 via email

@symgryph
Copy link

symgryph commented Oct 9, 2020 via email

@symgryph
Copy link

Fork docker stuff? I think we’re gonna have no choice but to Fork at least the dock or portions of this. The pull Requests never seem to be being processed. Offers to help are refused Not sure what else to do. I don’t wanna abandon shiori but I may not have any choice.

@imajes
Copy link

imajes commented Oct 21, 2020

This is great... @deanishe is this something that can move forward?

@n8225
Copy link
Contributor Author

n8225 commented Nov 3, 2020

@deanishe Docker account updated to 'deanishe' if you come up with something better I can create a new pr. For now add your docker hub access token to the github actions secret DOCKER_HUB_ACCESS_TOKEN and deanishe to DOCKER_HUB_ACCESS_TOKEN merge the PR and it should be good.

@symgryph
Copy link

is this ever going to get merged? i don’t mean to be a meanie, but there seems to be absolutely no progress.

@imajes
Copy link

imajes commented Nov 18, 2020

@symgryph: I have a fork i'm working on validating stability -- lets see how that goes?

@symgryph
Copy link

symgryph commented Nov 18, 2020 via email

@fi0
Copy link

fi0 commented Dec 15, 2020

Is there a docker image for testing?

@symgryph
Copy link

Can you post your fork? I would like to test out your docker image.

@fmartingr
Copy link
Member

Hello @n8225, Thanks a lot for this!! I know that this was submitted years ago, but is this you're willing to keep updating? If that's the case please go to #329 to follow up on the current discussion.

If not please tell me so I can continue the work myself using your contribution as a base.

@n8225
Copy link
Contributor Author

n8225 commented Feb 6, 2022

I should be able to find some time to update this PR. I'll look into slimming it down a little as well.

@fmartingr
Copy link
Member

I should be able to find some time to update this PR. I'll look into slimming it down a little as well.

That's just wonderful! Thank you for your dedication after all this time :)

@fmartingr fmartingr force-pushed the master branch 2 times, most recently from 23e55e3 to f967212 Compare February 10, 2022 21:35
@fmartingr fmartingr force-pushed the master branch 2 times, most recently from d1ffd75 to d70a8f2 Compare February 10, 2022 21:57
@n8225 n8225 mentioned this pull request Feb 12, 2022
@fmartingr
Copy link
Member

Closed by #365

@fmartingr fmartingr closed this Feb 13, 2022
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.

Panic while trying to run cross compiled binary on Raspberry PI
7 participants