Deploying on render.com #993
What happened?Hi there, I'm trying to get a pretty standard Laravel app deployed on a Render web service instance. Here's my Dockerfile: FROM dunglas/frankenphp
RUN install-php-extensions \
pdo \
gd \
intl \
zip \
opcache
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
COPY . /app
RUN composer install --no-interaction --no-scripts --no-suggest
RUN php artisan config:cache
RUN php artisan route:cache
RUN php artisan migrate --force
# Line below needed otherwise build exits with a permissions error
RUN setcap -r /usr/local/bin/frankenphpLocally, if I run (from the docs): docker run -p 80:80 -p 443:443 -p 443:443/udp -v $PWD:/app dunglas/frankenphpEverything works as expected. On Render, when I deploy everything seems to build and start correctly, I even get the default Laravel uptime endpoint ( I've tried clearing my cookies, different browsers and tweaking the ports exposed but nothing seems to help. I don't really have anything special set up in the environment as shown below:
I think the issue might be something to do with the default port binding and/or proxying from HTTPS -> HTTP but I don't know enough about this to get it working. Any ideas welcomed! Thanks in advance Build TypeDocker (Debian Bookworm) Worker ModeNo Operating SystemGNU/Linux CPU Architecturex86_64 PHP configurationUnchanged from Docker imageRelevant log outputNo response |
Replies: 3 comments 7 replies
|
Try setting the |
|
Ok, have found the issue. Running either: Is making the system-level env vars inaccessible for some reason 🤷 Taking these out and FrankenPHP starts as expected, with Render doing the HTTPS termination. |
|
I think this is probably caused by when If those commands run during the Docker image build, Laravel writes the resolved config values into That would explain why Laravel’s docs mention that after config is cached, the So I think one fix is to avoid running these during RUN php artisan config:cache
RUN php artisan optimizeand instead run them after the container has started with the real production env vars available, unless you explicitly make those vars available at build time. I would usually avoid running migrations during the image build for the same reason: RUN php artisan migrate --forceMigrations should usually happen at deploy/startup time, when the production database env vars are available and the new code that depends on those migrations is being deployed. Otherwise, there could be a significant gap between image build and deploy where the database has already been changed but the old code is still running. Using a Caddy module such as caddy-exec might be one way to run startup commands, and FrankenPHP documents how to build custom Caddy modules here: |

I think this is probably caused by when
config:cache/optimizeis being run.If those commands run during the Docker image build, Laravel writes the resolved config values into
bootstrap/cache/config.phpat build time. So the cached config reflects whatever environment existed while the image was built, not necessarily the environment that exists later when Render starts the container.That would explain why
printenvcan show the runtime variables inside the container, while Laravel still behaves as ifAPP_KEY/ other config values are missing or stale. The runtime env exists, but Laravel is reading from the already-cached config file.Laravel’s docs mention that after config is cached, …