pocketbase / pocketbase

Open Source realtime backend in 1 file
https://pocketbase.io
MIT License
39.21k stars 1.81k forks source link

Use port env when present. #4557

Closed ushieru closed 6 months ago

ushieru commented 6 months ago

Use port env by default when present.

https://github.com/pocketbase/pocketbase/blob/20653ef786db55dc77ad13461a659a0e5a960083/cmd/serve.go#L33C1-L37C5.

if len(args) > 0 {
        if httpAddr == "" {
                httpAddr = "0.0.0.0:80"
        }
        if httpsAddr == "" {
                httpsAddr = "0.0.0.0:443"
        }
} else {
        if port := os.Getenv("PORT"); port != "" {
        httpAddr = "0.0.0.0:" + port
    } else httpAddr == "" {
            httpAddr = "127.0.0.1:8090"
        }
}

This can help make it easier to deploy with docker on platforms that give us a random port.

ganigeorgiev commented 6 months ago

I don't think there is need for magic env variables. To specify a server address you can use the --http and --https flags. Env variables will require also extra documentation and could result in collisions if we don't prefix them.