chore: docker compose
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (push) Has been cancelled

This commit is contained in:
2025-10-27 15:53:58 +05:45
parent eba9e5f182
commit f92727fad4
4 changed files with 110 additions and 37 deletions

View File

@@ -1,22 +1,40 @@
FROM php:8.2-fpm 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 # Set working directory
WORKDIR /var/www 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 . . COPY . .
# Install Laravel dependencies # Copy existing application directory permissions
RUN composer install --no-dev --optimize-autoloader COPY --chown=www-data:www-data . /var/www
# Give permission # Change current user to www-data
RUN chown -R www-data:www-data /var/www \ USER www-data
&& chmod -R 755 /var/www/storage /var/www/bootstrap/cache
# Expose port 9000 and start php-fpm server
EXPOSE 9000
CMD ["php-fpm"]

View File

@@ -5,45 +5,76 @@ services:
build: build:
context: . context: .
dockerfile: Dockerfile dockerfile: Dockerfile
image: laravel-app image: laravel-react-app
container_name: laravel-app container_name: laravel_app
restart: unless-stopped restart: unless-stopped
working_dir: /var/www working_dir: /var/www
volumes: volumes:
- .:/var/www - ./:/var/www
- ./docker/php/php.ini:/usr/local/etc/php/conf.d/php.ini
networks: networks:
- laravel - laravel-react-network
webserver: webserver:
image: nginx:alpine image: nginx:alpine
container_name: laravel-webserver container_name: nginx_server
restart: unless-stopped restart: unless-stopped
ports: ports:
- '8080:80' - '8000:80'
volumes: volumes:
- .:/var/www - ./:/var/www
- ./docker/nginx/conf.d:/etc/nginx/conf.d - ./docker/nginx/conf.d/:/etc/nginx/conf.d/
networks: networks:
- laravel - laravel-react-network
depends_on:
- app
db: db:
image: mysql:8.0 image: mysql:8.0
container_name: laravel-db container_name: mysql_db
restart: unless-stopped restart: unless-stopped
environment: environment:
MYSQL_DATABASE: soorya MYSQL_DATABASE: ${DB_DATABASE}
MYSQL_ROOT_PASSWORD: root MYSQL_ROOT_PASSWORD: ${DB_PASSWORD}
MYSQL_USER: laravel MYSQL_PASSWORD: ${DB_PASSWORD}
MYSQL_PASSWORD: laravel MYSQL_USER: ${DB_USERNAME}
SERVICE_TAGS: dev
SERVICE_NAME: mysql
volumes: volumes:
- dbdata:/var/lib/mysql - dbdata:/var/lib/mysql
- ./docker/mysql/my.cnf:/etc/mysql/conf.d/my.cnf
ports: ports:
- '3306:3306' - '3306:3306'
networks: networks:
- laravel - laravel-react-network
node:
image: node:18-alpine
container_name: node_build
working_dir: /var/www
volumes:
- ./:/var/www
ports:
- '3000:3000'
networks: networks:
laravel: - 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: volumes:
dbdata: dbdata:
driver: local
networks:
laravel-react-network:
driver: bridge

View File

@@ -1,23 +1,26 @@
server { server {
listen 80; listen 80;
index index.php index.html;
server_name localhost; server_name localhost;
root /var/www/public; root /var/www/public;
index index.php index.html;
location / { location / {
try_files $uri $uri/ /index.php?$query_string; try_files $uri $uri/ /index.php?$query_string;
} }
location ~ \.php$ { location ~ \.php$ {
include fastcgi_params;
fastcgi_pass app:9000; fastcgi_pass app:9000;
fastcgi_index index.php; fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info; include fastcgi_params;
} }
location ~ /\.ht { location ~ /\.ht {
deny all; deny all;
} }
# For React development server proxy (if needed)
location /api/ {
try_files $uri $uri/ /index.php?$query_string;
}
} }

21
setup.sh Normal file
View 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."