I am a beginner in docker . I want to install docker into existing laravel project . The problem is that I want to install grpc for firebase . But , when I install grpc in docker , it’s is taking so many time . So , I’m not sure it is true or not.
Docker File
# Use the official PHP image as the base image
FROM php:8.2-fpm
# Set working directory
WORKDIR /var/www
# Install system dependencies
RUN apt-get update && apt-get install -y
build-essential
libpng-dev
libjpeg62-turbo-dev
libfreetype6-dev
locales
zip
jpegoptim optipng pngquant gifsicle
vim
unzip
git
curl
libzip-dev
libonig-dev
autoconf
zlib1g-dev
libicu-dev
libgrpc-dev
libprotobuf-dev
protobuf-compiler
# Install PHP extensions
RUN docker-php-ext-configure gd --with-freetype --with-jpeg
&& docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath gd zip -j$(nproc)
# Install gRPC
RUN pecl install grpc
&& docker-php-ext-enable grpc
# Install Composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
# Copy existing application directory contents
COPY . /var/www
# Copy existing application directory permissions
COPY --chown=www-data:www-data . /var/www
# Change current user to www
USER www-data
docker-compose.yml
version: '3.9'
services:
api:
container_name: htain-thein
build:
context: .
dockerfile: Dockerfile
working_dir: /var/www
volumes:
- .:/var/www
- ./php/local.ini:/usr/local/etc/php/conf.d/local.ini
environment:
- APP_ENV=local
- APP_DEBUG=true
- DB_CONNECTION=${DB_CONNECTION}
- DB_HOST=${DB_HOST}
- DB_PORT=${DB_PORT}
- DB_DATABASE=${DB_DATABASE}
- DB_USERNAME=${DB_USERNAME}
- DB_PASSWORD=${DB_PASSWORD}
depends_on:
- mysql_db
networks:
- htain-thein-network
web_server:
image: nginx:latest
volumes:
- .:/var/www
- ./nginx/default.conf:/etc/nginx/conf.d/default.conf
ports:
- "8000:80"
depends_on:
- api
networks:
- htain-thein-network
mysql_db:
image: mysql:latest
restart: always
ports:
- "3308:3306"
environment:
- MYSQL_ROOT_PASSWORD=${DB_PASSWORD}
- MYSQL_DATABASE=${DB_DATABASE}
- MYSQL_USER=${DB_USERNAME}
- MYSQL_PASSWORD=${DB_PASSWORD}
volumes:
- mysql_data:/var/lib/mysql
networks:
- htain-thein-network
volumes:
mysql_data:
driver: local
networks:
htain-thein-network:
driver: bridge
nginx.conf
server {
listen 80;
index index.php index.html;
server_name localhost;
root /var/www/public;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ .php$ {
fastcgi_pass api:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /.ht {
deny all;
}
}
Without grpc , docker file installation is fast but when i put grpc in docker installation , it’s taking over 20 min and keep going on .