-
Notifications
You must be signed in to change notification settings - Fork 21
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
Build castor apps as a single binary #257
Comments
I already test it, but I was disappointed by the size of the binary. Can't wait what you will be able to do 🤩 |
Interesting, that's what I was most scared of yeah. What was the final size ? Compressed ? If you have a solution branch that could help me to kickstart working on this issue, feel free to share. Thanks in advance! 🙂 |
It was a POC, and I trashed everything. Sorry. I remember something about 100Mb. 😬 But I'm pretty sure we can do much better nowadays! |
To track my progression, in an hour, I was able to produce a succesfully running single binary of # Download SPC binary to manage binary build
curl -o spc https://dl.static-php.dev/static-php-cli/spc-bin/nightly/spc-linux-x86_64 && chmod +x ./spc
# Download castor.phar
curl -L -o castor.linux-amd64.phar https://github.com/jolicode/castor/releases/download/v0.11.1/castor.linux-amd64.phar
# Download PHP build dependencies required by Castor
./spc download --for-extensions=openssl,pcntl,mbstring,curl,phar,posix,tokenizer
# Build PHP micro version
./spc build openssl,pcntl,mbstring,curl,phar,posix,tokenizer --build-micro
# Merge built PHP and Castor into a single binary
cat buildroot/bin/micro.sfx castor.linux-amd64.phar > castor-app && chmod a+x castor-app
# Run Castor as a single binary
./castor-app
If you put a So, the main problem we're dealing with now is figuring out how to pack |
This is awesome ❤️
I'm not sure we want to do that. BUT if you really want, I invite you to read this doc |
I've succeded repacking my whole Castor app into a single binary thanks to the It's still around 16M and now make our scripts more portable and much easier to distribute, from local workstations to servers. I think this is a huge win over the current task runner alternatives. In which form would you like to see the single binary feature introduced ?
|
First, thanks a lot for digging this project! And congrats for achieving it! this is really appreciated. 💛
Well, I haven't strong opinion on this. I don't really know the main usages of castor. In our company, we all have PHP installed everywhere. So this feature will not really solve any issue. BUT maybe if castor was shipped as a standalone binary, it may change our usages and maybe simplify things... I don't know wet.
I think it could be nice, but we should not replace the current versions. (size matter)
May be, but It would be useless if we do the next point.
I think it's the most important one. First it'll be needed for archiving the first point. And is will also fix the second point. We don't need instructions if something do it for us :) So IMHO, we could go first with the last point, merge it, play a bit with it, and then adapt our plan. WDYT? |
Sounds good 👍 I'll proceed with the native castor task then.
Thanks to you guys! You've turned a tool I envisioned for a long time into reality so I'm eager to contribute to its success. 🙂 |
Before you work on it, Can I suggest to add a flag |
I was thinking it's a good and pragmatic way to implement it but then I realized compiling as a binary will require a good amount of dedicated options like the target PHP version, the compilation source (php micro vs php cli) or the required PHP extensions. I'm afraid it could bloat the Having a dedicated command might help avoiding that and keep a clean separation of concerns. Anyway, I'll prefix the description of those options with "Only in --static mode, ..." in a first iteration and see how it feels DX wise. |
I didn't think about all theses option! Let's go for another command then. Thanks |
I enjoy the simplicity of Castor for scripting and automation, yet I'd prefer to avoid the need to install PHP everywhere. I'm curious about the possibility of making my custom Castor apps more portable by turning them into a single binary file. That would be awesome.
There's been some recent advancement in PHP that supports this idea, especially seen in https://github.com/crazywhalecc/static-php-cli. This method is already effective in several projects:
Considering this, I'm thinking of developing a native Castor feature to combine Castor, PHP, and user-defined tasks into one binary.
I'm planning to tackle this project myself, but I wanted to share the concept here for any feedback or if anyone find the idea interesting enough to collaborate on this.
The text was updated successfully, but these errors were encountered: