| Container | Purpose |
|---|---|
app |
Laravel PHP application |
nginx |
Web server |
db |
PostgreSQL database |
redis |
Queue & cache |
koshai-lagbe/
├── docker/
│ ├── nginx/
│ │ └── default.conf
│ └── php/
│ └── Dockerfile
├── src/ ← Your Laravel app lives here
├── docker-compose.yml
└── .env.docker
File: docker/php/Dockerfile
FROM php:8.3-fpm
RUN apt-get update && apt-get install -y \
git curl libpng-dev libonig-dev libxml2-dev \
libzip-dev zip unzip \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
RUN docker-php-ext-install \
pdo_mysql mbstring exif pcntl bcmath gd zip opcache
RUN pecl install redis && docker-php-ext-enable redis
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
WORKDIR /var/www
RUN chown -R www-data:www-data /var/www
EXPOSE 9000
CMD ["php-fpm"]File: docker/nginx/default.conf
server {
listen 80;
index index.php index.html;
root /var/www/public;
client_max_body_size 20M;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
fastcgi_pass app:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.(?!well-known).* {
deny all;
}
}File: docker-compose.yml
version: '3.8'
services:
app:
build:
context: .
dockerfile: docker/php/Dockerfile
container_name: koshai-lagbe_app
restart: unless-stopped
working_dir: /var/www
volumes:
- ./src:/var/www
networks:
- koshai-lagbe_network
depends_on:
- db
nginx:
image: nginx:alpine
container_name: koshai-lagbe_nginx
restart: unless-stopped
ports:
- "8000:80"
volumes:
- ./src:/var/www
- ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf
networks:
- koshai-lagbe_network
depends_on:
- app
db:
image: postgres:18
container_name: koshai-lagbe_db
volumes:
- ./src:/var/www
- ./docker/db/initdb.d:/docker-entrypoint-initdb.d
- pg_data:/var/lib/postgresql
environment:
POSTGRES_DB: ${DB_DATABASE}
POSTGRES_USER: ${DB_USERNAME}
POSTGRES_PASSWORD: ${DB_PASSWORD}
ports:
- "15732:5432"
restart: unless-stopped
networks:
- koshai-lagbe_network
networks:
koshai-lagbe_network:
driver: bridge
volumes:
pg_data:File: .env.docker
DB_DATABASE=saas_bot
DB_USERNAME=saas_user
DB_PASSWORD=secret123composer create-project laravel/laravel srcThen update src/.env:
APP_NAME="Koshai Lagbe"
APP_ENV=local
APP_DEBUG=true
APP_URL=http://localhost:8000
DB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=saas_bot
DB_USERNAME=saas_user
DB_PASSWORD=secret123
CACHE_DRIVER=redis
QUEUE_CONNECTION=redis
SESSION_DRIVER=redis
REDIS_HOST=redis
REDIS_PORT=6379
DB_HOST=mysqlandREDIS_HOST=redispoint to Docker service names, not localhost.
cp .env.docker .env
docker-compose up -d --buildWait 60–90 seconds, then:
docker exec koshai-lagbe_app composer install
docker exec koshai-lagbe_app php artisan key:generate
docker exec koshai-lagbe_app php artisan migrate# Recommended — fast and lightweight
docker exec koshai-lagbe_ollama ollama pull llama3.2:3b
# If RAM is limited (under 8GB)
docker exec koshai-lagbe_ollama ollama pull llama3.2:1bThe model is stored in the
ollama_datavolume. You only do this once.
Run each test in order. All must pass before moving to Part 2.
docker psExpected: 7 containers all showing Up
Open: http://localhost:8000
Expected: Laravel welcome page loads
Open: http://localhost:8080
Expected: phpMyAdmin login/dashboard loads
docker exec koshai-lagbe_app php artisan migrate:statusExpected: Migration table listed, no errors
docker exec koshai-lagbe_app php artisan tinkerCache::put('test', 'working', 10);
Cache::get('test');Expected: Returns "working"
docker logs koshai-lagbe_queueExpected: Processing jobs from the [default] queue
Inside tinker:
dispatch(function() {
\Log::info('Queue is working');
});Then:
docker logs koshai-lagbe_queueExpected: Queue is working appears in logs
| Problem | Fix |
|---|---|
| Port 8000 already in use | Change "8000:80" to "8080:80" in docker-compose |
| PostgreSQL connection refused | Wait 30 more seconds, PostgreSQL takes time to initialize |
| Permission denied on storage | docker exec koshai-lagbe_app chmod -R 775 storage bootstrap/cache |
# Start everything
docker-compose up -d
# Stop everything
docker-compose down
# Restart one service
docker-compose restart app
# View logs
docker logs koshai-lagbe_app
# Enter the app container shell
docker exec -it koshai-lagbe_app bash
# Clear Laravel caches
docker exec koshai-lagbe_app php artisan optimize:clear| Service | URL |
|---|---|
| Laravel App | http://localhost:8000 |