Error deploying example Laravel app to Fly

I am working on migrating my Heroku app (PHP/Codeigniter, Postgres) and having trouble launching the example Laravel fly app. I am able to successfully run the code locally, but when I run fly launch (in Git Bash on Windows), it errors out when trying to install composer. I’m somewhat new to docker, so I expect this to be a small fix, but I’ve had trouble finding the solution. Any help would be appreciated.

$ flyctl.exe launch
An existing fly.toml file was found for app example-www-stag
App is not running, deploy...
Deploying example-www-stag
==> Validating app configuration
--> Validating app configuration done
Services
TCP 443/80 ⇢ 8080
Remote builder fly-builder-example-1234 ready
==> Creating build context
--> Creating build context done
==> Building image with Docker
--> docker host: 20.10.12 linux x86_64
#1 [internal] load remote build context
Sending build context to Docker daemon  267.1kB
#1 CACHED

#2 copy /context /
#2 CACHED

#3 [internal] load metadata for docker.io/library/alpine:edge
#3 DONE 0.2s

#4 [ 1/33] FROM docker.io/library/alpine:edge@sha256:69361f5f421bb47db6f2f6baf84ab50b8f7c9b209f8376048dda9555example
#4 DONE 0.0s

#11 [ 8/33] RUN cp /etc/nginx/nginx.conf /etc/nginx/nginx.old.conf && rm -rf /etc/nginx/http.d/default.conf
#11 CACHED

#6 [ 3/33] RUN apk add curl     zip     unzip     ssmtp     tzdata
#6 CACHED

#7 [ 4/33] RUN apk add php8     php8-fpm     php8-cli     php8-pecl-mcrypt     php8-soap     php8-openssl     php8-gmp     php8-pdo_odbc     php8-json     php8-dom     php8-pdo     php8-zip     php8-pdo_mysql     php8-sqlite3     php8-pdo_pgsql     php8-bcmath     php8-gd     php8-odbc     php8-pdo_sqlite     php8-gettext     php8-xmlreader     php8-bz2     php8-iconv     php8-pdo_dblib     php8-curl     php8-ctype     php8-phar     php8-xml     php8-common     php8-mbstring     php8-tokenizer     php8-xmlwriter     php8-fileinfo     php8-opcache     php8-simplexml     php8-pecl-redis
#7 CACHED

#9 [ 6/33] RUN apk add supervisor
#9 CACHED

#10 [ 7/33] RUN apk add nginx
#10 CACHED

#5 [ 2/33] RUN apk update
#5 CACHED

#8 [ 5/33] RUN apk add nodejs npm
#8 CACHED

#12 [ 9/33] RUN apk add htop
#12 CACHED

#13 [10/33] RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
#13 0.290 /bin/sh: php: not found
#13 0.407 curl: (23) Failure writing output to destination
#13 ERROR: executor failed running [/bin/sh -c curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer]: exit code: 127
------
 > [10/33] RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer:
url: (23) Failure writing output to destination
------
Error error building: executor failed running [/bin/sh -c curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer]: exit code: 127

My guess is that a symlink for php is not being added (as it mentions php not found). It’s probably php8 still.

However Fly have changed the innards for how Laravel is deployed since that sample app was written. It’s now a lot smarter, using Fly’s processes block instead of supervisor etc.

I’d instead take a look at Run a Laravel App · Fly Docs and see how you get on with that new approach (so start with your Laravel app without the Fly-specific stuff that sample app adds, like the fly.toml etc).

If not, we can revisit the sample app and see what’s changed since it was written :slight_smile: Probably just needs modifying the Dockerfile so it can find php.

Thanks @greg . That worked. I am still running into a permissions error when I use that fly.toml on my Codeigniter app, but I’ll work on debugging that and I’ll post a separate question if I can’t get to the bottom of it.

1 Like