laravel在docker中使用gulp编译资产

时间:2020-02-18 08:07:48

标签: node.js laravel docker gulp

我有一个laravel应用(5.5),我使用gulp编译资产,并且在docker之外运行良好,我想要它:

当我在本地计算机上(不在docker上)运行gulp watch命令时,它可以生效,但是我该怎么做?

我必须在docker容器中运行“ gulp watch”命令吗?或者,如果我在本地运行此命令,它可以监视文件...

docker-compose.yml

version: "3"

services:
    redis:
        image: "redis:alpine"
        container_name: redis

    nginx:
        build:
            context: ./nginx
            dockerfile: Dockerfile.dev
        container_name: app_nginx
        ports:
            - 80:80
        volumes:
            - ./:/var/www
        depends_on:
            - php-fpm
            - redis

    php-fpm:
        build:
            context: ./
            dockerfile: Dockerfile.dev
        container_name: app_php
        volumes:
            - ./:/var/www
        environment:
            - REDIS_HOST=redis
            - REDIS_PORT=6379
            - REDIS_PASSWORD=null
            - MYSQL_ROOT_PASSWORD=xxx
            - MYSQL_HOST=mysql
            - MYSQL_DATABASE=xxx
            - MYSQL_USER=xxx
            - MYSQL_PASS=xxx

    mysql:
        image: mysql:5.7
        container_name: app_mysql
        volumes:
            - dbdata:/var/lib/mysql
        environment:
            - MYSQL_ROOT_PASSWORD=root
            - MYSQL_HOST=localhost
            - MYSQL_DATABASE=xxx
            - MYSQL_USER=xxx
            - MYSQL_PASS=xxx
        ports:
            - "3306:3306"

    cloud:
        image: minio/minio
        container_name: app_cloud
        volumes:
            - ./cloud-data/:/data
        environment:
            MINIO_ACCESS_KEY: xxx
            MINIO_SECRET_KEY: xxx
            MINIO_DOMAIN: miniolocal
        command: server /data
        ports:
            - "9000:9000"

volumes:
    dbdata:

Dockerfile.dev

# dockerfile
FROM php:7.3-fpm

# Copy composer.lock and composer.json
COPY composer.lock* composer.json* /var/www/

# Set working directory
WORKDIR /var/www

# Install dependencies
RUN apt-get update && apt-get install -y \
    build-essential \
    libpng-dev \
    libjpeg62-turbo-dev \
    libfreetype6-dev \
    locales \
    zip \
    jpegoptim optipng pngquant gifsicle \
    unzip \
    curl

# Clear cache
RUN apt-get clean && rm -rf /var/lib/apt/lists

# Install extensions
RUN docker-php-ext-install pdo pdo_mysql mbstring 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
RUN pecl install -o -f redis \
    &&  rm -rf /tmp/pear \
    &&  docker-php-ext-enable redis

# Install composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

# NPM for frontend builds
RUN apt install nodejs npm -y

# Add user for laravel application
RUN groupadd -g 1000 www
RUN useradd -u 1000 -ms /bin/bash -g www www

# Copy existing application directory contents
COPY ./ /var/www

RUN npm install
RUN gulp

# Copy existing application directory permissions
COPY --chown=www:www . /var/www

# Change current user to www
USER www

# Expose port 9000 and start php-fpm server
EXPOSE 9000
CMD ["php-fpm"]

0 个答案:

没有答案