Hello,
I have MariaDB installed on the host and connect to it using the following configuration:
network_mode: host
environment:
DB_HOST: host.docker.internal
...
extra_hosts:
- "host.docker.internal:host-gateway"
Does using a database as a container and internal network have a significant impact on speed?
Please share your experiences.
Thank you.
Hello,
Thank you so much for your reply.
The Docker compose is:
services:
# React Frontend
portal-view:
container_name: portal-view
build:
context: /home/portal-view/
dockerfile: Dockerfile
environment:
- NODE_ENV=development
- CHOKIDAR_USEPOLLING="true"
- WATCHPACK_POLLING="true"
- NEXT_TELEMETRY_DISABLED=1
- MAX_OLD_SPACE_SIZE=4096
- GENERATE_SOURCEMAP=false
- INLINE_RUNTIME_CHUNK=false
- USER_ID=${USER_ID:-999}
- GROUP_ID=${GROUP_ID:-995}
user: "${USER_ID:-999}:${GROUP_ID:-995}"
volumes:
- /home/devops/Projects/portal-view:/app
- /app/node_modules
- portal-view-next:/app/.next
ports:
- "127.0.0.1:3000:3000"
deploy:
resources:
limits:
cpus: '4.0'
memory: 4G
# Laravel Backend
portal:
build:
context: /home/portal
dockerfile: Dockerfile
container_name: portal
entrypoint: ["/usr/local/bin/entrypoint.sh"]
command: ["php-fpm"]
network_mode: host
environment:
APP_ENV: local
APP_DEBUG: "true"
DB_HOST: host.docker.internal
DB_PORT: 3306
DB_DATABASE: laravel
DB_USERNAME: root
DB_PASSWORD: 123456
USER_ID: ${USER_ID:-999}
GROUP_ID: ${GROUP_ID:-995}
PORTAL_VIEW_URL: http://127.0.0.1:3000
OPCACHE_ENABLE: 1
OPCACHE_MEMORY_CONSUMPTION: 128
OPCACHE_MAX_ACCELERATED_FILES: 10000
OPCACHE_REVALIDATE_FREQ: 60
volumes:
- /home/portal:/var/www
ports:
- "127.0.0.1:9000:9000"
extra_hosts:
- "host.docker.internal:host-gateway"
deploy:
resources:
limits:
cpus: '4.0'
memory: 4G
volumes:
portal-view-next:
It takes about 10 seconds to load each page of the website. What do you think is the problem? Is there something wrong with the Docker configuration?