0

I was using a docker container with php:8.1.6-cli and running my laravel aplication. When i attach the terminal to the container and run a simple command php artisan inspire the docker takes 8 seconds to execute. enter image description here

My php.ini config:

file_uploads = On
allow_url_fopen = On
memory_limit = 256M
upload_max_filesize = 100M
max_execution_time = 360
date.timezone = America/Sao_Paulo

My Dockerfile for this container:

FROM php:8.1.6-cli

LABEL maintainer="Crazynds"

WORKDIR /workspace

ENV DEBIAN_FRONTEND noninteractive
ENV TZ=UTC-3
ENV NODE_VERSION=16

USER root

RUN apt-get update \
    && apt-get install -y libcurl4-openssl-dev libonig-dev libzip-dev libpq-dev build-essential gnupg gosu curl zip unzip git supervisor libcap2-bin libpng-dev python2 locales \
    && mkdir -p ~/.gnupg \
    && chmod 600 ~/.gnupg

RUN php -r "readfile('http://getcomposer.org/installer');" | php -- --install-dir=/usr/bin/ --filename=composer \
    && curl -sL https://deb.nodesource.com/setup_$NODE_VERSION.x | bash - 

RUN apt-get install -y nodejs nano wget dos2unix

RUN apt-get -y autoremove \
    && apt-get clean\
    && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

RUN pecl install redis && docker-php-ext-enable redis; exit 0
RUN docker-php-ext-install pdo_mysql pdo_pgsql mbstring exif pcntl curl zip gd


ENTRYPOINT ["sleep","infinity"]

How i find the problem that takes most of the time to execute the php comands? Is there any way to check what is consuming each part of time in the execution?

1 Answer 1

1

I find the solution. The docker with volumes mounted using Windows dirs are slow.

The solution for my problem is to create the vendor folder and the node_modules in separated volumes, instead of mounting them from Windows folder.

That alone gave a big performance boost, now the response time is around 1 second, but if I mounted my entire project on the volume instead of a folder, it would be much faster.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.