6

This is using Docker. It works when using wsl2 but when using hyper-v I'm getting the issue.

I'm trying to run mix watch -- --watch-options-poll=3000 or mix --production but every time I'm running it I'm getting the following issue.

[webpack-cli] [Error: EEXIST: file already exists, open '/var/www/html/public/website/images/e-side.png'] { errno: -17,
code: 'EEXIST', syscall: 'open', path: '/var/www/html/public/website/images/e-side.png' }

webpack.mix.js

const mix = require('laravel-mix');
const oldMix = require('laravel-mix');
const path = require('path');
const glob = require('glob');
const PurgeCSSPlugin = require('purgecss-webpack-plugin');

//-- Website Mix --
mix.babelConfig({
   plugins: ['@babel/plugin-syntax-dynamic-import', '@babel/plugin-proposal-class-properties', '@babel/plugin-proposal-optional-chaining'],
});

mix.webpackConfig({
    watchOptions: {
        ignored: /node_modules/
    },
    stats: {
        warnings: false,
    },
    output: {
        chunkFilename: 'website/js/chunks/[chunkhash].js',//replace with your path
    },
    resolve: {
        alias: {
            '@fonts': path.resolve(__dirname, 'resources/website/styles/fonts'),
            '@images': path.resolve(__dirname, 'resources/website/images')
        }
    },
    plugins: [
        new PurgeCSSPlugin({
            paths: glob.sync('website/*',  { nodir: true }),
        })
    ]
});

mix.options({
    postCss: [
        require('autoprefixer'),
    ],
    fileLoaderDirs:  {
        fonts: 'website/fonts',
        images: 'website/images'
    }
});

mix.js('resources/website/index.js', 'public/website/js').react();
mix.version();
//-- Website Mix End --

//-- Old Application and Dashboard --
oldMix.webpackConfig({
    watchOptions: {
        ignored: /node_modules/
    }
});

oldMix.babel([
    'public/old/Scripts/Core/Primitive/jQuery.js',
    'public/old/Scripts/Core/Primitive/Slick.js',
    'public/old/Scripts/Core/Primitive/Angular.js',
    'public/old/Scripts/Core/Primitive/Bootstrap.js',
    'public/old/Scripts/Core/Primitive/Masonry.js',
    'public/old/Scripts/Core/Primitive/Images.js',
    'public/old/Scripts/Core/Primitive/Moment.js',
    'public/old/Scripts/Core/Primitive/Date.js',
    'public/old/Scripts/Core/Primitive/UTM.js',
    'public/old/Scripts/Dashboard/Tinymce/TinyMCE.js',
    'public/old/Scripts/Core/Primitive/Pusher.js',
    'public/old/Scripts/Core/Primitive/Reviews.js',
    'public/old/Scripts/Core/Primitive/Fancybox.js',
    'public/old/Scripts/Core/Primitive/Confetti.js',
    'public/old/Scripts/Core/Primitive/Signature.js',
], 'public/old/Build/Scripts/Primitive.js');

oldMix.babel([
    'public/old/Scripts/Core/Angular/*.js',
    'public/old/Scripts/Dashboard/Tinymce/UITinyMCE.js'
], 'public/old/Build/Scripts/Directives.js');

oldMix.babel([
    'public/old/Scripts/Dashboard/UI.js',
    'public/old/Scripts/Dashboard/Modules/OriginFactories.js',
    'public/old/Scripts/Dashboard/Modules/AddonsControllers.js',
    'public/old/Scripts/Dashboard/Modules/ProductsControllers.js',
    'public/old/Scripts/Dashboard/Modules/BoilerAdviceControllers.js',
    'public/old/Scripts/Dashboard/Modules/DashboardAnalytics.js',
    'public/old/Scripts/Dashboard/Controllers.js',
    'public/old/Scripts/Dashboard/Routes.js',
], 'public/old/Build/Scripts/Dashboard.js');

oldMix.babel([
    'public/old/Scripts/Application/UI.js',
    'public/old/Scripts/Application/Controllers.js',
    'public/old/Scripts/Application/Routes.js',
], 'public/old/Build/Scripts/Application.js');


oldMix.babel([
    'public/old/Scripts/Core.js'
], "public/old/Build/App.js");

oldMix.styles(['public/old/Styles/*.css'], 'public/old/Build/Styles/Core.css');
oldMix.styles(['public/old/Styles/Home/*.css'], 'public/old/Build/Styles/Home.css');
oldMix.styles(['public/old/Styles/Dashboard/*.css'], 'public/old/Build/Styles/Dashboard.css');
oldMix.styles(['public/old/Styles/Application/*.css'], 'public/old/Build/Styles/Application.css');
oldMix.version();
//-- Old Application and Dashboard End --

composer.dockerfile:

FROM composer:1.6.5

RUN addgroup -g 1000 laravel && adduser -G laravel -g laravel -s /bin/sh -D laravel

WORKDIR /var/www/html

CMD ["tail", "-f", "/dev/null"]

docker-compose.yml:

version: '3'

networks:
  laravel:

services:
  application-aws:
    build:
      context: .
      dockerfile: nginx.dockerfile
    container_name: nginx-aws
    ports:
      - 5001:5001
    volumes:
      - ./src:/var/www/html:delegated
    depends_on:
      - php
      - mysql
    links:
      - mysql
    networks:
      - laravel

  mysql:
    image: mysql:5.7.33
    container_name: mysql-aws
    restart: unless-stopped
    tty: true
    ports:
      - 3306:3306
    environment:
      MYSQL_HOST: mysql
      MYSQL_DATABASE: heatable
      MYSQL_USER: heatable
      MYSQL_ROOT_PASSWORD: password
    networks:
      - laravel
    volumes:
      - ./mysql:/var/lib/mysql

  php:
    build:
      context: .
      dockerfile: php.dockerfile
    container_name: php-aws
    volumes:
      - ./src:/var/www/html:delegated
    networks:
      - laravel
    links:
      - mysql
    depends_on:
      - mysql

  composer:
    build:
      context: .
      dockerfile: composer.dockerfile
    container_name: composer-aws
    volumes:
      - ./src:/var/www/html
    working_dir: /var/www/html
    depends_on:
      - php
    user: laravel
    entrypoint: ['composer', '--ignore-platform-reqs']
    networks:
      - laravel

  npm:
    image: node:14.17.1
    tty: true
    container_name: npm-aws
    volumes:
      - ./src:/var/www/html
      - /var/www/html/node_modules
    working_dir: /var/www/html
    entrypoint: ['npm']
    networks:
      - laravel

  artisan:
    build:
      context: .
      dockerfile: php.dockerfile
    container_name: artisan-aws
    volumes:
      - ./src:/var/www/html:delegated
    depends_on:
      - mysql
    working_dir: /var/www/html
    user: laravel
    entrypoint: ['php', '/var/www/html/artisan']
    links:
      - mysql
    networks:
      - laravel

nginx.dockerfile:

FROM nginx:stable-alpine

ADD ./nginx/nginx.conf /etc/nginx/nginx.conf
ADD ./nginx/default.conf /etc/nginx/conf.d/default.conf

RUN mkdir -p /var/www/html

RUN addgroup -g 1000 laravel && adduser -G laravel -g laravel -s /bin/sh -D laravel

RUN chown laravel:laravel /var/www/html

npm.dockerfile:

FROM node:14.17.1
WORKDIR /var/www/html
COPY ./src/package.json .
RUN npm install

php.dockerfile:

FROM php:7.3-fpm-alpine

ADD ./php/www.conf /usr/local/etc/php-fpm.d/www.conf

RUN addgroup -g 1000 laravel && adduser -G laravel -g laravel -s /bin/sh -D laravel

RUN mkdir -p /var/www/html

RUN chown laravel:laravel /var/www/html

WORKDIR /var/www/html

RUN apk add libpng-dev

RUN docker-php-ext-install mysqli pdo pdo_mysql gd
YaBCK
  • 2,949
  • 4
  • 32
  • 61
  • Have you tried removing any code to find out where the problem is? I'd start by removing the purge-css plugin. Have you tried debugging to see where the problem is triggered? https://hackernoon.com/debug-node-js-with-chrome-devtools-aca7cf83af6b – miken32 Nov 03 '21 at 23:50
  • Try to find an option to force mix replacing already existed images. – Zrelli Majdi Nov 04 '21 at 02:41
  • @YaBCK Please, could you include in the question your `docker-compose.yml` file and your custom `Dockerfile` if you are using one? – jccampanero Nov 04 '21 at 13:46
  • @jccampanero - I've including all the dockerfiles within the project and the `docker-compose.yml` – YaBCK Nov 05 '21 at 08:38
  • Thank you very much for the feedback @YaBCK. Great stuff by the way. I am not sure, but I think your problem can be related to your volumes configuration. The behavior in wls2 and hyper-v may be not the same. I would try two things: one, remove the `:delegated` configuration. In addition, as you are extensively using the same volume across the different containers, probably you could create a named volume and [reuse that volume within them](https://docs.docker.com/storage/volumes/#use-a-volume-with-docker-compose). – jccampanero Nov 05 '21 at 11:11
  • You can [populate](https://docs.docker.com/storage/volumes/#populate-a-volume-using-a-container) its contents if necessary using a helper container - maybe the one you identified as `npm`? In any way, at least for me, it is difficult to identify the actual reason of the problem. – jccampanero Nov 05 '21 at 11:13

0 Answers0