zoukankan      html  css  js  c++  java
  • Dockerfile 构建前端node应用cnpm命令启动nodejs服务

    cat Dockerfile.node 
    FROM centos
    
    
    MAINTAINER zha*****ch.cn
    
    ENV LANG en_US.UTF-8
     
    RUN /bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai' >/etc/timezone
    
    
    WORKDIR /home
      
    RUN mkdir node
    
    COPY node-v8.14.0-linux-x64.tar.gz /home/
    
    COPY web-monitor /home/node/web-monitor
    
    RUN tar zxf /home/node-v8.14.0-linux-x64.tar.gz -C /home/node
    
    
    ENV PATH PATH=$PATH:$HOME/bin:/home/node/node-v8.14.0-linux-x64/bin
    
    RUN npm install cnpm -g 
    
    WORKDIR  /home/node/web-monitor
    
    
    EXPOSE 8002
    
    ENTRYPOINT cnpm i  && npm run ci  && tail -f /root/logs/master-stdout.log 
    

      

    构建镜像
    
    [root@weifeng02 dockerfile]# docker build -t web-monitor -f Dockerfile.node . 
    Sending build context to Docker daemon 174.1 MB
    Step 1/14 : FROM centos
     ---> 1e1148e4cc2c
    
    ****
    
    Step 14/14 : ENTRYPOINT cnpm i  && npm run ci  && tail -f /root/logs/master-stdout.log
     ---> Using cache
     ---> f221cdd3dd0a
    Successfully built f221cdd3dd0a
    

      

    命令启动docker 镜像
    
    [root@weifeng02 dockerfile]# docker run -d -p 8002 web-monitor
    68afcb89348a69781694f01afabb8658ce8ea2b4f15b160d33c3e9f394e8bc17
    [root@weifeng02 dockerfile]# 
    [root@weifeng02 dockerfile]# docker ps
    CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                     NAMES
    68afcb89348a        web-monitor         "/bin/sh -c 'cnpm ..."   4 seconds ago       Up 3 seconds        0.0.0.0:32784->8002/tcp   elastic_heyrovsky
    

      

  • 相关阅读:
    从OkHttp的源码来看 HTTP
    从Retrofit的源码来看 HTTP
    登录授权、TCP/IP、HTTPS
    编码、加密、Hash
    java获取当前系统时间
    mybatis自动生成
    rabbitMQ权限相关命令
    在Spring Boot中使用Spring Security实现权限控制
    学习sharding-jdbc 分库分表扩展框架
    Jenkins的关闭、重启
  • 原文地址:https://www.cnblogs.com/weifeng1463/p/10439391.html
Copyright © 2011-2022 走看看