I am working on a quizz app. I have installed the Laravel app on docker and when I started working on the app I noticed that it takes very long for the app to load. It takes ~7-8s to load a page with a form which have 5 inputs.
I know that this waiting time is very long because a few weeks ago I installed a laravel application on docker that moves very quickly. But I can no longer use that one. I think it is possible that it is due to the .yml
file and the Dockerfile
, but I don’t know what the installation problems would be.
I can not disable the Use the WSL 2 based engine (Windows Home can only run the WSL 2 backend)
from Docker UI because I run W10 Home.
docker-compose.yml
version: '3'
services:
mariadb:
image: mariadb
restart: always
ports:
- 3375:3306
environment:
TZ: "Europe/Bucharest"
MARIADB_ALLOW_EMPTY_PASSWORD: "no"
MARIADB_ROOT_PASSWORD: "user@pass"
MARIADB_ROOT_HOST: "%"
MARIADB_USER: 'user'
MARIADB_PASSWORD: 'pass'
MARIADB_DATABASE: 'db'
networks:
- sail
volumes:
- ./docker-config/server_bd:/var/lib/mysql
app:
build: ./docker-config
container_name: app
ports:
- 8000:80
- 4430:443
volumes:
- "./:/var/www/html"
tty: true
networks:
- sail
links:
- mariadb
depends_on:
- mariadb
phpmyadmin:
image: phpmyadmin/phpmyadmin
restart: always
networks:
- sail
links:
- "mariadb:db"
depends_on:
- mariadb
environment:
UPLOAD_LIMIT: 1024M
ports:
- 3971:80
networks:
sail:
driver: bridge
volumes:
data:
driver: local
Dockerfile
FROM ubuntu:20.04
EXPOSE 80
WORKDIR /var/www/html
ENV DEBIAN_FRONTEND noninteractive
ENV TZ=Europe/Bucharest
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN apt-get update -y
RUN apt-get upgrade -y
RUN apt install -y lsb-release
RUN apt-get clean all
RUN apt-get install ca-certificates apt-transport-https -y
RUN apt-get install software-properties-common -y
# Apache Server
RUN apt-get -y install apache2
RUN a2enmod rewrite
RUN service apache2 restart
# SETUP SSL
RUN echo "ServerName localhost" >> /etc/apache2/apache2.conf &&
a2enmod rewrite &&
a2enmod ssl
COPY cert/certificate.crt /etc/ssl/certificate.crt
COPY cert/private.key /etc/ssl/private.key
COPY cert/ca_bundle.crt /etc/ssl/ca_bundle.crt
COPY 000-default.conf /etc/apache2/sites-available/000-default.conf
RUN service apache2 restart
RUN apt-get install -y wget
RUN apt-get install nano
RUN apt-get update -y
RUN apt-get install -y apt-transport-https
# PHP8
RUN add-apt-repository ppa:ondrej/php
RUN apt-get install -y php8.1
RUN apt-get install -y php8.1-fpm
RUN apt-get install -y libapache2-mod-php
RUN apt-get install -y libapache2-mod-fcgid
RUN apt-get install -y curl
RUN apt-get install -y php-curl
RUN apt-get install -y php-dev
RUN apt-get install -y php-gd
RUN apt-get install -y php-mbstring
RUN apt-get install -y php-zip
RUN apt-get install -y php-xml
RUN apt-get install -y php-soap
RUN apt-get install -y php-common
RUN apt-get install -y php-tokenizer
RUN apt-get install -y unzip
RUN apt-get install -y php-bcmath
RUN apt-get install -y php-mysql
# Install npm
RUN apt-get install -y npm
RUN npm cache clean -f
RUN npm install -g n
RUN n stable
RUN service apache2 restart
# COMPOSER
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
RUN echo " extension = php_mysqli.so" >> /etc/php/8.1/apache2/php.ini
RUN service apache2 restart
CMD ( cron -f -l 8 & ) && apachectl -D FOREGROUND
The DB is working fine, at a good speed.
The laptop power is not an issue because on the last app everything was running smooth and with no problems.
2
Answers
So I noticed that in WSL2 it is the filesystem which is an issue. If your project is on a folder in the Windows file system it will run much more slower than if you put the entire project into the Linux file system. Try moving your project into the linux system and see if it speeds it up.
For example, if your project is located in a windows folder like
Move it to the linux filesystem under WSL2 to something like:
After you have done this – rebuild the container from the new location.
Update
In case your project is in the folder
D:Quizzology-App
then you need to copy it to the WSL2 Linux file system.To do this try the following:
cd ~
to go to the home directory of the linux file system.mkdir Projects
will make the folderProjects
cd Projects
cp -R /mnt/d/Quizzology-App ./Quizzology-App/
cd Quizzology-App
and then rebuild the container from here.-bash: ./vendor/bin/sail: Permission denied in my project this is the result after do this.
how fix?