- Updated Dockerfile configurations for various environments (alpine, basic, cloudrun, minimal, simple, test) to ensure compatibility with Laravel 5.0 and PHP 5.6. - Added PHP compatibility documentation outlining mcrypt requirements and upgrade paths. - Created cloudbuild.yaml for Google Cloud Build integration to streamline deployment to Cloud Run. - Introduced docker-compose.local.yml for local development with MySQL and Redis services. - Enhanced rebuild.sh script for easier local development and migration handling. - Updated Laravel Blade views to correct asset paths. - Added start-local.sh script for quick local setup and service management.
157 lines
5.1 KiB
YAML
157 lines
5.1 KiB
YAML
# Google Cloud Build configuration for Laravel 5 application deployment to Cloud Run
|
|
steps:
|
|
# Step 1: Build the Docker image
|
|
- name: 'gcr.io/cloud-builders/docker'
|
|
args:
|
|
- 'build'
|
|
- '-t'
|
|
- 'gcr.io/$PROJECT_ID/merchbay-laravel:$COMMIT_SHA'
|
|
- '-t'
|
|
- 'gcr.io/$PROJECT_ID/merchbay-laravel:latest'
|
|
- '-f'
|
|
- 'Dockerfile.simple'
|
|
- '.'
|
|
id: 'build-image'
|
|
|
|
# Step 2: Push the Docker image to Google Container Registry
|
|
- name: 'gcr.io/cloud-builders/docker'
|
|
args:
|
|
- 'push'
|
|
- 'gcr.io/$PROJECT_ID/merchbay-laravel:$COMMIT_SHA'
|
|
id: 'push-image'
|
|
waitFor: ['build-image']
|
|
|
|
# Step 3: Push the latest tag as well
|
|
- name: 'gcr.io/cloud-builders/docker'
|
|
args:
|
|
- 'push'
|
|
- 'gcr.io/$PROJECT_ID/merchbay-laravel:latest'
|
|
id: 'push-latest'
|
|
waitFor: ['build-image']
|
|
|
|
# Step 4: Run database migrations (optional - only if you have Cloud SQL configured)
|
|
# Uncomment and configure if you need to run migrations
|
|
# - name: 'gcr.io/cloud-builders/gcloud'
|
|
# entrypoint: 'bash'
|
|
# args:
|
|
# - '-c'
|
|
# - |
|
|
# gcloud run jobs create laravel-migrate \
|
|
# --image=gcr.io/$PROJECT_ID/merchbay-laravel:$COMMIT_SHA \
|
|
# --region=$_REGION \
|
|
# --set-env-vars="APP_ENV=production,APP_KEY=$_APP_KEY,DB_HOST=$_DB_HOST,DB_DATABASE=$_DB_DATABASE,DB_USERNAME=$_DB_USERNAME,DB_PASSWORD=$_DB_PASSWORD" \
|
|
# --set-cloudsql-instances=$_CLOUDSQL_INSTANCE \
|
|
# --command="php" \
|
|
# --args="artisan,migrate,--force" \
|
|
# --max-retries=1 \
|
|
# --replace || true
|
|
# gcloud run jobs execute laravel-migrate --region=$_REGION --wait
|
|
# id: 'run-migrations'
|
|
# waitFor: ['push-image']
|
|
|
|
# Step 5: Deploy to Cloud Run
|
|
- name: 'gcr.io/cloud-builders/gcloud'
|
|
args:
|
|
- 'run'
|
|
- 'deploy'
|
|
- '$_SERVICE_NAME'
|
|
- '--image'
|
|
- 'gcr.io/$PROJECT_ID/merchbay-laravel:$COMMIT_SHA'
|
|
- '--region'
|
|
- '$_REGION'
|
|
- '--platform'
|
|
- 'managed'
|
|
- '--allow-unauthenticated'
|
|
- '--port'
|
|
- '8080'
|
|
- '--memory'
|
|
- '$_MEMORY'
|
|
- '--cpu'
|
|
- '$_CPU'
|
|
- '--timeout'
|
|
- '$_TIMEOUT'
|
|
- '--concurrency'
|
|
- '$_CONCURRENCY'
|
|
- '--min-instances'
|
|
- '$_MIN_INSTANCES'
|
|
- '--max-instances'
|
|
- '$_MAX_INSTANCES'
|
|
- '--set-env-vars'
|
|
- 'APP_ENV=production,APP_DEBUG=false,APP_KEY=$_APP_KEY,DB_HOST=$_DB_HOST,DB_DATABASE=$_DB_DATABASE,DB_USERNAME=$_DB_USERNAME,DB_PASSWORD=$_DB_PASSWORD,CACHE_DRIVER=redis,SESSION_DRIVER=redis,QUEUE_DRIVER=database,PAYPAL_MODE=$_PAYPAL_MODE,PAYPAL_LIVE_CLIENT_ID=$_PAYPAL_LIVE_CLIENT_ID,PAYPAL_LIVE_SECRET=$_PAYPAL_LIVE_SECRET,PAYPAL_SANDBOX_CLIENT_ID=$_PAYPAL_SANDBOX_CLIENT_ID,PAYPAL_SANDBOX_SECRET=$_PAYPAL_SANDBOX_SECRET,MAIL_DRIVER=$_MAIL_DRIVER,MAIL_HOST=$_MAIL_HOST,MAIL_PORT=$_MAIL_PORT,MAIL_USERNAME=$_MAIL_USERNAME,MAIL_PASSWORD=$_MAIL_PASSWORD,GOOGLE_ANALYTICS_VIEW_ID=$_GOOGLE_ANALYTICS_VIEW_ID'
|
|
- '--set-cloudsql-instances'
|
|
- '$_CLOUDSQL_INSTANCE'
|
|
- '--vpc-connector'
|
|
- '$_VPC_CONNECTOR'
|
|
- '--add-cloudsql-instances'
|
|
- '$_CLOUDSQL_INSTANCE'
|
|
id: 'deploy-service'
|
|
waitFor: ['push-image']
|
|
|
|
# Substitution variables - you can override these in your Cloud Build trigger
|
|
substitutions:
|
|
# Service configuration
|
|
_SERVICE_NAME: 'merchbay-laravel'
|
|
_REGION: 'us-central1'
|
|
|
|
# Resource limits
|
|
_MEMORY: '1Gi'
|
|
_CPU: '1000m'
|
|
_TIMEOUT: '300s'
|
|
_CONCURRENCY: '80'
|
|
_MIN_INSTANCES: '0'
|
|
_MAX_INSTANCES: '10'
|
|
|
|
# Database configuration (Cloud SQL)
|
|
_CLOUDSQL_INSTANCE: 'YOUR_PROJECT_ID:REGION:INSTANCE_NAME'
|
|
_DB_HOST: '127.0.0.1'
|
|
_DB_DATABASE: 'merchbay'
|
|
_DB_USERNAME: 'laravel_user'
|
|
_DB_PASSWORD: 'YOUR_DB_PASSWORD'
|
|
|
|
# VPC configuration (if needed)
|
|
_VPC_CONNECTOR: 'projects/YOUR_PROJECT_ID/locations/REGION/connectors/CONNECTOR_NAME'
|
|
|
|
# Application configuration
|
|
_APP_KEY: 'base64:YOUR_APP_KEY_HERE'
|
|
|
|
# PayPal configuration
|
|
_PAYPAL_MODE: 'live'
|
|
_PAYPAL_LIVE_CLIENT_ID: 'YOUR_PAYPAL_LIVE_CLIENT_ID'
|
|
_PAYPAL_LIVE_SECRET: 'YOUR_PAYPAL_LIVE_SECRET'
|
|
_PAYPAL_SANDBOX_CLIENT_ID: 'YOUR_PAYPAL_SANDBOX_CLIENT_ID'
|
|
_PAYPAL_SANDBOX_SECRET: 'YOUR_PAYPAL_SANDBOX_SECRET'
|
|
|
|
# Mail configuration
|
|
_MAIL_DRIVER: 'smtp'
|
|
_MAIL_HOST: 'smtp.gmail.com'
|
|
_MAIL_PORT: '587'
|
|
_MAIL_USERNAME: 'your-email@domain.com'
|
|
_MAIL_PASSWORD: 'your-app-password'
|
|
|
|
# Google Analytics
|
|
_GOOGLE_ANALYTICS_VIEW_ID: 'YOUR_GA_VIEW_ID'
|
|
|
|
# Build options
|
|
options:
|
|
# Use a more powerful machine for faster builds
|
|
machineType: 'E2_HIGHCPU_8'
|
|
|
|
# Enable detailed logging
|
|
logging: CLOUD_LOGGING_ONLY
|
|
|
|
# Build timeout
|
|
timeout: '1200s'
|
|
|
|
# Store build logs in Cloud Logging
|
|
logsBucket: 'gs://YOUR_PROJECT_ID_cloudbuild-logs'
|
|
|
|
# Available logs for debugging
|
|
availableSecrets:
|
|
secretManager:
|
|
- versionName: 'projects/YOUR_PROJECT_ID/secrets/APP_KEY/versions/latest'
|
|
env: 'APP_KEY'
|
|
- versionName: 'projects/YOUR_PROJECT_ID/secrets/DB_PASSWORD/versions/latest'
|
|
env: 'DB_PASSWORD'
|
|
- versionName: 'projects/YOUR_PROJECT_ID/secrets/PAYPAL_LIVE_SECRET/versions/latest'
|
|
env: 'PAYPAL_LIVE_SECRET'
|