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

feat: initial docker support #42

Merged
merged 8 commits into from
Aug 24, 2024
Merged

Conversation

Erb3
Copy link
Contributor

@Erb3 Erb3 commented Aug 20, 2024

Adds support for docker

  • Compile in docker
  • Load favicon
  • Document usage
  • Fix log spam
  • Make SIGTERM work
  • Alpine

I've decided that GitHub actions can be done later. Since we aren't making releases yet, it's hard to publish docker images.

@Snowiiii
Copy link
Owner

We want to give people the option to choose their own icons. So compiling with Pumpkin's icon data is not an option

@Erb3
Copy link
Contributor Author

Erb3 commented Aug 20, 2024

Well in that case we can't have a default icon. I am not suggesting to hardcode it, but we can't both have a default loaded dynamically from fs, and be able to compile to a standalone binary. We could do it, and force you to mount an icon through docker, but that's stupid. That also won't work with the Cargo.toml env var

@Snowiiii
Copy link
Owner

So im not very fimiliar with docker, Why it isn't possible or so easy to just use the icon file directly?

@Erb3
Copy link
Contributor Author

Erb3 commented Aug 21, 2024

It's not a docker limitation, we totally could include the icon, but:

  1. You can't just give the binary to someone, and say "run this". It will panic due to the missing icon. This is unrelated to Docker.
  2. It uses CARGO_MANIFEST_DIR to find the icon, which is injected by cargo.

Again, neither of these are limitations of Docker. I could set the CARGO_MANIFEST_DIR myself, but it feels jank. I also think that being able to run Pumpkin as a standalone binary would be a benefit. It would be like you running java -jar paper.jar, but it crashes because you didn't include a default icon.

I would suggest either including the icon.png in the binary, whilst still letting users set their own.

@Snowiiii
Copy link
Owner

Your right, I made the icon optional so you can start the server with only the executable
b370391

@Erb3
Copy link
Contributor Author

Erb3 commented Aug 21, 2024

It now loads successfully, however now the console is being spammed by the following log:

2024-08-21T15:56:27.941Z INFO  [pumpkin::commands] Text { text: "Empty Command" }

@Snowiiii
Copy link
Owner

It now loads successfully, however now the console is being spammed by the following log:

2024-08-21T15:56:27.941Z INFO  [pumpkin::commands] Text { text: "Empty Command" }

Does it spamm?. Or only says when sending something in the terminal?

@Erb3
Copy link
Contributor Author

Erb3 commented Aug 21, 2024

It now loads successfully, however now the console is being spammed by the following log:

2024-08-21T15:56:27.941Z INFO  [pumpkin::commands] Text { text: "Empty Command" }

Does it spamm?. Or only says when sending something in the terminal?

Spam, many each ms

@Snowiiii
Copy link
Owner

Snowiiii commented Aug 21, 2024

It now loads successfully, however now the console is being spammed by the following log:

2024-08-21T15:56:27.941Z INFO  [pumpkin::commands] Text { text: "Empty Command" }

Does it spamm?. Or only says when sending something in the terminal?

Spam, many each ms

Can you may apply this patch and test ?

@Snowiiii
Copy link
Owner

It now loads successfully, however now the console is being spammed by the following log:

2024-08-21T15:56:27.941Z INFO  [pumpkin::commands] Text { text: "Empty Command" }

Does it spamm?. Or only says when sending something in the terminal?

Spam, many each ms

Can you may apply this patch and test ?

test.patch

@Erb3
Copy link
Contributor Author

Erb3 commented Aug 21, 2024

Your .patch file didn't work, perhaps CRLF/LF? Well I manually did the change and it worked :)

@Snowiiii
Copy link
Owner

Great, So whats needs to be fixed next?

@Erb3
Copy link
Contributor Author

Erb3 commented Aug 21, 2024

Great, So whats needs to be fixed next?

The biggest problem now is termination not working, for some reason. This leads to the docker container being slow to stop (10s timeout)

@Erb3
Copy link
Contributor Author

Erb3 commented Aug 22, 2024

It suspect this is caused by running pumpkin with PID 1, which can't terminate like normal. You have to install a special CTRL+C handler, similar to what is used for graceful shutdown. See https://robertying.com/post/sigterm-docker/

@Snowiiii
Copy link
Owner

@Erb3 Can you may test with latest commit ?

fa1ca07

@Erb3
Copy link
Contributor Author

Erb3 commented Aug 24, 2024

@Erb3 Can you may test with latest commit ?

fa1ca07

Works like a charm!

@Snowiiii
Copy link
Owner

Okay, Whats next ?

@Erb3
Copy link
Contributor Author

Erb3 commented Aug 24, 2024

I've decided to post-pone GitHub actions to publish, since we aren't making releases. I'll try to get it working on alpine, since it has a smaller footprint. If that doesn't work, we're ready to merge :)

@Erb3 Erb3 marked this pull request as ready for review August 24, 2024 11:19
@Snowiiii
Copy link
Owner

Looks good. I just wonder if it makes sense to may use RUSTFLAGS="-C target-cpu=native" ?

@Snowiiii
Copy link
Owner

Thank you @Erb3

@Snowiiii Snowiiii merged commit ae028da into Snowiiii:master Aug 24, 2024
5 checks passed
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.

2 participants