frankenphp icon indicating copy to clipboard operation
frankenphp copied to clipboard

Feature request: self-upgrade command

Open vanodevium opened this issue 1 year ago • 9 comments

Let's imagine that it's more convenient for me to use frankenphp as a stand-alone binary. Therefore, it is downloaded to my working folder.

It would be super handy if there was a self-upgrade command that would:

  1. detect which operating system is used
  2. download a new binary file and replaced the old one with it

vanodevium avatar Dec 13 '23 10:12 vanodevium

Good idea. This could be implemented by porting this code to Go: https://github.com/laravel/octane/pull/764/files#diff-4c211241cfa3be7c1ba31f8fabc468b671a007ab6fc93a3ca5b379c9567a4c4cR52-R93

dunglas avatar Dec 13 '23 10:12 dunglas

@dunglas

Awesome! But I think there is already written code, like this

vanodevium avatar Dec 13 '23 10:12 vanodevium

Also these

creativeprojects/go-selfupdate mouuff/go-rocket-update

I do not insist on the use of these libraries, only as an example of ready-made code

Thanx!

vanodevium avatar Dec 13 '23 12:12 vanodevium

Cool! I wonder if Caddy uses one of these libs for its own "self update" feature (so we could reuse the same).

dunglas avatar Dec 13 '23 21:12 dunglas

@dunglas

But caddy didn't support self-upgrade. It's so sad.

proof

vanodevium avatar Dec 13 '23 21:12 vanodevium

It has an experimental upgrade command: https://github.com/caddyserver/caddy/blob/dc12bd974367b1c15e6b8f3c6b446a208ac3546f/cmd/packagesfuncs.go#L36

This looks like an ad-hoc solution using Caddy's API. I fear that we'll not be able to use it for our needs for now because we also need to embed PHP etc. (cc @mholt)

To not confuse users, maybe we could override this command in our builds?

In the future, the best option will be to allow downloading a version of Caddy embedding PHP using the official Caddy API.

dunglas avatar Dec 13 '23 21:12 dunglas

LGTM

vanodevium avatar Dec 13 '23 21:12 vanodevium

This looks like an ad-hoc solution using Caddy's API. I fear that we'll not be able to use it for our needs for now because we also need to embed PHP etc. (cc @mholt)

Hmm, yeah, it would work, except CGO_ENABLED=1... our build server does not support this, last time I checked, for a few reasons (compile time -- C is expensive to compile, and compatibility -- C doesn't cross-compile which is a very common use case of our build server).

So yeah, perhaps the best thing to do in the interim is to override the caddy upgrade command with your own. I think(?) that should be possible

mholt avatar Dec 13 '23 22:12 mholt

What about creating a separate composer package for the built binary? It'd be easy to automate with a GitHub Action.

That way the server could be upgraded using composer update.

binaryfire avatar Dec 23 '23 21:12 binaryfire