Major Configuration
This commit is contained in:
parent
754a9c2821
commit
a74b46ae31
|
@ -1,42 +1,37 @@
|
||||||
services:
|
services:
|
||||||
# Laravel App
|
|
||||||
app:
|
app:
|
||||||
build:
|
build:
|
||||||
context: ./docker/php
|
context: .
|
||||||
dockerfile: Dockerfile
|
dockerfile: ./docker/php/Dockerfile
|
||||||
container_name: laravel-12-docker
|
container_name: laravel-app
|
||||||
restart: always
|
restart: unless-stopped
|
||||||
working_dir: /var/www
|
|
||||||
volumes:
|
volumes:
|
||||||
- .:/var/www
|
- .:/var/www/html
|
||||||
|
- ./storage:/var/www/html/storage
|
||||||
|
- ./bootstrap/cache:/var/www/html/bootstrap/cache
|
||||||
depends_on:
|
depends_on:
|
||||||
db_mysql:
|
db_mysql:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
command: >
|
command:
|
||||||
sh -c "
|
[ "sh", "-c", "/var/www/html/docker/php/entrypoint.sh" ]
|
||||||
while ! nc -z db_mysql 3306; do
|
|
||||||
sleep 2;
|
|
||||||
done;
|
|
||||||
php artisan migrate --force && php-fpm"
|
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD", "sh", "-c", "pgrep php-fpm"]
|
test: ["CMD", "pgrep", "php-fpm"]
|
||||||
interval: 30s
|
interval: 30s
|
||||||
timeout: 10s
|
timeout: 10s
|
||||||
retries: 10
|
retries: 5
|
||||||
networks:
|
networks:
|
||||||
- app_network
|
- app_network
|
||||||
|
|
||||||
# MySQL
|
|
||||||
db_mysql:
|
db_mysql:
|
||||||
image: mysql:8.2
|
image: mysql:8.2
|
||||||
container_name: mysql-db
|
container_name: db_mysql
|
||||||
restart: always
|
restart: unless-stopped
|
||||||
environment:
|
environment:
|
||||||
MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD}
|
MYSQL_ROOT_PASSWORD: laravel
|
||||||
MYSQL_DATABASE: ${DB_DATABASE}
|
MYSQL_DATABASE: laravel-docker
|
||||||
MYSQL_PASSWORD: ${DB_PASSWORD}
|
MYSQL_USER: laravel
|
||||||
ports:
|
MYSQL_PASSWORD: laravel12
|
||||||
- ${DB_PORT}:3306
|
|
||||||
volumes:
|
volumes:
|
||||||
- mysql-data:/var/lib/mysql
|
- mysql-data:/var/lib/mysql
|
||||||
healthcheck:
|
healthcheck:
|
||||||
|
@ -47,44 +42,25 @@ services:
|
||||||
networks:
|
networks:
|
||||||
- app_network
|
- app_network
|
||||||
|
|
||||||
# Phpmyadmin
|
nginx:
|
||||||
phpmyadmin:
|
image: nginx:alpine
|
||||||
image: phpmyadmin/phpmyadmin
|
container_name: nginx
|
||||||
container_name: phpmyadmin
|
restart: unless-stopped
|
||||||
restart: always
|
|
||||||
ports:
|
ports:
|
||||||
- "8080:80"
|
- "80: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"
|
|
||||||
volumes:
|
volumes:
|
||||||
- .:/var/www
|
- .:/var/www/html
|
||||||
- ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf:ro
|
- ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf:ro
|
||||||
depends_on:
|
depends_on:
|
||||||
app:
|
app:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
healthcheck:
|
|
||||||
test: ["CMD", "curl", "-f", "http://localhost"]
|
|
||||||
interval: 30s
|
|
||||||
timeout: 10s
|
|
||||||
retries: 5
|
|
||||||
networks:
|
networks:
|
||||||
- app_network
|
- app_network
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
mysql-data:
|
mysql-data:
|
||||||
|
storage-volume:
|
||||||
|
driver: local
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
app_network:
|
app_network:
|
||||||
|
|
|
@ -2,8 +2,7 @@ server {
|
||||||
listen 80;
|
listen 80;
|
||||||
server_name localhost;
|
server_name localhost;
|
||||||
|
|
||||||
root /var/www/public;
|
root /var/www/html/public;
|
||||||
|
|
||||||
index index.php index.html;
|
index index.php index.html;
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
|
@ -24,4 +23,3 @@ server {
|
||||||
error_log /var/log/nginx/error.log;
|
error_log /var/log/nginx/error.log;
|
||||||
access_log /var/log/nginx/access.log;
|
access_log /var/log/nginx/access.log;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,16 +8,19 @@ RUN docker-php-ext-install pdo pdo_mysql bcmath
|
||||||
COPY --from=composer:2.7 /usr/bin/composer /usr/bin/composer
|
COPY --from=composer:2.7 /usr/bin/composer /usr/bin/composer
|
||||||
|
|
||||||
# Set working directory
|
# Set working directory
|
||||||
WORKDIR /var/www
|
WORKDIR /var/www/html
|
||||||
|
|
||||||
# Copy app files
|
# Copy app files
|
||||||
COPY . /var/www
|
COPY . /var/www/html
|
||||||
|
|
||||||
# Set permissions
|
# Ensure entrypoint script is
|
||||||
RUN chown -R www-data:www-data /var/www
|
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 PHP-FPM port
|
||||||
EXPOSE 9000
|
EXPOSE 9000
|
||||||
|
|
||||||
# Start PHP-FPM
|
# Start PHP-FPM (Handled in entrypoint.sh)
|
||||||
CMD ["php-fpm"]
|
CMD ["sh", "-c", "/var/www/html/docker/php/entrypoint.sh"]
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue