节点js,nuxt js,vue js-docker文件未同步

时间:2020-03-09 11:35:04

标签: node.js docker vue.js docker-compose nuxt.js

我在Docker容器中部署了节点js + nuxt js + vue js。一切开始,并且可以在地址http://0.0.0.0:1000/上访问,但是当我更改文件.vue时,它们不会掉入容器中。

1。。docker-compose up --build; (我在控制台中看到:node-js |ℹ收听:http://172.19.0.2:3000/

2。。打开http://0.0.0.0:1000/(我在浏览器中看到:“ 99999”)

/client/layouts/default.vue

<template>
  <div>
    99999
  </div>
</template>

3。。将/client/layouts/default.vue更改为

<template>
  <div>
    111111
  </div>
</template>

4。在浏览器中重新加载http://0.0.0.0:1000/,我看到的是99999。 更改(111111)不适用

是否可以同步文件? 我在做什么错了?


我的配置

项目结构

  • / api(php)
  • /客户端(节点js + nuxt js + vue js)
  • / docker(用于docker的配置)
  • docker-compose.yml
  • .env

.env

PROJECT_NAME=test
NODE_VERSION=13.8
...

docker-compose.yml

version: "3.7"

services:
    node:
        container_name: ${PROJECT_NAME}-node-js
        build:
            context: client
            dockerfile: ../docker/client/Dockerfile
            args:
                - NODE_VERSION=${NODE_VERSION}
        volumes:
            - ./client:/app
            - ./docker/client/log:/root/.npm/_logs
        ports:
            - "1000:3000"
        command:
            "npm run start"
        networks:
            - app-network

networks:
    app-network:
        driver: bridge

volumes:
    dbdata:
        driver: local

/ docker / client / Dockerfile

ARG NODE_VERSION

FROM node:$NODE_VERSION

COPY ./package*.json ./
RUN npm install

ENV NODE_ENV=production

COPY . .
RUN npm run build

ENV HOST 0.0.0.0
EXPOSE 3000
CMD ["npm", "start"]

/client/.dockerignore

node_modules

npm-debug.log

.nuxt


决定!

/client/package.json

"scripts": {
     "start": "nodemon index.js -e js,graphql,gql",
     "docker": "npm run dev"
     ...

docker-compose.yml

version: "3.7"

services:
    node:
        container_name: ${PROJECT_NAME}-node-js
        image: node:${NODE_VERSION}
        command: npm run docker
        working_dir: /app
        volumes:
            - ./client:/app
            - ./docker/client/log:/root/.npm/_logs
        environment:
            HOST: 0.0.0.0
        ports:
            - "1000:3000"
        networks:
            - app-network

networks:
    app-network:
        driver: bridge

volumes:
    dbdata:
        driver: local

0 个答案:

没有答案