Hello guys.
I just deployed the Laravel application (clean) following the Fly documentation, I didn’t make any changes on the Laravel side, except what the doc asks for, but when I access the browser, everything is blank and the log doesn’t show any errors, which Can be?
Domain https://jmellodev.fly.dev
Just to clarify, did you use the guide from here Run a Laravel App · Fly Docs (rather than say, one of the older github examples)?
And nothing shows when you run fly logs
?
I guess the next thing I’d check was whether the app did in fact deploy. If you run fly status
, what does that show? It should show a table of 1 or more vms, and they should be running. If there are none, or they are showing as stopped/failed etc, that would explain why the site would not be working. As the vms serving it would not be. If they are all running, it would rule that out at least.
Thanks for the feedback, I think it must be some incompatibility with vite, I deleted the previous version and now I deployed it with a version using the mix and changed the APP_ENV key to local, now it shows the site.
I identified the problem, it’s not incompatibility, in fact the fly.toml is being created with spaces, as I still didn’t know about .toml I installed a plugin in vscode that I formatted and deployed and now everything is fine.
Hello everyone, after two days, even without deploying the application, it doesn’t work again, so there are no incompatibilities as I mentioned above, can any of the colleagues try to help me?
Thank you very much in advance.
My .toml
# fly.toml file generated for jmellodev on 2022-09-24T11:00:57-03:00
app = "jmellodev"
kill_signal = "SIGINT"
kill_timeout = 5
processes = []
[build]
[build.args]
NODE_VERSION = "14"
PHP_VERSION = "8.0"
[env]
APP_DEBUG = true
APP_ENV = "local"
LOG_CHANNEL = "stderr"
LOG_LEVEL = "info"
LOG_STDERR_FORMATTER = "Monolog\\Formatter\\JsonFormatter"
[experimental]
allowed_public_ports = []
auto_rollback = true
[[services]]
http_checks = []
internal_port = 8080
processes = ["app"]
protocol = "tcp"
script_checks = []
[services.concurrency]
hard_limit = 25
soft_limit = 20
type = "connections"
[[services.ports]]
force_https = true
handlers = ["http"]
port = 80
[[services.ports]]
handlers = ["tls", "http"]
port = 443
[[services.tcp_checks]]
grace_period = "1s"
interval = "15s"
restart_limit = 0
timeout = "2s"
hey there!
What do your logs say? is an error being reported?
What does “not working” look like this time? (same error that Chrome generates?)
Finally - what’s your Dockerfile look like? We’ve gone through some revisions if it, but not super recently.
There is no error, now it displays HTTP ERROR 503 and there was no change in any files (Laravel, .toml, Docker…).
Dockerfile
# syntax = docker/dockerfile:experimental
# Default to PHP 8.1, but we attempt to match
# the PHP version from the user (wherever `flyctl launch` is run)
# Valid version values are PHP 7.4+
ARG PHP_VERSION=8.1
ARG NODE_VERSION=14
FROM serversideup/php:${PHP_VERSION}-fpm-nginx as base
LABEL fly_launch_runtime="laravel"
RUN apt-get update && apt-get install -y \
git curl zip unzip rsync ca-certificates vim htop cron \
php${DOCKER_VERSION}-pgsql php${PHP_VERSION}-bcmath \
php${DOCKER_VERSION}-swoole php${PHP_VERSION}-xml php${PHP_VERSION}-mbstring \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /var/www/html
# copy application code, skipping files based on .dockerignore
COPY . /var/www/html
RUN composer install --optimize-autoloader --no-dev \
&& mkdir -p storage/logs \
&& php artisan optimize:clear \
&& chown -R webuser:webgroup /var/www/html \
&& sed -i 's/protected \$proxies/protected \$proxies = "*"/g' app/Http/Middleware/TrustProxies.php \
&& echo "MAILTO=\"\"\n* * * * * webuser /usr/bin/php /var/www/html/artisan schedule:run" > /etc/cron.d/laravel \
&& rm -rf /etc/cont-init.d/* \
&& cp docker/nginx-websockets.conf /etc/nginx/conf.d/websockets.conf \
&& cp docker/entrypoint.sh /entrypoint \
&& chmod +x /entrypoint
# If we're using Octane...
RUN if grep -Fq "laravel/octane" /var/www/html/composer.json; then \
rm -rf /etc/services.d/php-fpm; \
if grep -Fq "spiral/roadrunner" /var/www/html/composer.json; then \
mv docker/octane-rr /etc/services.d/octane; \
if [ -f ./vendor/bin/rr ]; then ./vendor/bin/rr get-binary; fi; \
rm -f .rr.yaml; \
else \
mv docker/octane-swoole /etc/services.d/octane; \
fi; \
cp docker/nginx-default-swoole /etc/nginx/sites-available/default; \
else \
cp docker/nginx-default /etc/nginx/sites-available/default; \
fi
# Multi-stage build: Build static assets
# This allows us to not include Node within the final container
FROM node:${NODE_VERSION} as node_modules_go_brrr
RUN mkdir /app
RUN mkdir -p /app
WORKDIR /app
COPY . .
COPY --from=base /var/www/html/vendor /app/vendor
# Use yarn or npm depending on what type of
# lock file we might find. Defaults to
# NPM if no lock file is found.
# Note: We run "production" for Mix and "build" for Vite
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;
# From our base container created above, we
# create our final image, adding in static
# assets that we generated above
FROM base
# Packages like Laravel Nova may have added assets to the public directory
# or maybe some custom assets were added manually! Either way, we merge
# in the assets we generated above rather than overwrite them
COPY --from=node_modules_go_brrr /app/public /var/www/html/public-npm
RUN rsync -ar /var/www/html/public-npm/ /var/www/html/public/ \
&& rm -rf /var/www/html/public-npm \
&& chown -R webuser:webgroup /var/www/html/public
EXPOSE 8080
ENTRYPOINT ["/entrypoint"]
What’s fly status --all
tell you? Are you in middle of updating the app now? (On our side, I see an allocation is in the “pending” state.
I re-deployed a clean application and the status is still 500.
app
Name = delivery
owner = personal
Version = 0
Status = running
Hostname = delivery.fly.dev
Platform = nomad
Deployment Status
ID=6625d9db-bf74-18ed-e8a7-c1298f412341
Version = v0
Status = successful
Description = Deployment completed successfully
Instances = 1 desired, 1 placed, 1 healthy, 0 unhealthy
instances
ID PROCESS VERSION REGION DESIRED STATUS HEALTH CHECKS RESTARTS CREATED
82da40a4 app 0 gru run running 1 total, 1 passing 0 36m7s ago
The 503 error you saw before is different from a 500 error. 503 might be like PHP-FPM is not running but Nginx is and returns a 503 error.
A 500 error might be more like the application code is running but returns an error message. It might be time to recheck fly logs
for that app!
That being said, the 500 error page isn’t Laravel’s error page, so I’m not totally sure where that error is coming from.
Are you able to docker build
this locally and ensure the resulting image can run (if you have Docker installed)? That might be a bit easier to debug and tell if there’s some configuration issue.
It would be something like:
docker build -t delivery:latest
docker run --rm -it -p 8080:8080 delivery:latest
# Then check http://localhost:8080 to see if it works
Stop here: ---> Running in 56dcbe85e8c5 Composer could not find a composer.json file in /var/www/html To initialize a project, please create a composer.json file. See https://getcomposer.org/basic-usage The command '/bin/sh -c composer install --optimize-autoloader --no-dev && mkdir -p storage/logs && php artisan optimize:clear && chown -R webuser:webgroup /var/www/html && sed -i 's/protected \$proxies/protected \$proxies = "*"/g' app/Http/Middleware/TrustProxies.php && echo "MAILTO=\"\"\n* * * * * webuser /usr/bin/php /var/www/html/artisan schedule:run" > /etc/cron.d/laravel && rm -rf /etc/cont-init.d/* && cp docker/nginx-websockets.conf /etc/nginx/conf.d/websockets.conf && cp docker/entrypoint.sh /entrypoint && chmod +x /entrypoint' returned a non-zero code: 1
That sounds like you weren’t running the “docker build” command from your project’s root - it couldn’t find a composer.json
file in the current directory.
(Apologies, I realized the docker build
command needed the “context” - the path to where the project files live).
It’s more like:
cd ~/path/to/my-laravel-project
# Confirm you're in the root of your Laravel project, and fly.toml, Dockerfile, etc, are present
# Note the addition of "." to say "build from the current directory"
docker build -t delivery:latest .
I’m assuming you actually do have a composer.json
file, but if you don’t, then … well that doesn’t make much sense for a Laravel application!
Everything is correct, way, it has composer.json
I give up, I did everything and all the tips and nothing works as it should, I deleted everything and redid it, I even used your example on github and nothing works. The messages say that everything is ok.
--> Pushing image done
Image: registry.fly.io/delivery:deployment-01GE2ERT67WTTH0Q0Q510APXJP
Image size: 408 MB
==> Creating release
Release v2 created
You can detach the terminal anytime without stopping the deployment
Monitoring Deployment
1 desired, 1 placed, 1 healthy, 0 unhealthy [health checks: 1 total, 1 passing]
--> v0 deployed successfully
What exact steps did you take? The example app on GitHub is essentially defunkt since we support Laravel via the fly launch
command.
Here’s what I just did successfully:
composer create-project laravel/laravel testproject
cd testproject
fly launch
> gave it a name
> set the region it selected (DFW for me)
> deploy now: yes
Here’s a quick video of what it looks like (I edited out the parts where you’re just waiting for a docker build to finish / deploy to happen). It uses a fresh Laravel installation.
I’m following exactly the steps you did, I even chose another region, but it doesn’t open, 503.
In the Dashboard there is another app that is disabled fly-builder-muddy-fog-5613.fly.dev, is this one disabled?
fly status --all
app
Name = delivery-app
owner = personal
Version = 0
Status = running
Hostname = delivery-app.fly.dev
Platform = nomad
Deployment Status
ID = fcdaee6f-7884-afc4-00a0-5a4457f3944b
Version = v0
Status = successful
Description = Deployment completed successfully
Instances = 1 desired, 1 placed, 1 healthy, 0 unhealthy
instances
ID PROCESS VERSION REGION DESIRED STATUS HEALTH CHECKS RESTARTS CREATED
74b26690 app 0 dfw run running 1 total, 1 passing 0 17m0s ago