我在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)不适用
是否可以同步文件? 我在做什么错了?
我的配置
项目结构
.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