OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

The command does not start npm run dev in Docker Compose

  • Thread starter Thread starter Artem Dikarev
  • Start date Start date
A

Artem Dikarev

Guest
I have an nginx and php container in which a Laravel application exists, and there is also a vite builder, and when I run the npm run dev command, the css, js files do not compile. And when I go to the browser I see 3 errors:

Code:
- GET http://localhost:5173/@vite/client net::ERR_EMPTY_RESPONSE
- GET http://localhost:5173/resources/js/app.js net::ERR_EMPTY_RESPONSE
- GET http://localhost:5173/resources/css/app.css net::ERR_EMPTY_RESPONSE

file docker-compose:

Code:
version: "3"
networks:
  backend:
    driver: bridge
services:
  nginx:
    image: "nginx:stable-alpine"
    ports:
      - "5000:80"
    volumes:
      - ./nginx/nginx.conf:/etc/nginx/conf.d/default.conf:ro
      - ./src:/var/www/laravel
    depends_on:
      - mysql
      - php
      - phpmyadmin
      - npm
    networks:
      - backend
  php:
    build:
      context: dockerfiles
      dockerfile: php.Dockerfile
    volumes:
      - ./src:/var/www/laravel
    networks:
      - backend
  mysql:
    image: mysql:8.0
    ports:
      - "3316:3306"
    env_file:
      - env/mysql.env
    networks:
      - backend
  composer:
     build:
        context: dockerfiles
        dockerfile: composer.Dockerfile
     volumes:
        - ./src:/var/www/laravel
     networks:
        - backend   
  artisan:
      build: 
        context: dockerfiles
        dockerfile: php.Dockerfile
      volumes:
          - ./src:/var/www/laravel
      entrypoint: ["php","/var/www/laravel/artisan"]
      networks:
        - backend
  npm:
      image: node:alpine
      container_name: npm
      volumes:
        - ./src:/var/www/laravel
      ports:
        - "5173:80"
      working_dir: /var/www/laravel
      entrypoint: ["npm"]

vite.config.js

Code:
import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';

export default defineConfig({
    
   
    plugins: [
        laravel({
            input: ['resources/css/app.css', 'resources/js/app.js'],
            refresh: true,
        }),
    ],
    server: {
        strictPort: true,
        port: 5173,
        host: '0.0.0.0',
        origin: 'http://localhost:5173',
        hmr: {
            host: 'localhost',
        },
        watch: {
            ignored: ['./app/**', './bootstrap/**', './config/**', './database/**', './lang/**', './node_modules/**', './public/**', './routes/**', './storage/**', './tests/**', './vendor/**'],
        },
    }
 
});

I tried changing the ports from 80 to 8000 and running npm run dev --host --port 5173 as well as npm run dev --host --port 80 but it didn't work.

<p>I have an nginx and php container in which a Laravel application exists, and there is also a vite builder, and when I run the npm run dev command, the css, js files do not compile. And when I go to the browser I see 3 errors:</p>
<pre><code>- GET http://localhost:5173/@vite/client net::ERR_EMPTY_RESPONSE
- GET http://localhost:5173/resources/js/app.js net::ERR_EMPTY_RESPONSE
- GET http://localhost:5173/resources/css/app.css net::ERR_EMPTY_RESPONSE
</code></pre>
<p>file docker-compose:</p>
<pre><code>version: "3"
networks:
backend:
driver: bridge
services:
nginx:
image: "nginx:stable-alpine"
ports:
- "5000:80"
volumes:
- ./nginx/nginx.conf:/etc/nginx/conf.d/default.conf:ro
- ./src:/var/www/laravel
depends_on:
- mysql
- php
- phpmyadmin
- npm
networks:
- backend
php:
build:
context: dockerfiles
dockerfile: php.Dockerfile
volumes:
- ./src:/var/www/laravel
networks:
- backend
mysql:
image: mysql:8.0
ports:
- "3316:3306"
env_file:
- env/mysql.env
networks:
- backend
composer:
build:
context: dockerfiles
dockerfile: composer.Dockerfile
volumes:
- ./src:/var/www/laravel
networks:
- backend
artisan:
build:
context: dockerfiles
dockerfile: php.Dockerfile
volumes:
- ./src:/var/www/laravel
entrypoint: ["php","/var/www/laravel/artisan"]
networks:
- backend
npm:
image: node:alpine
container_name: npm
volumes:
- ./src:/var/www/laravel
ports:
- "5173:80"
working_dir: /var/www/laravel
entrypoint: ["npm"]


</code></pre>
<p>vite.config.js</p>
<pre><code>import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';

export default defineConfig({


plugins: [
laravel({
input: ['resources/css/app.css', 'resources/js/app.js'],
refresh: true,
}),
],
server: {
strictPort: true,
port: 5173,
host: '0.0.0.0',
origin: 'http://localhost:5173',
hmr: {
host: 'localhost',
},
watch: {
ignored: ['./app/**', './bootstrap/**', './config/**', './database/**', './lang/**', './node_modules/**', './public/**', './routes/**', './storage/**', './tests/**', './vendor/**'],
},
}

});

</code></pre>
<p>I tried changing the ports from 80 to 8000 and running npm run dev --host --port 5173 as well as npm run dev --host --port 80 but it didn't work.</p>
 

Latest posts

Z
Replies
0
Views
1
zuegelwagen
Z
Top