Loading...

Learn / Deploy

How to Deploy a Laravel App on cdn.com.tr

Take a Laravel app to production without renting and patching a server. Two paths: a fully managed PHP runtime, or your own container deployed from Git — both behind the CDN edge with a managed database, automatic HTTPS and a WAF.

9 min read Intermediate Updated

How to Deploy a Laravel App on cdn.com.tr

Two ways to deploy

You need a Laravel app, a Git repository and a cdn.com.tr account. There are two paths and you can pick either. The managed PHP platform runs your Laravel app on a modern PHP 8 runtime with a managed database, Redis, automatic SSL and a WAF — no Dockerfile to write. The container path gives you full control: you provide a Dockerfile, and the platform builds and runs it as a managed container app. Both sit behind the CDN edge. This guide covers the container path in detail and points to the managed platform where it is simpler.

How to Deploy a Laravel App on cdn.com.tr — Two ways to deploy
Managed platforms and container apps on cdn.com.tr.

Configuration and secrets

Never bake your .env into the image or commit secrets to Git. Instead, set your Laravel configuration as environment variables (and secrets) on the platform, so the same image runs safely in production. At minimum you will set the app key, environment, and your managed database and Redis connections.

Environment values to set on the platform

APP_ENV=production
APP_KEY=base64:...        # php artisan key:generate --show
APP_DEBUG=false
APP_URL=https://app.example.com

DB_CONNECTION=mysql
DB_HOST=<managed-db-host>
DB_DATABASE=<db>
DB_USERNAME=<user>
DB_PASSWORD=<secret>

CACHE_STORE=redis
SESSION_DRIVER=redis
REDIS_HOST=<managed-redis-host>

Add a Dockerfile

Commit a Dockerfile to the root of your repository. This example installs Composer dependencies and serves the app on port 8000. Laravel's built-in server keeps the example simple; for high traffic, switch the last line to Laravel Octane (FrankenPHP or Swoole) or use the managed PHP platform instead.

Dockerfile

FROM php:8.2-cli

# PHP extensions Laravel commonly needs
RUN apt-get update && apt-get install -y libzip-dev \
 && docker-php-ext-install pdo_mysql zip opcache

# Composer
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer

WORKDIR /app
COPY . .
RUN composer install --no-dev --optimize-autoloader --no-interaction

EXPOSE 8000
CMD ["php", "artisan", "serve", "--host=0.0.0.0", "--port=8000"]

Deploy from Git

In the cdn.com.tr panel, create a container app and connect your Git repository. The platform reads your Dockerfile, builds the image and runs the container. After that, deploying is just pushing to your branch — each push builds a fresh image and rolls it out with zero downtime.

Ship a change

git add .
git commit -m "Add invoices page"
git push origin main
# cdn.com.tr builds the image and rolls it out automatically

Managed database, Redis and migrations

Attach a managed database and Redis with one cdnctl command each — they wire the connection into your app as environment variables, so the .env values from step 2 are set for you. Redis gives Laravel a fast cache and session store; the managed database is backed up and reachable from the app. Then run your migrations against it as part of the deploy so the schema stays in sync.

cdnctl — add a database and Redis, then migrate
cdnctl accounts use <account_uuid>

cdnctl container addons enable-database --app <app_uuid> --url-scheme mysql
cdnctl container addons enable-redis    --app <app_uuid> --env-prefix REDIS

# run migrations against the managed database
php artisan migrate --force

Domain, HTTPS and the edge

Point your domain at the app and cdn.com.tr issues and renews SSL automatically. Your Laravel app now runs behind the CDN edge: static assets are cached and served close to visitors, a WAF filters malicious traffic, and spikes are absorbed at the edge. If you would rather not manage a Dockerfile at all, the managed PHP platform gives you the same result — PHP 8 runtime, managed DB and Redis, automatic HTTPS and WAF — without building an image.

Good fits

SaaS & web apps

Run Laravel with a managed database and Redis, automatic HTTPS and a WAF, deployed straight from Git.

Legacy PHP modernization

Move an older PHP app to PHP 8 on the managed platform, behind CDN and WAF, without re-architecting it.

APIs & backends

Serve Laravel API routes as a managed container with healthchecks, secrets and edge routing in front.

Laravel deploy FAQ

Do I need Docker, or can I use the managed platform?

Either. The managed PHP platform runs Laravel without a Dockerfile — you get a PHP 8 runtime with a managed database, Redis, HTTPS and a WAF. The container path is for teams that want full control over the image; both run behind the edge.

Where do queues and the scheduler run?

Run Laravel's scheduler and queue workers as scheduled or long-running jobs alongside the app, pointed at the same managed Redis/database. Keep secrets in environment variables so every process shares one configuration.

How do database migrations work on deploy?

Run 'php artisan migrate --force' against the managed database as part of your deploy. Because a failed build keeps the previous version serving, you roll forward safely and your schema stays in sync with the code.