Web application for calculating optimal sleep schedule.
- Docker and Docker Compose
- Git
-
Clone the repository:
git clone https://github.com/rico-vz/sleep-calculator-web.git cd sleep-calculator-web -
Copy the Laravel environment file:
cp src/.env.example src/.env
-
Update the root .env file with the ports want to use for Nginx and Redis.
-
Start the Docker environment:
docker-compose up -d
-
Install PHP dependencies:
docker-compose exec app composer install -
Generate application key (if not already set):
docker-compose exec app php artisan key:generate -
Install JavaScript dependencies:
docker-compose exec app npm install -
Run Vite development server:
docker-compose exec app npm run dev -
Run database migrations:
docker-compose exec app php artisan migrate -
Access the application at localhost (with the port you set in the .env file).
├── docker/ # Docker configuration files
│ ├── nginx/ # Nginx configuration
│ └── php/ # PHP configuration and Dockerfile
├── src/ # Laravel source code
└── docker-compose.yml # Docker Compose configurationThe project uses Docker Compose with the following services:
- app: PHP application server (PHP 8.4 FPM + Node.js 20.x)
- nginx: Web server (Nginx 1.27)
- mariadb: Database server (MariaDB 11.4)
- redis: Caching server (Redis 7.4)
# Start all containers
docker-compose up -d
# Stop all containers
docker-compose down
# Rebuild containers after Dockerfile changes
docker-compose build
# View logs
docker-compose logs -f
# Execute commands in the app container
docker-compose exec app [command]docker-compose exec app php artisan [command]# Build assets for production
docker-compose exec app npm run build# Run migrations
docker-compose exec app php artisan migrate
# Roll back migrations
docker-compose exec app php artisan migrate:rollback
# Create a new migration
docker-compose exec app php artisan make:migration create_table_name- Modify PHP configuration in
docker/php/php.ini - Adjust Nginx settings in
docker/nginx/default.conf - Configure database settings in
src/.env
-
If you encounter connection refused errors to MariaDB, ensure the
DB_HOSTinsrc/.envis set tomariadb -
For Redis connection issues, check that
REDIS_HOSTis set toredis -
For permission issues with the storage directory, run:
docker-compose exec app chmod -R 775 storage bootstrap/cache
- Web server with Docker and Docker Compose
-
Clone the repository on your server
-
Create a production
src/.envfile with appropriate settings -
Build and start the containers:
docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d --build
-
Run migrations and optimize:
docker-compose exec app php artisan migrate --force docker-compose exec app php artisan optimize docker-compose exec app npm run build