I have set up digitalocean database and added the app as trusted source but the database connection fails over the composer installation process. Below are the errors.
2023-08-31T12:28:49.440674571Z [34m│[0m - Installing spatie/laravel-permission (5.11.0): Extracting archive
2023-08-31T12:28:49.440996235Z [34m│[0m - Installing backpack/permissionmanager (7.0.1): Extracting archive
2023-08-31T12:28:49.441707872Z [34m│[0m - Installing backpack/pro (2.0.11): Extracting archive
2023-08-31T12:28:49.441857947Z [34m│[0m - Installing backpack/theme-tabler (1.0.12): Extracting archive
2023-08-31T12:28:49.441866784Z [34m│[0m - Installing laravel/sanctum (v3.2.6): Extracting archive
2023-08-31T12:28:49.442922204Z [34m│[0m - Installing nikic/php-parser (v4.17.1): Extracting archive
2023-08-31T12:28:49.443072538Z [34m│[0m - Installing psy/psysh (v0.11.20): Extracting archive
2023-08-31T12:28:49.443083506Z [34m│[0m - Installing laravel/tinker (v2.8.2): Extracting archive
2023-08-31T12:28:49.443739356Z [34m│[0m - Installing league/oauth1-client (v1.10.1): Extracting archive
2023-08-31T12:28:49.443887417Z [34m│[0m - Installing laravel/socialite (v5.6.1): Extracting archive
2023-08-31T12:28:49.444189417Z [34m│[0m - Installing webfuelagency/socialite (v1.0.0): Extracting archive
2023-08-31T12:28:50.211339029Z [34m│[0m Generating optimized autoload files
2023-08-31T12:28:51.092950964Z [34m│[0m > Illuminate\Foundation\ComposerScripts::postAutoloadDump
2023-08-31T12:28:51.112618305Z [34m│[0m > @php artisan package:discover --ansi
2023-08-31T12:30:51.671975471Z [34m│[0m
2023-08-31T12:30:51.685054869Z [34m│[0m In Connection.php line 801:
2023-08-31T12:30:51.685072692Z [34m│[0m
2023-08-31T12:30:51.685075407Z [34m│[0m SQLSTATE[HY000] [2002] Connection timed out (Connection: mysql, SQL: select
2023-08-31T12:30:51.685077778Z [34m│[0m column_name as `column_name` from information_schema.columns where table_s
2023-08-31T12:30:51.686646615Z [34m│[0m chema = racer and table_name = users)
2023-08-31T12:30:51.686650405Z [34m│[0m
2023-08-31T12:30:51.686653013Z [34m│[0m
2023-08-31T12:30:51.688565005Z [34m│[0m In Connector.php line 65:
2023-08-31T12:30:51.688570318Z [34m│[0m
2023-08-31T12:30:51.688572730Z [34m│[0m SQLSTATE[HY000] [2002] Connection timed out
2023-08-31T12:30:51.688575121Z [34m│[0m
2023-08-31T12:30:51.688577991Z [34m│[0m
2023-08-31T12:30:51.694274106Z [34m│[0m Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1
2023-08-31T12:30:51.740116109Z [34m│[0m [1;33m ! WARNING: An error occurred during a database connection or query
2023-08-31T12:30:51.740606806Z [34m│[0m [0m[1;31m
2023-08-31T12:30:51.743565792Z [34m│[0m ! ERROR: Dependency installation failed!
2023-08-31T12:30:51.743584506Z [34m│[0m !
2023-08-31T12:30:51.743589033Z [34m│[0m ! The 'composer install' process failed with an error. The cause
2023-08-31T12:30:51.743592710Z [34m│[0m ! may be the download or installation of packages, or a pre- or
2023-08-31T12:30:51.743596676Z [34m│[0m ! post-install hook (e.g. a 'post-install-cmd' item in 'scripts')
2023-08-31T12:30:51.743600321Z [34m│[0m ! in your 'composer.json'.
2023-08-31T12:30:51.743603582Z [34m│[0m !
2023-08-31T12:30:51.743606904Z [34m│[0m ! Typical error cases are out-of-date or missing parts of code,
2023-08-31T12:30:51.743610463Z [34m│[0m ! timeouts when making external connections, or memory limits.
2023-08-31T12:30:51.743626470Z [34m│[0m !
2023-08-31T12:30:51.743629959Z [34m│[0m ! Check the above error output closely to determine the cause of
2023-08-31T12:30:51.743633303Z [34m│[0m ! the problem, ensure the code you're pushing is functioning
2023-08-31T12:30:51.743636503Z [34m│[0m ! properly, and that all local changes are committed correctly.
2023-08-31T12:30:51.743639566Z [34m│[0m !
2023-08-31T12:30:51.743642861Z [34m│[0m ! For more information on builds for PHP on Heroku, refer to
2023-08-31T12:30:51.743645886Z [34m│[0m ! https://devcenter.heroku.com/articles/php-support
2023-08-31T12:30:51.746419873Z [34m│[0m !
2023-08-31T12:30:51.749945421Z [34m│[0m ! [1;33mREMINDER:[1;31m the following [1;33mwarnings[1;31m were emitted during the build;
2023-08-31T12:30:51.753633670Z [34m│[0m ! check the details above, as they may be related to this error:
2023-08-31T12:30:51.756724906Z [34m│[0m ! [1;33m-[1;31m Your app's PHP version is close to end of maintenance
2023-08-31T12:30:51.756739316Z [34m│[0m ! [1;33m-[1;31m An error occurred during a database connection or query
2023-08-31T12:30:51.757494004Z [34m│[0m [0m
2023-08-31T12:30:51.758311052Z [34m│[0m [31;1mERROR: [0mfailed to build: exit status 1
this is my composer json
{
"name": "laravel/laravel",
"type": "project",
"description": "The skeleton application for the Laravel framework.",
"keywords": ["laravel", "framework"],
"license": "MIT",
"require": {
"php": "8.1.18",
"ext-bcmath": "*",
"ext-ctype": "*",
"ext-curl": "*",
"ext-exif": "*",
"ext-fileinfo": "*",
"ext-gd": "*",
"ext-json": "*",
"ext-mbstring": "*",
"ext-openssl": "*",
"ext-pdo": "*",
"ext-tokenizer": "*",
"ext-xml": "*",
"backpack/crud": "^6.1",
"backpack/devtools": "^2.0",
"backpack/langfilemanager": "^5.0",
"backpack/medialibrary-uploaders": "^1.0",
"backpack/menucrud": "^4.0",
"backpack/pagemanager": "^3.2",
"backpack/permissionmanager": "^7.0",
"backpack/pro": "^2.0",
"backpack/theme-tabler": "^1.0",
"guzzlehttp/guzzle": "^7.2",
"laravel/framework": "^10.10",
"laravel/sanctum": "^3.2",
"laravel/tinker": "^2.8",
"spatie/laravel-medialibrary": "^10.11",
"webfuelagency/socialite": "^1.0"
},
and my app spec
alerts:
- rule: DEPLOYMENT_FAILED
- rule: DOMAIN_FAILED
databases:
- cluster_name: staging-db1
db_name: racer
db_user: doadmin
engine: MYSQL
name: staging-db1
production: true
size: professional-xs
version: "8"
ingress:
rules:
- component:
name: testapp
match:
path:
prefix: /
name: racer
region: sgp
services:
- build_command: npm run build
environment_slug: php
envs:
- key: DATABASE_URL
scope: RUN_TIME
value: ${staging-db1.DATABASE_URL}
github:
branch: staging
deploy_on_push: true
repo: wfftt/testapp
http_port: 8080
instance_count: 2
instance_size_slug: professional-xs
name: racer
run_command: heroku-php-apache2 public/ && composer install --ignore-platform-reqs
&& php artisan migrate:fresh
source_dir: /
I tested the database and the app running on my local were able to connect by adding my ip to the trusted source. Any idea?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Hi there,
Indeed, during the build stage the App Platform does not have access to the Managed databases.
In your case, you most likely have a post run script defined somewhere in your
composer.json
file which is causing the problem. What you could do is to track down the specific command defined in thecomposer.json
file that is causing the problem and remove it from there.Here is an example of a
composer.json
file that I have for an open-source project that I maintain which works with the App Platform:Feel free to share your complete
composer.json
file here so I could take a look as well and try to spot which script might be causing the problem.Best,
Bobby