I have an app that laravel app that can generate excel file. The performance of excel generation was much slower in docker container. I am using laravel excel for generating the excel file.
# For more information: https://laravel.com/docs/sail
services:
mysql:
image: 'mysql:8.0'
ports:
- '3306:3306'
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
volumes:
- 'mysql:/var/lib/mysql'
networks:
- otonometer
zipkin:
image: openzipkin/zipkin:latest
ports:
- '9411:9411'
networks:
- otonometer
otonometer:
build:
context: .
dockerfile: Dockerfile
develop:
watch:
- action: sync+restart
path: ./nginx/otonometer.com.conf
target: /etc/nginx/sites-available/otonometer.com.conf
- action: sync+restart
path: ./nginx/nginx.conf
target: /etc/nginx/nginx.conf
- action: sync
path: ./
target: ./var/www/webcore_app
ignore: [./nginx, ./php, ./mysql]
ports:
- "${APP_PORT:-80}:80"
environment:
- OTP_URL=zipkin
- OTP_PORT=9411
depends_on:
- mysql
- zipkin
networks:
- otonometer
networks:
otonometer:
driver: bridge
volumes:
mysql:
This is my docker-compose.yml file. And this is my Dockerfile
# Use the official PHP image as the base image
FROM php:8.1.0-fpm
# Set the working directory
WORKDIR /var/www/webcore_app
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
## View files
RUN ls -la
## Install dependencies
RUN apt-get clean
RUN apt-get update -yqq &&
apt-get install -y nginx &&
apt-get clean &&
rm -rf /var/lib/apt/lists/*
# Update package manager and install dependencies for PHP extensions
RUN apt-get update && apt-get install -y
libfreetype6-dev
libjpeg62-turbo-dev
libpng-dev
libicu-dev
libbz2-dev
libxml2-dev
libzip-dev
zip
unzip
mariadb-client
&& docker-php-ext-configure gd --with-freetype --with-jpeg
&& docker-php-ext-install -j$(nproc) pdo_mysql zip bcmath pcntl exif gd intl opcache xml bz2
# Clean up to reduce the image size
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
# Copy the Laravel project files into the container
COPY composer.json composer.lock ./
# Install Laravel dependencies using Composer
RUN composer install --no-scripts --no-autoloader
# Copy the rest of the Laravel project files into the container
COPY . .
# Set the correct permissions for the storage and cache directories
RUN chown -R www-data:www-data /var/www/webcore_app/storage /var/www/webcore_app/bootstrap/cache
RUN chmod -R 775 /var/www/webcore_app/storage /var/www/webcore_app/bootstrap/cache
# Now run autoloader optimization
RUN composer dump-autoload --optimize
# Copy and configure Nginx
COPY ./nginx/otonometer.com.conf /etc/nginx/sites-available/otonometer.com.conf
COPY ./nginx/nginx.conf /etc/nginx/nginx.conf
ADD ./php/php.ini /usr/local/etc/php/conf.d
RUN ln -s /etc/nginx/sites-available/otonometer.com.conf /etc/nginx/sites-enabled
RUN nginx -t
EXPOSE 80
# Start Nginx and PHP-FPM
CMD ["sh", "-c", "service nginx start && php-fpm"]
I have suspissions on whether there are some volume attached/mounted to my local host, because i just known that if my app is mounted to host machine it will make performance much slower. But when i look at mount and volumne page on docker console, there were no volume and mount attached. Maybe some one can help me, i am new at docker.
2