Fly Deploy docker build fails with Api Only based Laravel

Using automatic Laravel detection with fly launch. it fails at the build stage below

 => [base 6/6] RUN if grep -Fq "laravel/octane" /var/www/html/composer.json; then         rm -rf /etc/services.d/php-fpm;           0.3s
 => [node_modules_go_brrr 6/7] COPY --from=base /var/www/html/vendor /app/vendor                                                    0.7s
 => ERROR [node_modules_go_brrr 7/7] RUN if [ -f "vite.config.js" ]; then         ASSET_CMD="build";     else         ASSET_CMD="p  1.1s
------
 > [node_modules_go_brrr 7/7] RUN if [ -f "vite.config.js" ]; then         ASSET_CMD="build";     else         ASSET_CMD="production";     fi;     if [ -f "yarn.lock" ]; then         yarn install --frozen-lockfile;         yarn $ASSET_CMD;     elif [ -f "package-lock.json" ]; then         npm ci --no-audit;         npm run $ASSET_CMD;     else         npm install;         npm run $ASSET_CMD;     fi;:
#19 0.732 npm WARN saveError ENOENT: no such file or directory, open '/app/package.json'
#19 0.742 npm notice created a lockfile as package-lock.json. You should commit this file.
#19 0.751 npm WARN enoent ENOENT: no such file or directory, open '/app/package.json'

Note this is using Laravel with API only, as such, there’s no npm/yarn, which I think is the error.

Note, you MUST have a package.json, with the scripts production set, even if you’re API only (eg using Laravel Breeze Next starter pack). Otherwise there will be a docker build error.

Eg, add the below,

package.json
{
    "name": "my-laravel-api-app",
    "version": "1.0.0",
    "scripts": {
        "prod": "",
        "production": ""
    }
  }

1 Like

Ahhh thank you for letting us know you figured that out! That could use some improvement there.