Mysql 来自docker容器的BrowserSync不';行不通
我无法从容器运行browsersync。请告诉我怎么做才对。 我使用docker composer构建了nginx、php和mysql容器Mysql 来自docker容器的BrowserSync不';行不通,mysql,reactjs,laravel,nginx,docker-compose,Mysql,Reactjs,Laravel,Nginx,Docker Compose,我无法从容器运行browsersync。请告诉我怎么做才对。 我使用docker composer构建了nginx、php和mysql容器 version: "3" services: nginx: image: nginx:alpine container_name: nginx_container restart: unless-stopped tty: true ports: - ${NGINX_PORT}:8
version: "3"
services:
nginx:
image: nginx:alpine
container_name: nginx_container
restart: unless-stopped
tty: true
ports:
- ${NGINX_PORT}:80
volumes:
- ${APP_PATH_HOST}:${APP_PATH_CONTAINER}
- ./docker/nginx/conf.d/:/etc/nginx/conf.d
php:
build:
context: .
dockerfile: ./docker/php/Php.Dockerfile
container_name: php_container
restart: unless-stopped
tty: true
working_dir: ${APP_PATH_CONTAINER}
volumes:
- ${APP_PATH_HOST}:${APP_PATH_CONTAINER}
- ./docker/php/php.ini:/usr/local/etc/php/conf.d/local.ini
db:
image: mysql:5.7
container_name: mysql_container
restart: unless-stopped
ports:
- ${MYSQL_PORT}:3306
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
MYSQL_DATABASE: ${MYSQL_DATABASE}
volumes:
- ${DB_PATH_HOST}:/var/lib/mysql
- ./docker/mysql/conf/my.cnf:/etc/mysql/my.cnf
phpmyadmin:
image: phpmyadmin/phpmyadmin
container_name: phpmyadmin_container
restart: always
links:
- db:db
ports:
- ${PHPMYADMIN_PORT}:80
depends_on:
- db
在容器内部,我使用composer安装了laravel,然后将laravel更改为带有react的捆绑包,并在容器中安装了node_模块。一切似乎都很好。接下来,我做docker撰写
。正在设置browsersync
mix.browserSync({
proxy: "localhost:7777",
notify: false,
browser: "firefox"
});
运行npm运行监视后。终端显示:
[Browsersync] Proxying: http://localhost:7777
[Browsersync] Access URLs:
-------------------------------------
Local: http://localhost:3000
External: http://192.168.32.5:3000
-------------------------------------
UI: http://localhost:3001
UI External: http://localhost:3001
-------------------------------------
[Browsersync] Watching files...
[Browsersync] Couldn't open browser (if you are using BrowserSync in a headless environment, you might want to set the open option to false)
地址本地:http://localhost:3000
和本地:http://localhost:3001
系统不工作。
我不知道如何让它工作。请告诉我。
我的nginx.conf
文件:
server {
listen 80;
index index.php index.html;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
root /var/www/public/;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
location / {
try_files $uri $uri/ /index.php?$query_string;
}
}
#PATHS
DB_PATH_HOST=./docker/mysql/database
APP_PATH_HOST=./src
APP_PATH_CONTAINER=/var/www/
#PORTS
NGINX_PORT=7777
MYSQL_PORT=33061
PHPMYADMIN_PORT=8765
#MySQL
MYSQL_ROOT_PASSWORD=123456
MYSQL_DATABASE=laravel
我的dockerfile
:
FROM php:7.3-fpm
WORKDIR /var/www/
# Install dependencies
RUN apt-get update && apt-get install -y \
build-essential \
libpng-dev \
libjpeg62-turbo-dev \
libfreetype6-dev \
locales \
zip \
libzip-dev \
jpegoptim optipng pngquant gifsicle \
vim \
unzip \
git \
curl
RUN apt-get clean && rm -rf /var/lib/apt/lists/\*
# Install extensions
RUN docker-php-ext-install pdo_mysql zip exif pcntl
RUN docker-php-ext-configure gd --with-gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ --with-png-dir=/usr/include/
RUN docker-php-ext-install gd
# Install composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
# Install Node.js
RUN curl -s https://deb.nodesource.com/setup_12.x | bash - && \
apt-get install -y nodejs
# Add user for laravel application
RUN groupadd -g 1000 www
RUN useradd -u 1000 -ms /bin/bash -g www www
# Copy existing application directory permissions
COPY --chown=www:www . /var/www
# Change current user to www-data
USER www
EXPOSE 9000
CMD ["php-fpm"]
我的.env
文件:
server {
listen 80;
index index.php index.html;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
root /var/www/public/;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
location / {
try_files $uri $uri/ /index.php?$query_string;
}
}
#PATHS
DB_PATH_HOST=./docker/mysql/database
APP_PATH_HOST=./src
APP_PATH_CONTAINER=/var/www/
#PORTS
NGINX_PORT=7777
MYSQL_PORT=33061
PHPMYADMIN_PORT=8765
#MySQL
MYSQL_ROOT_PASSWORD=123456
MYSQL_DATABASE=laravel