在docker中运行的实时调试节点应用程序

前端之家收集整理的这篇文章主要介绍了在docker中运行的实时调试节点应用程序前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

我在Docker上运行React内置的应用程序.我正在寻找一种调试它的方法.我正在使用Visual Studio Code.这是我的Docker文件和Docker-compose文件

FROM node:boron


ARG build_env

RUN mkdir /usr/share/unicode && cd /usr/share/unicode && wget ftp://ftp.unicode.org/Public/UNIDATA/UnicodeData.txt

COPY package.json /tmp/package.json

RUN cd /tmp && npm install

COPY ./shim/RelayDefaultNetworkLayer.js /tmp/node_modules/react-relay/lib/RelayDefaultNetworkLayer.js
COPY ./shim/buildRQL.js /tmp/node_modules/react-relay/lib/buildRQL.js

RUN mkdir -p /var/www && cp -a /tmp/node_modules /var/www/

WORKDIR /var/www

COPY . ./

RUN if [ "$build_env" != "development" ]; then npm run build-webpack && npm run gulp; fi

EXPOSE 8080

CMD ["npm","run","--debug=5858 prod"]

我的docker-compose文件看起来像

version: '2'

services:
  Nginx:
    container_name: Nginx
    image: openroad/Nginx
    build:
      context: Nginx
    ports:
      - "80:80"
    volumes:
      - ./Nginx/Nginx.development.conf:/etc/Nginx/Nginx.conf
    networks:
      - orion-network

  graphql:
    container_name: graphql
    image: openroad/graphql
    build:
      context: integration_api
    volumes:
      - ./integration_api:/var/www
    environment:
      - NODE_ENV=development
    command: npm run dev
    working_dir: /var/www
    networks:
      orion-network:
        ipv4_address: 172.16.238.10

  pegasus:
    container_name: pegasus
    image: openroad/pegasus
    build:
      context: pegasus
      args:
        build_env: development
    expose:
      - "3000"
    volumes:
      - ./pegasus:/var/www/public
    environment:
      - NODE_ENV=development
    command: npm run dev
    working_dir: /var/www/public
    extra_hosts:
      - "local.pegasus.com:192.168.99.100"
    networks:
      orion-network:
        ipv4_address: 172.16.238.11

  frontend:
    container_name: orion-frontend
    image: openroad/orion-frontend
    build:
      context: orion-frontend
      args:
        build_env: development
    expose:
      - "3000"
    ports:
      - "5858:5858"
    volumes:
      - ./orion-frontend:/var/www/public
    environment:
      - NODE_ENV=development
    command: npm run --debug=5858 dev
    working_dir: /var/www/public
    networks:
      orion-network:
        ipv4_address: 172.16.238.12

  admin:
      container_name: orion-admin
      image: openroad/orion-admin
      build:
        context: orion-admin
        args:
          build_env: development
      expose:
        - "3000"
      volumes:
        - ./orion-admin:/var/www/
      environment:
        - NODE_ENV=development
      command: npm run dev
      working_dir: /var/www/
      networks:
        orion-network:
          ipv4_address: 172.16.238.13

  uploads:
    container_name: orion-uploads
    image: openroad/orion-uploads
    build:
      context: orion-uploads
    volumes:
      - ./orion-uploads:/var/www/
    working_dir: /var/www/
    networks:
      orion-network:
        ipv4_address: 172.16.238.14

  dashboard:
    container_name: orion-dashboard
    image: openroad/orion-dashboard
    build:
      context: orion-dashboard
      args:
        build_env: development
    volumes:
      - ./orion-dashboard/src:/var/www/src
      - ./orion-dashboard/package.json:/var/www/package.json
      - ./orion-dashboard/webpack.config.babel.js:/var/www/webpack.config.babel.js
      - ./orion-dashboard/node_modules:/var/www/node_modules
      - ./orion-dashboard/data/babelRelayPlugin.js:/var/www/data/babelRelayPlugin.js
    working_dir: /var/www
    environment:
      - NODE_ENV=development
      - GRAPHQLURL=http://172.16.238.10:8080/graphql
      - PORT=8080
    command: npm run dev
    networks:
      orion-network:
        ipv4_address: 172.16.238.15

networks:
  orion-network:
    driver: bridge
    driver_opts:
      com.docker.network.bridge.enable_ip_masquerade: "true"
    ipam:
      driver: default
      config:
      - subnet: 172.16.238.0/24
        gateway: 172.16.238.1

我希望能够调试在orion-frontend容器下运行的应用程序.我尝试了各种选项而没有任何成功.我已经尝试了https://codefresh.io/docker-tutorial/debug_node_in_docker/https://blog.docker.com/2016/07/live-debugging-docker/.

最佳答案
我对npm run的命令语法可能有误(在npm docs中找不到这个命令),但你可能需要将–debug = 5858和prod args分开,如下所示:

CMD ["npm","--debug=5858","prod"]

猜你在找的Docker相关文章