首页 > 解决方案 > 代码更改如何通过 docker-compose 立即生效?

问题描述

我是 MEAN 应用程序的新手,目前正在从事一个项目。我已将前端和后端都包含在 docker 容器中。应用程序在没有问题的 docker 上构建和运行。我的问题是当我想在前后的代码中执行更改时。

执行的任何更改都不会立即发生。我读了几篇关于如何做到这一点的文章,但对我来说不是很清楚,可能是我读过的那些。请在下面找到我当前项目的一些数据。

[后端码头文件]

# Dockerfile

FROM node:10.16.0-alpine
RUN mkdir -p /opt/app
WORKDIR /opt/app
RUN adduser --disabled-password app
COPY ./* ./
RUN chown -R app:app /opt/app
USER app
RUN npm install
CMD [ "npm","run", "start:dev" ]

[前端 dockerfile ]

# Dockerfile

FROM node:10.20.0-alpine AS builder
RUN apk add --no-cache git=2.24.3-r0 \
    --repository https://alpine.global.ssl.fastly.net/alpine/v3.10/community \
    --repository https://alpine.global.ssl.fastly.net/alpine/v3.10/main


COPY . ./app
WORKDIR /app
RUN npm i -g @angular/cli
RUN npm install
RUN ng build --prod --aot
# RUN $(npm bin)/ng build --prod --aot

# FROM nginx:1.15.8-alpine
# COPY --from=builder /app/dist/ /usr/share/nginx/html
EXPOSE 4200
#CMD [ "npm", "start" ]
CMD ng serve --host 0.0.0.0 --disable-host-check
# EXPOSE 80 443
# CMD [ "nginx", "-g", "daemon off;" ]

[码头工人-compose.yml ]

version: "3.7"

services:
    evillio-backend:
        build:
            context: evillio-backend/
        ports:
            - '3000:3000'

    evillio-frontend:
        build:
            context: evillio-frontend/
        ports:
            - '4200:4200'

[后端包.json ]

"start": "node dist/main.js",
    "start-local": "nest start",
    "start:dev": "nest start",
    "start:debug": "nest start --debug --watch",
    "start:prod": "node dist/main",

标签: angularmeannestjs

解决方案


推荐阅读