При сборке docker-compose файла, на шаге [frontend build 2/2] RUN npm install
начинают сыпаться ошибки:
=> [frontend build 2/2] RUN npm install
=> => # (node:1) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [T => => # LSSocket]. Use emitter.setMaxListeners() to increase limit
=> => # (node:1) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [T => => # LSSocket]. Use emitter.setMaxListeners() to increase limit
=> => # (node:1) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [T => => # LSSocket]. Use emitter.setMaxListeners() to increase limit
и затем сборка заканчивается неудачей с ошибкой network aborted
214.1 npm notice
214.1 npm ERR! code ECONNRESET
214.1 npm ERR! network aborted
214.1 npm ERR! network This is a problem related to network connectivity.
214.1 npm ERR! network In most cases you are behind a proxy or have bad network settings.
214.1 npm ERR! network
214.1 npm ERR! network If you are behind a proxy, please make sure that the
214.1 npm ERR! network 'proxy' config is set properly. See: 'npm help config'
214.1
214.1 npm ERR! A complete log of this run can be found in: /root/.npm/_logs/2024-05-03T12_08_09_049Z-debug-0.log
------
failed to solve: process "/bin/sh -c npm install" did not complete successfully: exit code: 1
На хосте таких проблем нету.
Dockerfile
# syntax = docker/dockerfile:1
ARG NODE_VERSION=20.9
FROM node:${NODE_VERSION}-slim as base
ENV NODE_ENV=development
WORKDIR /src
# Build
FROM base as build
COPY --link package.json package-lock.json ./
RUN npm install
# Run
FROM base
COPY --from=build /src/node_modules /src/node_modules
CMD [ "npm", "run", "dev" ]
Docker compose:
version: '3.7'
services:
frontend:
container_name: frontend
build:
context: .
dockerfile: Dockerfile.dev
restart: always
volumes:
- ./:/src
- node_modules:/src/node_modules
working_dir: /src
expose:
- 3000
- 24678
ports:
- "24678:24678"
environment:
VIRTUAL_HOST: $FRONTEND_DOMAIN
HTTPS_METHOD: noredirect
VIRTUAL_PORT: 3000
NUXT_SITE_URL: $NUXT_SITE_URL
NUXT_API_URL: $NUXT_API_URL
NUXT_API_REFERRER: $NUXT_API_REFERRER
NUXT_SEARCH_API_KEY: $NUXT_SEARCH_API_KEY
NUXT_SEARCH_HOST: $NUXT_SEARCH_HOST
NUXT_SEARCH_PORT: $NUXT_SEARCH_PORT
NUXT_SEARCH_PROTOCOL: $NUXT_SEARCH_PROTOCOL
networks:
- frontend
- backend
- reverse-proxy
networks:
reverse-proxy:
name: reverse-proxy
external: true
backend:
name: backend
external: true
frontend:
name: frontend
driver: bridge
volumes:
node_modules:
package.json
{
"name": "nuxt-app",
"private": true,
"type": "module",
"scripts": {
"build": "nuxt build",
"dev": "nuxt dev",
"generate": "nuxt generate",
"preview": "nuxt preview",
"postinstall": "nuxt prepare"
},
"dependencies": {
"@babel/runtime": "^7.23.9",
"@nuxt/image": "^1.3.0",
"@nuxt/ui": "^2.13.0",
"@pinia/nuxt": "^0.5.1",
"centrifuge": "^5.1.1",
"maska": "^2.1.11",
"mitt": "^3.0.1",
"nuxt": "^3.10.2",
"nuxt-swiper": "^1.2.2",
"pinia": "^2.1.7",
"typesense": "^1.7.2",
"vue": "^3.4.19",
"vue-router": "^4.2.5",
"zod": "^3.22.4"
},
"devDependencies": {
"@nuxtjs/i18n": "^8.1.1",
"execa": "^8.0.1",
"nuxt-lodash": "^2.5.3",
"nuxt-og-image": "^3.0.0-rc.38",
"nuxt3-leaflet": "^1.0.12",
"sharp": "^0.33.2"
}
}