docker set up added
This commit is contained in:
parent
d49b0ff407
commit
a65f3aeae4
|
@ -0,0 +1,67 @@
|
||||||
|
services:
|
||||||
|
app:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: ./docker/php/Dockerfile
|
||||||
|
container_name: unioil-app
|
||||||
|
restart: unless-stopped
|
||||||
|
volumes:
|
||||||
|
- .:/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", "/var/www/html/docker/php/entrypoint.sh" ]
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "pgrep", "php-fpm"]
|
||||||
|
interval: 30s
|
||||||
|
timeout: 10s
|
||||||
|
retries: 10
|
||||||
|
networks:
|
||||||
|
- app_network
|
||||||
|
|
||||||
|
|
||||||
|
db_mysql:
|
||||||
|
image: mysql:8.2
|
||||||
|
container_name: unioil-db
|
||||||
|
restart: unless-stopped
|
||||||
|
environment:
|
||||||
|
MYSQL_ROOT_PASSWORD: laravel
|
||||||
|
MYSQL_DATABASE: unioil_cms
|
||||||
|
MYSQL_USER: admin_erish
|
||||||
|
MYSQL_PASSWORD: Laravel@123
|
||||||
|
volumes:
|
||||||
|
- mysql-data:/var/lib/mysql
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
|
||||||
|
interval: 30s
|
||||||
|
timeout: 10s
|
||||||
|
retries: 5
|
||||||
|
networks:
|
||||||
|
- app_network
|
||||||
|
|
||||||
|
nginx:
|
||||||
|
image: nginx:alpine
|
||||||
|
container_name: unioil-nginx
|
||||||
|
restart: unless-stopped
|
||||||
|
ports:
|
||||||
|
- "8000:80"
|
||||||
|
volumes:
|
||||||
|
- .:/var/www/html
|
||||||
|
- ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf:ro
|
||||||
|
depends_on:
|
||||||
|
app:
|
||||||
|
condition: service_healthy
|
||||||
|
networks:
|
||||||
|
- app_network
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
mysql-data:
|
||||||
|
storage-volume:
|
||||||
|
driver: local
|
||||||
|
|
||||||
|
networks:
|
||||||
|
app_network:
|
||||||
|
driver: bridge
|
|
@ -0,0 +1,25 @@
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name localhost;
|
||||||
|
|
||||||
|
root /var/www/html/public;
|
||||||
|
index index.php index.html;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
try_files $uri $uri/ /index.php?$query_string;
|
||||||
|
}
|
||||||
|
|
||||||
|
location ~ \.php$ {
|
||||||
|
include fastcgi_params;
|
||||||
|
fastcgi_pass app:9000; # laravel app container
|
||||||
|
fastcgi_index index.php;
|
||||||
|
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
location ~ /\.ht {
|
||||||
|
deny all;
|
||||||
|
}
|
||||||
|
|
||||||
|
error_log /var/log/nginx/error.log;
|
||||||
|
access_log /var/log/nginx/access.log;
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
# Base image
|
||||||
|
FROM php:8.3-fpm-alpine
|
||||||
|
|
||||||
|
# Install required PHP extensions
|
||||||
|
RUN docker-php-ext-install pdo pdo_mysql bcmath
|
||||||
|
|
||||||
|
# Install Composer
|
||||||
|
COPY --from=composer:2.7 /usr/bin/composer /usr/bin/composer
|
||||||
|
|
||||||
|
# Install Node.js and npm
|
||||||
|
RUN apk add --no-cache nodejs npm
|
||||||
|
|
||||||
|
# Set working directory
|
||||||
|
WORKDIR /var/www/html
|
||||||
|
|
||||||
|
# Copy app files
|
||||||
|
COPY . /var/www/html
|
||||||
|
|
||||||
|
# Ensure entrypoint script is executable
|
||||||
|
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 (handled in entrypoint.sh)
|
||||||
|
CMD ["sh", "-c", "/var/www/html/docker/php/entrypoint.sh"]
|
|
@ -0,0 +1,28 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Exit script on any error
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Ensure we're in the right directory
|
||||||
|
cd /var/www/html
|
||||||
|
|
||||||
|
# Install PHP dependencies
|
||||||
|
composer install --no-dev --optimize-autoloader
|
||||||
|
|
||||||
|
# Install Node.js dependencies if node_modules not present
|
||||||
|
if [ ! -d "node_modules" ]; then
|
||||||
|
npm install
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Build frontend assets
|
||||||
|
npm run build
|
||||||
|
|
||||||
|
# Set correct permissions for storage and cache
|
||||||
|
chown -R www-data:www-data storage bootstrap/cache
|
||||||
|
chmod -R 775 storage bootstrap/
|
||||||
|
|
||||||
|
# Run database migrations
|
||||||
|
php artisan migrate --force
|
||||||
|
|
||||||
|
# Start PHP-FPM
|
||||||
|
php-fpm
|
Loading…
Reference in New Issue