chore: docker compose
This commit is contained in:
46
Dockerfile
46
Dockerfile
@@ -1,22 +1,40 @@
|
||||
FROM php:8.2-fpm
|
||||
|
||||
# Install system dependencies
|
||||
RUN apt-get update && apt-get install -y \
|
||||
git curl zip unzip libpng-dev libonig-dev libxml2-dev libzip-dev \
|
||||
&& docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath gd zip
|
||||
|
||||
# Install Composer
|
||||
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
|
||||
|
||||
# Set working directory
|
||||
WORKDIR /var/www
|
||||
|
||||
# Copy existing application code
|
||||
# Install system dependencies
|
||||
RUN apt-get update && apt-get install -y \
|
||||
git \
|
||||
curl \
|
||||
libpng-dev \
|
||||
libonig-dev \
|
||||
libxml2-dev \
|
||||
zip \
|
||||
unzip \
|
||||
nodejs \
|
||||
npm \
|
||||
libzip-dev \
|
||||
default-mysql-client
|
||||
|
||||
# Clear cache
|
||||
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Install PHP extensions
|
||||
RUN docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath gd zip
|
||||
|
||||
# Get latest Composer
|
||||
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
|
||||
|
||||
# Copy existing application directory contents
|
||||
COPY . .
|
||||
|
||||
# Install Laravel dependencies
|
||||
RUN composer install --no-dev --optimize-autoloader
|
||||
# Copy existing application directory permissions
|
||||
COPY --chown=www-data:www-data . /var/www
|
||||
|
||||
# Give permission
|
||||
RUN chown -R www-data:www-data /var/www \
|
||||
&& chmod -R 755 /var/www/storage /var/www/bootstrap/cache
|
||||
# Change current user to www-data
|
||||
USER www-data
|
||||
|
||||
# Expose port 9000 and start php-fpm server
|
||||
EXPOSE 9000
|
||||
CMD ["php-fpm"]
|
||||
@@ -5,45 +5,76 @@ services:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
image: laravel-app
|
||||
container_name: laravel-app
|
||||
image: laravel-react-app
|
||||
container_name: laravel_app
|
||||
restart: unless-stopped
|
||||
working_dir: /var/www
|
||||
volumes:
|
||||
- .:/var/www
|
||||
- ./:/var/www
|
||||
- ./docker/php/php.ini:/usr/local/etc/php/conf.d/php.ini
|
||||
networks:
|
||||
- laravel
|
||||
- laravel-react-network
|
||||
|
||||
webserver:
|
||||
image: nginx:alpine
|
||||
container_name: laravel-webserver
|
||||
container_name: nginx_server
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- '8080:80'
|
||||
- '8000:80'
|
||||
volumes:
|
||||
- .:/var/www
|
||||
- ./docker/nginx/conf.d:/etc/nginx/conf.d
|
||||
- ./:/var/www
|
||||
- ./docker/nginx/conf.d/:/etc/nginx/conf.d/
|
||||
networks:
|
||||
- laravel
|
||||
- laravel-react-network
|
||||
depends_on:
|
||||
- app
|
||||
|
||||
db:
|
||||
image: mysql:8.0
|
||||
container_name: laravel-db
|
||||
container_name: mysql_db
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
MYSQL_DATABASE: soorya
|
||||
MYSQL_ROOT_PASSWORD: root
|
||||
MYSQL_USER: laravel
|
||||
MYSQL_PASSWORD: laravel
|
||||
MYSQL_DATABASE: ${DB_DATABASE}
|
||||
MYSQL_ROOT_PASSWORD: ${DB_PASSWORD}
|
||||
MYSQL_PASSWORD: ${DB_PASSWORD}
|
||||
MYSQL_USER: ${DB_USERNAME}
|
||||
SERVICE_TAGS: dev
|
||||
SERVICE_NAME: mysql
|
||||
volumes:
|
||||
- dbdata:/var/lib/mysql
|
||||
- ./docker/mysql/my.cnf:/etc/mysql/conf.d/my.cnf
|
||||
ports:
|
||||
- '3306:3306'
|
||||
networks:
|
||||
- laravel
|
||||
- laravel-react-network
|
||||
|
||||
networks:
|
||||
laravel:
|
||||
node:
|
||||
image: node:18-alpine
|
||||
container_name: node_build
|
||||
working_dir: /var/www
|
||||
volumes:
|
||||
- ./:/var/www
|
||||
ports:
|
||||
- '3000:3000'
|
||||
networks:
|
||||
- laravel-react-network
|
||||
depends_on:
|
||||
- app
|
||||
tty: true
|
||||
stdin_open: true
|
||||
|
||||
redis:
|
||||
image: redis:alpine
|
||||
container_name: redis_cache
|
||||
ports:
|
||||
- '6379:6379'
|
||||
networks:
|
||||
- laravel-react-network
|
||||
|
||||
volumes:
|
||||
dbdata:
|
||||
driver: local
|
||||
|
||||
networks:
|
||||
laravel-react-network:
|
||||
driver: bridge
|
||||
|
||||
@@ -1,23 +1,26 @@
|
||||
server {
|
||||
listen 80;
|
||||
index index.php index.html;
|
||||
server_name localhost;
|
||||
|
||||
root /var/www/public;
|
||||
index index.php index.html;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.php?$query_string;
|
||||
}
|
||||
|
||||
location ~ \.php$ {
|
||||
include fastcgi_params;
|
||||
fastcgi_pass app:9000;
|
||||
fastcgi_index index.php;
|
||||
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
|
||||
fastcgi_param PATH_INFO $fastcgi_path_info;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
include fastcgi_params;
|
||||
}
|
||||
|
||||
location ~ /\.ht {
|
||||
deny all;
|
||||
}
|
||||
}
|
||||
|
||||
# For React development server proxy (if needed)
|
||||
location /api/ {
|
||||
try_files $uri $uri/ /index.php?$query_string;
|
||||
}
|
||||
}
|
||||
21
setup.sh
Normal file
21
setup.sh
Normal file
@@ -0,0 +1,21 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copy environment file
|
||||
cp .env.example .env
|
||||
|
||||
# Install PHP dependencies
|
||||
docker-compose run --rm composer install
|
||||
|
||||
# Generate application key
|
||||
docker-compose run --rm php artisan key:generate
|
||||
|
||||
# Run migrations
|
||||
docker-compose run --rm php artisan migrate
|
||||
|
||||
# Install Node.js dependencies
|
||||
docker-compose run --rm npm install
|
||||
|
||||
# Build frontend assets
|
||||
docker-compose run --rm npm run build
|
||||
|
||||
echo "Setup complete! Run 'docker-compose up -d' to start the application."
|
||||
Reference in New Issue
Block a user