Major Configuration

This commit is contained in:
erishBRBS 2025-03-26 22:43:00 +08:00
parent 754a9c2821
commit a74b46ae31
47 changed files with 57 additions and 59 deletions

0
.editorconfig Normal file → Executable file
View File

0
.gitattributes vendored Normal file → Executable file
View File

0
.gitignore vendored Normal file → Executable file
View File

0
README.md Normal file → Executable file
View File

0
app/Http/Controllers/Controller.php Normal file → Executable file
View File

0
app/Models/User.php Normal file → Executable file
View File

0
app/Providers/AppServiceProvider.php Normal file → Executable file
View File

0
bootstrap/app.php Normal file → Executable file
View File

0
bootstrap/providers.php Normal file → Executable file
View File

0
composer.json Normal file → Executable file
View File

0
composer.lock generated Normal file → Executable file
View File

0
config/app.php Normal file → Executable file
View File

0
config/auth.php Normal file → Executable file
View File

0
config/cache.php Normal file → Executable file
View File

0
config/database.php Normal file → Executable file
View File

0
config/filesystems.php Normal file → Executable file
View File

0
config/logging.php Normal file → Executable file
View File

0
config/mail.php Normal file → Executable file
View File

0
config/queue.php Normal file → Executable file
View File

0
config/services.php Normal file → Executable file
View File

0
config/session.php Normal file → Executable file
View File

0
database/.gitignore vendored Normal file → Executable file
View File

0
database/factories/UserFactory.php Normal file → Executable file
View File

View File

View File

View File

0
database/seeders/DatabaseSeeder.php Normal file → Executable file
View File

76
docker-compose.yml Normal file → Executable file
View File

@ -1,42 +1,37 @@
services:
# Laravel App
app:
build:
context: ./docker/php
dockerfile: Dockerfile
container_name: laravel-12-docker
restart: always
working_dir: /var/www
context: .
dockerfile: ./docker/php/Dockerfile
container_name: laravel-app
restart: unless-stopped
volumes:
- .:/var/www
- .:/var/www/html
- ./storage:/var/www/html/storage
- ./bootstrap/cache:/var/www/html/bootstrap/cache
depends_on:
db_mysql:
condition: service_healthy
command: >
sh -c "
while ! nc -z db_mysql 3306; do
sleep 2;
done;
php artisan migrate --force && php-fpm"
command:
[ "sh", "-c", "/var/www/html/docker/php/entrypoint.sh" ]
healthcheck:
test: ["CMD", "sh", "-c", "pgrep php-fpm"]
test: ["CMD", "pgrep", "php-fpm"]
interval: 30s
timeout: 10s
retries: 10
retries: 5
networks:
- app_network
# MySQL
db_mysql:
image: mysql:8.2
container_name: mysql-db
restart: always
container_name: db_mysql
restart: unless-stopped
environment:
MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD}
MYSQL_DATABASE: ${DB_DATABASE}
MYSQL_PASSWORD: ${DB_PASSWORD}
ports:
- ${DB_PORT}:3306
MYSQL_ROOT_PASSWORD: laravel
MYSQL_DATABASE: laravel-docker
MYSQL_USER: laravel
MYSQL_PASSWORD: laravel12
volumes:
- mysql-data:/var/lib/mysql
healthcheck:
@ -47,44 +42,25 @@ services:
networks:
- app_network
# Phpmyadmin
phpmyadmin:
image: phpmyadmin/phpmyadmin
container_name: phpmyadmin
restart: always
nginx:
image: nginx:alpine
container_name: nginx
restart: unless-stopped
ports:
- "8080:80"
environment:
PMA_HOST: db_mysql
MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD}
APACHE_SERVER_NAME: 0.0.0.0
networks:
- app_network
# Nginx
web:
image: nginx:1.26.3-alpine
container_name: nginx-web
restart: always
ports:
- "8000:80"
- "80:80"
volumes:
- .:/var/www
- .:/var/www/html
- ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf:ro
depends_on:
app:
condition: service_healthy
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost"]
interval: 30s
timeout: 10s
retries: 5
networks:
- app_network
volumes:
mysql-data:
storage-volume:
driver: local
networks:
app_network:

4
docker/nginx/default.conf Normal file → Executable file
View File

@ -2,8 +2,7 @@ server {
listen 80;
server_name localhost;
root /var/www/public;
root /var/www/html/public;
index index.php index.html;
location / {
@ -24,4 +23,3 @@ server {
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
}

15
docker/php/Dockerfile Normal file → Executable file
View File

@ -8,16 +8,19 @@ RUN docker-php-ext-install pdo pdo_mysql bcmath
COPY --from=composer:2.7 /usr/bin/composer /usr/bin/composer
# Set working directory
WORKDIR /var/www
WORKDIR /var/www/html
# Copy app files
COPY . /var/www
COPY . /var/www/html
# Set permissions
RUN chown -R www-data:www-data /var/www
# Ensure entrypoint script is
RUN chmod +x /var/www/html/docker/php/entrypoint.sh
# Set permissions for app files
RUN chown -R www-data:www-data /var/www/html
# Expose PHP-FPM port
EXPOSE 9000
# Start PHP-FPM
CMD ["php-fpm"]
# Start PHP-FPM (Handled in entrypoint.sh)
CMD ["sh", "-c", "/var/www/html/docker/php/entrypoint.sh"]

21
docker/php/entrypoint.sh Executable file
View File

@ -0,0 +1,21 @@
#!/bin/sh
# Exit script on any error
set -e
# Ensure we are in the right directory
cd /var/www/html
# Install dependencies
composer install --no-dev --optimize-autoloader
# Set correct permissions for storage and cache
chown -R www-data:www-data storage bootstrap/cache
chmod -R 775 storage bootstrap/
# Run migrations
php artisan migrate --force
# Start PHP-FPM
php-fpm

0
package.json Normal file → Executable file
View File

0
phpunit.xml Normal file → Executable file
View File

0
public/.htaccess Normal file → Executable file
View File

0
public/favicon.ico Normal file → Executable file
View File

0
public/index.php Normal file → Executable file
View File

0
public/robots.txt Normal file → Executable file
View File

0
resources/css/app.css Normal file → Executable file
View File

0
resources/js/app.js Normal file → Executable file
View File

0
resources/js/bootstrap.js vendored Normal file → Executable file
View File

0
resources/views/welcome.blade.php Normal file → Executable file
View File

0
routes/console.php Normal file → Executable file
View File

0
routes/web.php Normal file → Executable file
View File

0
tests/Feature/ExampleTest.php Normal file → Executable file
View File

0
tests/TestCase.php Normal file → Executable file
View File

0
tests/Unit/ExampleTest.php Normal file → Executable file
View File

0
vite.config.js Normal file → Executable file
View File