0
  1. Server: I'm using Ubuntu 18.10 and run magento2.3.1 with Redis, varnish end the elastic search.

    • when clear the cache, ubuntu take only 10-20seconds to reload the page.
    • when running setup:static-content:deploy ubuntu take 50seconds to finish
    • with varnish cache, it takes 1second to reload the page
  2. Docker: I create a docker-compose on my ubuntu server, no volume added

    • when clear the cache, docker take 1-2min to reload the page
    • when running setup:static-content:deploy docker take 300seconds (5min) to finish
    • with varnish cache, it takes 1second the same as Ubuntu Server.

My question is what happens to Docker that take the deploy time so long? I'm thinking of reading/write files speed b/w Docker and Server are different, Docker read/write speed is much slower than ubuntu.

Below are my docker-compose and Dockerfile

docker-compose.yml
version: '3.7'
services:
  web:
    build: ./projectx
    networks:
      - magento_bacth_net
      - 94now_elasticsearch_net
    container_name: magento_bacth_web
    links:
      - db
      - redis
    ports:
      - "8080:80"
    env_file:
      - .env
      - database.env
  redis:
    build: ./redis
    networks:
      - magento_bacth_net
    container_name: magento_bacth_redis
  varnish:
    build: ./varnish
    networks:
      - magento_bacth_net
    container_name: magento_bacth_varnish
    depends_on:
      - web
    ports:
      - "8082:82"
  db:
    image: mysql:5.7.26
    networks:
      - magento_bacth_net
    container_name: magento_bacth_db
    environment:
      - MYSQL_ROOT_PASSWORD=ecomsys
      - MYSQL_USER=ecomsys
      - MYSQL_PASSWORD=ecomsys
      - MYSQL_DATABASE=magento_ecomsys
networks:
  magento_bacth_net:
    name: magento_bacth_net
    ipam:
      driver: default
      config:
        - subnet: "170.10.10.16/29"
  94now_elasticsearch_net:
    external:
      name: 94now_elasticsearch_net

project: Dockerfile
FROM centos:latest

ENV INSTALL_DIR /home/ecommage/public_html
ENV SETUP_FOLDER /home/ecommage/bamboo_setup
ENV COMPOSER_HOME /home/ecommage/.composer/
ENV SSH_HOME /home/ecommage/.ssh/

RUN rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm \
 && rpm -Uvh https://rpms.remirepo.net/enterprise/remi-release-7.rpm

# normal updates
RUN yum -y update

# php && httpd
RUN yum -y install php72 php72-php php72-php-opcache php72-php-bcmath php72-php-cli php72-php-common php72-php-gd php72-php-intl php72-php-json php72-php-mbstring php72-php-pdo php72-php-pdo-dblib php72-php-pear php72-php-pecl-mcrypt php72-php-xmlrpc php72-php-xml php72-php-mysql php72-php-soap php72-php-pecl-zip php72-php-pecl-mongodb php72-php-pecl-xdebug php72-php-pecl-yaml httpd

# tools
RUN yum -y install epel-release iproute at curl crontabs git Redis MySQL htop

RUN curl -O https://dl-ssl.google.com/dl/linux/direct/mod-pagespeed-stable_current_x86_64.rpm \
 && rpm -U mod-pagespeed-*.rpm \
 && yum clean all \
 && php72 -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \
 && php72 composer-setup.php --install-dir=bin --filename=composer \
 && php72 -r "unlink('composer-setup.php');" \
 && rm -rf /etc/localtime \
 && ln -s /usr/share/zoneinfo/Europe/Berlin /etc/localtime \
 && ln -s /bin/php72 /bin/php

#create ecommage user
RUN useradd ecommage
RUN echo "ecommage:ecommage" | chpasswd

# we want some config changes
COPY config/50-php_settings.ini /etc/opt/remi/php72/php.d/
COPY config/v-host.conf /etc/httpd/conf.d/

# create webserver-default directory
RUN mkdir -p ${INSTALL_DIR}
COPY ./Setup ${SETUP_FOLDER}

RUN chown -R ecommage:ecommage /home/ecommage/.

RUN su ecommage -c "mkdir -p ${SSH_HOME}"

COPY ./install-magento /usr/local/bin/install-magento
RUN chmod +x /usr/local/bin/install-magento

COPY ./install-magento-cache /usr/local/bin/install-magento-cache
RUN chmod +x /usr/local/bin/install-magento-cache

COPY ./install-magento-theme /usr/local/bin/install-magento-theme
RUN chmod +x /usr/local/bin/install-magento-theme

COPY ./switch-git-repos /usr/local/bin/switch-git-repos
RUN chmod +x /usr/local/bin/switch-git-repos

#change apache default user to ecommage
RUN sed -i 's/User apache/User ecommage/g' /etc/httpd/conf/httpd.conf
RUN sed -i 's/Group apache/Group ecommage/g' /etc/httpd/conf/httpd.conf

#install modman
RUN curl -SL https://raw.githubusercontent.com/colinmollenhour/modman/master/modman -o modman
RUN mv ./modman /usr/local/bin/modman
RUN chmod +x /usr/local/bin/modman

#give /var/opt/remi/php72/lib/php/session 777 permission
RUN chmod -R 777 /var/opt/remi/php72/lib/php/session

EXPOSE 80

RUN systemctl enable httpd \
 && systemctl enable crond

CMD ["/usr/sbin/init"]
CMD ["/usr/sbin/httpd","-D","FOREGROUND"]
  • Have you tried anyone else's magento 2 docker setup on github? See if it performs the same? Many to choose from. I use something based on this github.com/meanbee/docker-magento2 if still really slow could be docker that's the issue – Dominic Xigen Jul 17 '19 at 19:39
  • I recommend giving Valet+ a try, it is sooo much faster than Vagrant and Docker although it does come with a few problems of it's own but still worth it IMO - github.com/weprovide/valet-plus – Ben Crook Jul 24 '19 at 11:12
0

I found the reason why. There are 2 reasons for this:

  1. Image mysql is using Volume. In my case, to maximize performances, I remove all mounting

  2. Adding opcache in web container:

    [opcache]

    opcache.enable = 1 opcache.revalidate_freq = 0 opcache.validate_timestamps = 0 opcache.max_accelerated_files = 10000 opcache.memory_consumption = 192 opcache.max_wasted_percentage = 10 opcache.interned_strings_buffer = 16

    opcache.fast_shutdown = 1

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.