I have an nginx and php container in which a Laravel application exists, and when I run the npm run dev
command,
the css and js files are not compiled.
And then when I go to the browser on the local host I get 3 errors:
- 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/js/Pages/Welcome.vue net::ERR_EMPTY_RESPONSE
file docker-compose:
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
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.