Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 85 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Docker ignore file for Laravel application

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Dependency directories
node_modules/
vendor/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Environment files
.env
.env.local
.env.development.local
.env.test.local
.env.production.local

# Laravel specific
/storage/*.key
/storage/app/*
/storage/framework/cache/*
/storage/framework/sessions/*
/storage/framework/testing/*
/storage/framework/views/*
/storage/logs/*
/bootstrap/cache/*

# IDE files
.vscode/
.idea/
*.swp
*.swo

# OS generated files
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db

# Git
.git
.gitignore

# Testing
coverage/
.nyc_output

# Build files
/public/hot
/public/storage
/public/build

# Cache
.phpunit.result.cache

# Documentation
README.md
DEPLOYMENT.md
docs/

# Development files
docker-compose.yml
.editorconfig
.gitattributes

# Deployment scripts (optional - remove if you want them in the image)
# deploy.sh
67 changes: 67 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost

APP_LOCALE=en
APP_FALLBACK_LOCALE=en
APP_FAKER_LOCALE=en_US

APP_MAINTENANCE_DRIVER=file
# APP_MAINTENANCE_STORE=database

PHP_CLI_SERVER_WORKERS=4

BCRYPT_ROUNDS=12

LOG_CHANNEL=stack
LOG_STACK=single
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug

DB_CONNECTION=pgsql
DB_HOST=127.0.0.1
DB_PORT=5432
DB_DATABASE=smile
DB_USERNAME=root
DB_PASSWORD=

SESSION_DRIVER=database
SESSION_LIFETIME=120
SESSION_ENCRYPT=false
SESSION_PATH=/
SESSION_DOMAIN=null

BROADCAST_CONNECTION=log
FILESYSTEM_DISK=local
QUEUE_CONNECTION=database

CACHE_STORE=database
# CACHE_PREFIX=

MEMCACHED_HOST=127.0.0.1

REDIS_CLIENT=phpredis
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_MAILER=log
MAIL_SCHEME=null
MAIL_HOST=127.0.0.1
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_FROM_ADDRESS="hello@example.com"
MAIL_FROM_NAME="${APP_NAME}"

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
AWS_USE_PATH_STYLE_ENDPOINT=false

VITE_APP_NAME="${APP_NAME}"
OPENAI_API_KEY=
OPENAI_ORGANIZATION=
139 changes: 139 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
# CI/CD Pipeline for GitHub Actions
name: Deploy to DigitalOcean Kubernetes

on:
push:
branches: [ main, production ]
pull_request:
branches: [ main ]

env:
REGISTRY: registry.digitalocean.com/smile-registry
IMAGE_NAME: smile-app

jobs:
test:
runs-on: ubuntu-latest

services:
mysql:
image: mysql:8.0
env:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: smile_test
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3

redis:
image: redis:7-alpine
ports:
- 6379:6379
options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=3

steps:
- uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite, pdo_mysql, gd, redis
coverage: xdebug

- name: Cache Composer dependencies
uses: actions/cache@v3
with:
path: /tmp/composer-cache
key: ${{ runner.os }}-${{ hashFiles('**/composer.lock') }}

- name: Install PHP dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'

- name: Install Node.js dependencies
run: npm ci

- name: Build frontend assets
run: npm run build

- name: Prepare Laravel environment
run: |
cp .env.example .env
php artisan key:generate
php artisan config:cache

- name: Run tests
env:
DB_CONNECTION: mysql
DB_HOST: 127.0.0.1
DB_PORT: 3306
DB_DATABASE: smile_test
DB_USERNAME: root
DB_PASSWORD: root
REDIS_HOST: 127.0.0.1
REDIS_PORT: 6379
run: |
php artisan migrate --force
php artisan test

build:
needs: test
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/production'

steps:
- uses: actions/checkout@v4

- name: Install doctl
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}

- name: Log in to DigitalOcean Container Registry
run: doctl registry login --expiry-seconds 600

- name: Build and push Docker image
run: |
docker build -t $REGISTRY/$IMAGE_NAME:$GITHUB_SHA -t $REGISTRY/$IMAGE_NAME:latest .
docker push $REGISTRY/$IMAGE_NAME:$GITHUB_SHA
docker push $REGISTRY/$IMAGE_NAME:latest

deploy:
needs: build
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/production'

steps:
- uses: actions/checkout@v4

- name: Install doctl
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}

- name: Save DigitalOcean kubeconfig
run: doctl kubernetes cluster kubeconfig save --expiry-seconds 600 ${{ secrets.K8S_CLUSTER_NAME }}

- name: Update deployment image
run: |
kubectl set image deployment/smile-app smile-app=$REGISTRY/$IMAGE_NAME:$GITHUB_SHA -n smile-app
kubectl set image deployment/smile-worker smile-worker=$REGISTRY/$IMAGE_NAME:$GITHUB_SHA -n smile-app
kubectl set image deployment/smile-scheduler smile-scheduler=$REGISTRY/$IMAGE_NAME:$GITHUB_SHA -n smile-app

- name: Verify deployment
run: |
kubectl rollout status deployment/smile-app -n smile-app --timeout=300s
kubectl rollout status deployment/smile-worker -n smile-app --timeout=300s
kubectl rollout status deployment/smile-scheduler -n smile-app --timeout=300s

- name: Run database migrations
run: |
kubectl wait --for=condition=ready pod -l app=smile-app -n smile-app --timeout=300s
POD_NAME=$(kubectl get pods -l app=smile-app -n smile-app -o jsonpath='{.items[0].metadata.name}')
kubectl exec $POD_NAME -n smile-app -- php artisan migrate --force
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,4 @@ Homestead.yaml
npm-debug.log
Thumbs.db
yarn-error.log

composer.lock
package-lock.json
k8s/secrets.yaml
Loading
Loading