a month ago
My app build takes too long in current railpack
Example:
- Project: 99528a9e-50d0-44f3-8947-a91834dc8f9f
- Service: 921223c1-66da-41bf-84a6-fceeb1eb81d4
one of the slowest step is this one:
`install-php-extensions mbstring pgsql fileinfo json zip curl gd openssl soap gd imagick redis zip ctype curl dom fileinfo filter hash mbstring openssl pcre pdo session tokenizer xml pdo_pgsql redis`
This actually rarely changes but it is installed everytime and is not cached.
There are other 3 services with similar configuration.
Whats the recommended aproach?
6 Replies
a month ago
Build cache hits are not guaranteed since our build system scales dynamically, as noted in our docs. For PHP extension installation that rarely changes, the recommended approach for consistent fast builds is to use a custom Dockerfile where you can leverage cache mounts or multi-stage builds to cache the extension installation layer, then deploy that image. You can also file a feature request for better PHP extension caching on the Railpack GitHub repo.
Status changed to Awaiting User Response Railway • about 1 month ago
Railway
Build cache hits are not guaranteed since our build system scales dynamically, as noted in [our docs](https://docs.railway.com/builds/build-configuration#why-isnt-my-build-using-cache). For PHP extension installation that rarely changes, the recommended approach for consistent fast builds is to use a custom Dockerfile where you can leverage cache mounts or multi-stage builds to cache the extension installation layer, then deploy that image. You can also file a feature request for better PHP extension caching on the [Railpack GitHub repo](https://github.com/railwayapp/railpack).
a month ago
I am not sure how to mix Railpack PHP provider which does automatically a lot of things with multi stage builds. My current railpack is this:
```
{
"$schema": "https://railway.com/railway.schema.json",
"build": {
"builder": "RAILPACK"
},
"deploy": {
"healthcheckPath": "/_debug",
"healthcheckTimeout": 60,
"restartPolicyType": "ON_FAILURE",
"preDeployCommand": [
"php artisan migrate --force"
],
"multiRegionConfig": {
"us-east4-eqdc4a": {
"numReplicas": 2
}
},
"limitOverride": {
"containers": {
"cpu": 2,
"memoryBytes": 8000000000
}
}
}
}
```
on every build this is what I see:
```
[Region: us-east4]
╭─────────────────╮
│ Railpack 0.23.0 │
╰─────────────────╯
↳ Detected Php
↳ Using custom php.ini: php.ini
↳ Using custom start-container.sh: start-container.sh
↳ Found Laravel app
Packages
──────────
php │ 8.4.20 │ composer.json > require > php (8.4)
Steps
──────────
▸ prepare
$ mkdir -p /usr/local/etc/php/conf.d
$ mkdir -p /conf.d/
▸ extensions
$ install-php-extensions mbstring pgsql fileinfo json zip curl gd openssl soap gd imagick redis zip ctype curl dom fileinfo filter hash mbstring openssl pcre pdo session tokenizer xml pdo_pgsql redis
...
```
Status changed to Awaiting Railway Response Railway • about 1 month ago
a month ago
This thread has been marked as public for community involvement, as it does not contain any sensitive or personal information. Any further activity in this thread will be visible to everyone.
Status changed to Open Railway • about 1 month ago
a month ago
Is that list of extensions specified in your php.ini in some way?
We'd love to improve PHP support, but I'm not a PHP guy so I'm still trying to understand usage patterns, etc so any details around your specific setup would be really helpful.
The AI comment is mostly incorrect. Railpack does cache mounts, etc so we should be able to greatly improve caching there.
mikebianco
Is that list of extensions specified in your php.ini in some way? We'd love to improve PHP support, but I'm not a PHP guy so I'm still trying to understand usage patterns, etc so any details around your specific setup would be really helpful. The AI comment is mostly incorrect. Railpack does cache mounts, etc so we should be able to greatly improve caching there.
a month ago
Hello Mike, I think railpack takes them from the composer.json at least in my case, they are defined like this:
"require": {
....
"ext-pgsql": "*",
....
}
a month ago
Got it. That's helpful! Sounds like you are using Laravel: are there any other frameworks or core libraries that you have in place that I can build into the test case for railpack?
mikebianco
Got it. That's helpful! Sounds like you are using Laravel: are there any other frameworks or core libraries that you have in place that I can build into the test case for railpack?
a month ago
Sorry for the late reply, I miss the notification for your message. First of all thank you for the help!. I can give you my exact composer.json file if that helps, see attached. I am do not much about php either 😆
Attachments