pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

    <small id='i4MEk'></small><noframes id='i4MEk'>

    1. <i id='i4MEk'><tr id='i4MEk'><dt id='i4MEk'><q id='i4MEk'><span id='i4MEk'><b id='i4MEk'><form id='i4MEk'><ins id='i4MEk'></ins><ul id='i4MEk'></ul><sub id='i4MEk'></sub></form><legend id='i4MEk'></legend><bdo id='i4MEk'><pre id='i4MEk'><center id='i4MEk'></center></pre></bdo></b><th id='i4MEk'></th></span></q></dt></tr></i><div class="7z7tvrn" id='i4MEk'><tfoot id='i4MEk'></tfoot><dl id='i4MEk'><fieldset id='i4MEk'></fieldset></dl></div>
    2. <legend id='i4MEk'><style id='i4MEk'><dir id='i4MEk'><q id='i4MEk'></q></dir></style></legend>
      <tfoot id='i4MEk'></tfoot>
        <bdo id='i4MEk'></bdo><ul id='i4MEk'></ul>

    3. Docker 容器中的 Browsersync

      Browsersync within a Docker container(Docker 容器中的 Browsersync)
    4. <legend id='qgh6B'><style id='qgh6B'><dir id='qgh6B'><q id='qgh6B'></q></dir></style></legend>
        <tbody id='qgh6B'></tbody>

          <bdo id='qgh6B'></bdo><ul id='qgh6B'></ul>
        • <tfoot id='qgh6B'></tfoot>

                <small id='qgh6B'></small><noframes id='qgh6B'>

                <i id='qgh6B'><tr id='qgh6B'><dt id='qgh6B'><q id='qgh6B'><span id='qgh6B'><b id='qgh6B'><form id='qgh6B'><ins id='qgh6B'></ins><ul id='qgh6B'></ul><sub id='qgh6B'></sub></form><legend id='qgh6B'></legend><bdo id='qgh6B'><pre id='qgh6B'><center id='qgh6B'></center></pre></bdo></b><th id='qgh6B'></th></span></q></dt></tr></i><div class="dbjpjrv" id='qgh6B'><tfoot id='qgh6B'></tfoot><dl id='qgh6B'><fieldset id='qgh6B'></fieldset></dl></div>
                本文介紹了Docker 容器中的 Browsersync的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                限時送ChatGPT賬號..

                我有一個 Wordpress/MySQL docker 容器,用于開發主題和插件.我在 localhost:8000 上訪問它.

                I've got a Wordpress/MySQL docker container, which I use for developing themes & plugins. I access this on localhost:8000.

                它使用 Gulp 構建過程 &我正在嘗試將 browsersync 添加到組合中.我很難讓 browsersync 真正代理出容器.從 Gulp 輸出中,我可以看到它生成了更改,實際上并沒有在瀏覽器中進行任何更改.

                It uses a Gulp build process & I am trying to add browsersync to the mix. I'm having a hard time getting the browsersync to actually proxy out of the container. From the Gulp output I can see that its generating the changes, just not actually making any changes in the browser.

                這是我的 docker-compose.yml、gulpfile、dockerfile 和外殼腳本.

                Heres my docker-compose.yml, gulpfile, dockerfile & shell script.

                version: '2'
                
                services:
                    wordpress_db:
                        image: mariadb
                        restart: 'always'
                        ports:
                            - 3360:3306
                        volumes:
                            - ./db_data:/docker-entrypoint-initdb.d
                        environment:
                            MYSQL_ROOT_PASSWORD: wordpress
                            MYSQL_DATABASE: wordpress
                
                    wordpress:
                        depends_on:
                            - wordpress_db
                        image: wordpress
                        restart: 'always'
                        environment:
                            WORDPRESS_DB_NAME: wordpress
                            WORDPRESS_DB_USER: root
                            WORDPRESS_DB_PASSWORD: wordpress
                        ports:
                            - 8000:3000
                        volumes:
                            - ./uploads:/var/www/html/wp-content/uploads
                            - ./plugins:/var/www/html/wp-content/plugins
                            - ./theme:/var/www/html/wp-content/themes/theme
                        links:
                            - wordpress_db:mysql
                
                    composer:
                        image: composer/composer:php7
                        depends_on:
                            - wordpress
                        restart: 'no'
                        environment:
                            ACF_PRO_KEY: this_would_be_my_ACF_pro_key_:)
                        volumes_from:
                            - wordpress
                        working_dir: /var/www/html/wp-content/themes/theme
                        command: install
                
                    node:
                        restart: 'no'
                        image: node:slim
                        depends_on:
                            - wordpress
                        volumes_from:
                            - wordpress
                        working_dir: /var/www/html/wp-content/themes/theme
                        build:
                            context: .
                            dockerfile: WordpressBuild
                            args:
                                - SITE_VERSION=0.0.1
                

                var browserSync  = require('browser-sync');
                var reload      = browserSync.reload;
                var watchify     = require('watchify');
                var browserify   = require('browserify');
                var source       = require('vinyl-source-stream');
                var buffer       = require('vinyl-buffer');
                var gulp         = require('gulp');
                var gutil        = require('gulp-util');
                var gulpSequence = require('gulp-sequence');
                var processhtml  = require('gulp-minify-html');
                var sass         = require('gulp-sass');
                var autoprefixer = require('gulp-autoprefixer');
                var watch        = require('gulp-watch');
                var cleanCSS    = require('gulp-clean-css');
                var uglify       = require('gulp-uglify');
                var streamify    = require('gulp-streamify');
                var sourcemaps   = require('gulp-sourcemaps');
                var concat       = require('gulp-concat');
                var babel        = require('gulp-babel');
                var fontawesome  = require('node-font-awesome');
                var prod         = gutil.env.prod;
                
                var onError = function(err) {
                  console.log(err.message);
                  this.emit('end');
                };
                
                // bundling js with browserify and watchify
                var b = watchify(browserify('./src/js/app', {
                  cache: {},
                  packageCache: {},
                  fullPaths: true
                }));
                
                gulp.task('js', bundle);
                b.on('update', bundle);
                b.on('log', gutil.log);
                
                function bundle() {
                  return b.bundle()
                    .on('error', onError)
                    .pipe(source('app.js'))
                    .pipe(buffer())
                    .pipe(sourcemaps.init())
                    .pipe(prod ? babel({
                      presets: ['es2015']
                    }) : gutil.noop())
                    .pipe(concat('app.js'))
                    .pipe(!prod ? sourcemaps.write('.') : gutil.noop())
                    .pipe(prod ? streamify(uglify()) : gutil.noop())
                    .pipe(gulp.dest('./assets/js'))
                    .pipe(browserSync.stream());
                }
                
                // fonts
                gulp.task('fonts', function() {
                  gulp.src(fontawesome.fonts)
                    .pipe(gulp.dest('./assets/fonts'));
                });
                
                // sass
                gulp.task('sass', function() {
                  return gulp.src('./src/scss/**/*.scss')
                    .pipe(sourcemaps.init())
                      .pipe(sass({
                        includePaths: [].concat(require('node-bourbon').includePaths, ['node_modules/foundation-sites/scss', 'node_modules/motion-ui/src', fontawesome.scssPath])
                      }))
                      .on('error', onError)
                      .pipe(prod ? cleanCSS() : gutil.noop())
                      .pipe(prod ? autoprefixer({
                        browsers: ['last 2 versions'],
                        cascade: false
                      }) : gutil.noop())
                    .pipe(!prod ? sourcemaps.write('.') : gutil.noop())
                    .pipe(gulp.dest('./assets/css'))
                    .pipe(browserSync.stream());
                });
                
                gulp.task('watch', function(){
                  gulp.watch('./src/scss/**/*.scss', ['sass']);
                  gulp.watch('./src/js/**/*.js', ['js']);
                });
                
                // browser-sync task for starting the server.
                gulp.task('serve', function() {
                    //watch files
                    var files = [
                    './assets/css/*.scss',
                    './*.php'
                    ];
                
                    //initialize browsersync
                    browserSync.init(files, {
                    //browsersync with a php server
                    proxy: "localhost",
                    notify: false
                  });
                  gulp.watch('./src/scss/**/*.scss', ['sass']);
                
                    // gulp.task('default', gulpSequence(['fonts', 'sass', 'js', 'watch']));
                });
                
                // use gulp-sequence to finish building html, sass and js before first page load
                gulp.task('default', gulpSequence(['fonts', 'sass', 'js'], 'serve'));
                

                docker-compose.yml 引用以下 dockerfile:

                The docker-compose.yml refers to the following dockerfile:

                FROM node
                
                # Grab our version variable from the yml file
                ARG SITE_VERSION
                
                # Install gulp globally
                RUN npm install -g gulp node-gyp node-sass
                
                # Install dependencies
                COPY ./gulp-build.sh /
                RUN chmod 777 /gulp-build.sh
                ENTRYPOINT ["/gulp-build.sh"]
                CMD ["run"]
                

                安裝 gulp 和 node-sass,并將以下 gulp-guild.sh 腳本復制到容器中:

                which installs gulp and node-sass, and also copies the following gulp-guild.sh script into the container:

                #!/bin/bash
                
                cd /var/www/html/wp-content/themes/theme
                # npm rebuild node-sass && npm install && gulp --dev
                npm rebuild node-sass && npm install && gulp
                

                推薦答案

                您的配置的主要問題是您在 gulpfile 中指向 localhost.這指向本地容器,而不是您的主機,因此 browsersync 將無法連接到 Wordpress.

                The primary problem with your configuration is that you're pointing to localhost in the gulpfile. This points to the local container, not your host machine, so browsersync won't be able to connect to Wordpress.

                您首先需要更新 gulpfile 以在其內部端口上指向 wordpress 服務:

                You first need to update the gulpfile to point to the wordpress service, on its internal port:

                browserSync.init(files, {
                    // The hostname is the name of your service in docker-compose.yml.
                    // The port is what's defined in your Dockerfile.
                    proxy: "wordpress:3000",
                    notify: false,
                    // Do not open browser on start
                    open: false
                })
                

                然后您需要添加端口映射以從您的 node 服務公開 browsersync 服務器.在您的 docker-compose.yml 文件中:

                Then you need to add a port mapping to expose the browsersync server from your node service. In your docker-compose.yml file:

                node:
                    ports:
                        - "3000:3000"
                        - "3001:3001"
                

                您現在應該可以訪問 localhost:3001 上的 browsersync 代理了.

                You should now be able to access the browsersync proxy on localhost:3001.

                附:如果您在一個 ngninx docker 容器中提供多個站點,您可以在/etc/nginx/conf.d/somesite.conf 中編輯特定站點的 nginx 配置文件并添加新行:聽:3000;

                P.S. In case you have more than one site serving in one ngninx docker container, you can edit nginx config file for specific site in /etc/nginx/conf.d/somesite.conf and add new line: listen: 3000;

                這篇關于Docker 容器中的 Browsersync的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                相關文檔推薦

                Browserify, Babel 6, Gulp - Unexpected token on spread operator(Browserify,Babel 6,Gulp - 傳播運算符上的意外令牌)
                Is it possible to pass a flag to Gulp to have it run tasks in different ways?(是否可以將標志傳遞給 Gulp 以使其以不同的方式運行任務?)
                Why do we need to install gulp globally and locally?(為什么我們需要在全局和本地安裝 gulp?)
                How to run Gulp tasks sequentially one after the other(如何一個接一個地依次運行 Gulp 任務)
                Stylesheet not loaded because of MIME-type(由于 MIME 類型而未加載樣式表)
                Visual Studio 2015 crashes when opening Javascript files(打開 Javascript 文件時 Visual Studio 2015 崩潰)

                  1. <i id='ZTTtz'><tr id='ZTTtz'><dt id='ZTTtz'><q id='ZTTtz'><span id='ZTTtz'><b id='ZTTtz'><form id='ZTTtz'><ins id='ZTTtz'></ins><ul id='ZTTtz'></ul><sub id='ZTTtz'></sub></form><legend id='ZTTtz'></legend><bdo id='ZTTtz'><pre id='ZTTtz'><center id='ZTTtz'></center></pre></bdo></b><th id='ZTTtz'></th></span></q></dt></tr></i><div class="p77nl5b" id='ZTTtz'><tfoot id='ZTTtz'></tfoot><dl id='ZTTtz'><fieldset id='ZTTtz'></fieldset></dl></div>

                      • <tfoot id='ZTTtz'></tfoot>
                        • <bdo id='ZTTtz'></bdo><ul id='ZTTtz'></ul>

                          <small id='ZTTtz'></small><noframes id='ZTTtz'>

                          <legend id='ZTTtz'><style id='ZTTtz'><dir id='ZTTtz'><q id='ZTTtz'></q></dir></style></legend>
                            <tbody id='ZTTtz'></tbody>
                          主站蜘蛛池模板: 耐高温电缆厂家-远洋高温电缆| 石油/泥浆/不锈钢防腐/砂泵/抽砂泵/砂砾泵/吸砂泵/压滤机泵 - 专业石油环保专用泵厂家 | 碳化硅,氮化硅,冰晶石,绢云母,氟化铝,白刚玉,棕刚玉,石墨,铝粉,铁粉,金属硅粉,金属铝粉,氧化铝粉,硅微粉,蓝晶石,红柱石,莫来石,粉煤灰,三聚磷酸钠,六偏磷酸钠,硫酸镁-皓泉新材料 | 欧美日韩国产一区二区三区不_久久久久国产精品无码不卡_亚洲欧洲美洲无码精品AV_精品一区美女视频_日韩黄色性爱一级视频_日本五十路人妻斩_国产99视频免费精品是看4_亚洲中文字幕无码一二三四区_国产小萍萍挤奶喷奶水_亚洲另类精品无码在线一区 | 不锈钢丸厂家,铝丸,铸钢丸-淄博智源铸造材料有限公司 | 不锈钢复合板厂家_钛钢复合板批发_铜铝复合板供应-威海泓方金属复合材料股份有限公司 | 刚性-柔性防水套管-橡胶伸缩接头-波纹管补偿器-启腾供水材料有限公司 | 东莞工厂厂房装修_无尘车间施工_钢结构工程安装-广东集景建筑装饰设计工程有限公司 | 儿童乐园|游乐场|淘气堡招商加盟|室内儿童游乐园配套设备|生产厂家|开心哈乐儿童乐园 | POS机办理_个人pos机免费领取-银联pos机申请首页 | 杭州翻译公司_驾照翻译_专业人工翻译-杭州以琳翻译有限公司官网 组织研磨机-高通量组织研磨仪-实验室多样品组织研磨机-东方天净 | 上海平衡机-单面卧式动平衡机-万向节动平衡机-圈带动平衡机厂家-上海申岢动平衡机制造有限公司 | 电梯装饰-北京万达中意电梯装饰有限公司 | 超声波清洗机_细胞破碎仪_实验室超声仪器_恒温水浴-广东洁盟深那仪器 | 东莞工厂厂房装修_无尘车间施工_钢结构工程安装-广东集景建筑装饰设计工程有限公司 | 房在线-免费房产管理系统软件-二手房中介房屋房源管理系统软件 | 深圳离婚律师咨询「在线免费」华荣深圳婚姻律师事务所专办离婚纠纷案件 | 万烁建筑设计院-建筑设计公司加盟,设计院加盟分公司,市政设计加盟 | 深圳高新投三江工业消防解决方案提供厂家_服务商_园区智慧消防_储能消防解决方案服务商_高新投三江 | 精密模具加工制造 - 富东懿 | 东莞螺杆空压机_永磁变频空压机_节能空压机_空压机工厂批发_深圳螺杆空压机_广州螺杆空压机_东莞空压机_空压机批发_东莞空压机工厂批发_东莞市文颖设备科技有限公司 | 谈股票-今日股票行情走势分析-牛股推荐排行榜| 软装设计-提供软装装饰和软装配饰及软装陈设的软装设计公司 | 大_小鼠elisa试剂盒-植物_人Elisa试剂盒-PCR荧光定量试剂盒-上海一研生物科技有限公司 | 超声波破碎仪-均质乳化机(供应杭州,上海,北京,广州,深圳,成都等地)-上海沪析实业有限公司 | Safety light curtain|Belt Sway Switches|Pull Rope Switch|ultrasonic flaw detector-Shandong Zhuoxin Machinery Co., Ltd | 消电检公司,消电检价格,北京消电检报告-北京设施检测公司-亿杰(北京)消防工程有限公司 | 临朐空调移机_空调维修「空调回收」临朐二手空调 | 车间除尘设备,VOCs废气处理,工业涂装流水线,伸缩式喷漆房,自动喷砂房,沸石转轮浓缩吸附,机器人喷粉线-山东创杰智慧 | 生鲜配送系统-蔬菜食材配送管理系统-连锁餐饮订货配送软件-挪挪生鲜供应链管理软件 | 石家庄网站建设|石家庄网站制作|石家庄小程序开发|石家庄微信开发|网站建设公司|网站制作公司|微信小程序开发|手机APP开发|软件开发 | 钢格板_钢格栅_格栅板_钢格栅板 - 安平县鑫拓钢格栅板厂家 | 百度关键词优化_网站优化_SEO价格 - 云无限好排名 | 上海皓越真空设备有限公司官网-真空炉-真空热压烧结炉-sps放电等离子烧结炉 | 全自动定氮仪-半自动凯氏定氮仪厂家-祎鸿仪器 | EDLC超级法拉电容器_LIC锂离子超级电容_超级电容模组_软包单体电容电池_轴向薄膜电力电容器_深圳佳名兴电容有限公司_JMX专注中高端品牌电容生产厂家 | 活动策划,舞台搭建,活动策划公司-首选美湖上海活动策划公司 | 模具ERP_模具管理系统_模具mes_模具进度管理_东莞市精纬软件有限公司 | 圆盘鞋底注塑机_连帮鞋底成型注塑机-温州天钢机械有限公司 | 废气处理_废气处理设备_工业废气处理_江苏龙泰环保设备制造有限公司 | 拉曼光谱仪_便携式|激光|显微共焦拉曼光谱仪-北京卓立汉光仪器有限公司 |