July 22, 2025

Article

How to Deploy Laravel to Google Cloud Run in Under 10 Minutes

How to Deploy Laravel to Google Cloud Run in Under 10 Minutes

In this guide, you’ll learn how to take a Laravel app and deploy it to Google Cloud Run quickly using Docker and the gcloud CLI. We cover containerizing your app, deploying it, setting environment variables, and optional steps like scheduling cron jobs and handling queues. If you want to skip the DevOps headache and get straight to scaling Laravel on GCP, this is the fastest way to start.

Intro:

Deploying Laravel to Google Cloud can feel overwhelming at first — Dockerfiles, environment variables, queue handling, and cron jobs can quickly turn into a full DevOps project. But it doesn’t have to be this hard. In this post, I’ll walk you through a quick way to get your Laravel app running on Google Cloud Run, using simple steps you can follow today.

🛠️ What You’ll Need

  • A Laravel project

  • A Google Cloud account

  • The gcloud CLI installed

  • Docker installed locally

🚀 Step 1: Containerize Your Laravel App

You’ll need a Dockerfile at the root of your project:

FROM php:8.2-fpm

# Install dependencies
RUN apt-get update && apt-get install -y \
    zip unzip curl git libpng-dev libonig-dev libxml2-dev libzip-dev \
    && docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath gd zip

# Set working directory
WORKDIR /var/www

# Copy and install composer
COPY . .
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
RUN composer install --no-dev --optimize-autoloader

# Set permissions
RUN chown -R www-data:www-data /var/www

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

⚙️ Step 2: Deploy to Cloud Run

In your terminal:

gcloud builds submit --tag

Then:

gcloud run deploy laravel-app \
  --image gcr.io/YOUR_PROJECT_ID/laravel-app \
  --platform managed \
  --region us-central1 \
  --allow-unauthenticated

🔐 Step 3: Configure Environment Variables

Use Google Secret Manager or pass vars in gcloud run deploy using:

--set-env-vars APP_KEY=your_app_key,APP_ENV

⏱️ Step 4: Schedule Cron Jobs (Optional)

Use Cloud Scheduler to call an authenticated route like:

Set up Laravel route to handle it.

📦 Bonus: Queue Workers with Pub/Sub

To support Laravel queues, configure Pub/Sub and a background worker service — or wait for LaraRun, which handles this automatically 😉

✅ Conclusion

Google Cloud Run is powerful, but a bit of a setup puzzle for Laravel devs. With tools like Docker, gcloud, and a bit of tweaking, you can go serverless in under 10 minutes. Or, you can skip the hassle altogether and join the LaraRun waitlist — we’re building this experience for you.