I'm new at Docker and I'm facing a problem.
I've mounted a BE with Laravel 10 in a docker container, without sail, with php 8.1. I've also, in my docker compose, two FE in Vue.
Here the interesting parts:
Dockerfile
FROM php:8.1-apache
RUN docker-php-ext-install opcache pdo_mysql \
&& docker-php-ext-enable opcache
COPY opcache.ini /usr/local/etc/php/conf.d/opcache.ini
RUN a2enmod rewrite \
&& sed -i 's!/var/www/html!/var/www/html/public!g' /etc/apache2/sites-available/000-default.conf
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
COPY . /var/www/html/
WORKDIR /var/www/html
RUN composer install --no-interaction --prefer-dist --optimize-autoloader
RUN chown -R www-data:www-data /var/www/html/storage \
&& chown -R www-data:www-data /var/www/html/bootstrap/cache
EXPOSE 80
docker-compose.yml
...
services:
api:
build:
context: ./api
container_name: api
restart: unless-stopped
ports:
- "8000:80"
environment:
APP_URL: http://localhost:8000
DB_HOST: db
DB_PORT: 3306
DB_USERNAME: ****
DB_PASSWORD: ****
DB_DATABASE: ****
SANCTUM_STATEFUL_DOMAINS: localhost,localhost:8080,localhost:8081
volumes:
- backend_data:/var/www/html
networks:
- app-network
depends_on:
- db
...
networks:
app-network:
driver: bridge
volumes:
db-api:
backend_data:
driver: local
driver_opts:
type: none
device: ./api
o: bind
Everythings works fine but the backend is too slow (about 4/5 second per api call). I've notice that if I don't mount the volume and acceed the file directly in the containers, it is fast as normal (less than 100ms per call).
What am I doing wrong?
I've tried mounting a custom volume for datas, changing the path of the mounted volume, using php-fpm in Dockerfile
Got it :')
as sad by UnderDog in comments, I've installed WSL, placed my files under /home/user/whatever
and runned docker from there.