• docker 启动 reactjs


    # Dockerfile
    
    # base image
    FROM node:latest
    
    LABEL maintainer="B**** Dev <b****dev@****.com>"
    
    # set working directory
    WORKDIR /app
    
    EXPOSE 3000
    # EXPOSE 80
    
    # add `/app/node_modules/.bin` to $PATH
    # ENV NODE_PATH=/app/node_modules
    # ENV PATH=/app/node_modules/.bin:$PATH
    
    ENV "LC_ALL"="en_US.UTF-8"
    ENV "LANG"="en_US.UTF-8"
    ENV "LANGUAGE"="en_US.UTF-8"
    # ARG registry=https://registry.npm.taobao.org
    # ARG disturl=https://npm.taobao.org/dist
    # ARG sass_binary_site=http://cdn.npm.taobao.org/dist/node-sass
    # ARG SASS_BINARY_SITE=https://npm.taobao.org/mirrors/node-sass/ npm install node-sass
    
    
    # install and cache app dependencies
    COPY yarn.lock /app/yarn.lock
    COPY package.json /app/package.json
    # COPY src ./src
    # COPY public ./public
    # COPY node_modules ./node_modules
    
    # RUN npm config set registry https://registry.npm.taobao.org
    # RUN npm config set sass_binary_site http://cdn.npm.taobao.org/dist/node-sass
    # RUN npm install
    # RUN npm install react-scripts@3.4.1 -g
    # RUN npm install react-scripts@3.0.1 -g --silent
    # RUN npm install --save next react react-dom
    
    RUN yarn config set registry https://registry.npm.taobao.org 
    RUN yarn config set sass_binary_site http://cdn.npm.taobao.org/dist/node-sass
    RUN yarn
    RUN yarn add react-scripts@3.4.1
    
    COPY . /app
    RUN yarn install
    RUN yarn build
    
    # start app
    ENTRYPOINT ["/bin/bash", "/app/run.sh"]
    CMD ["start"]
    # RUN npm run build
    

      

    PS D:********.WebSitejsx> docker build -t website-reactjs:v10 .
    
    
    PS D:********.WebSitejsx>docker run -i -v ${PWD}:/app -v /app/node_modules -p 3001:3000 --rm 805147207dd5
    

      

    PS D:********.WebSitejsx> docker tag website-reactjs:v10 192.168.33.21:5000/westwin/msap/website-reactjs:v10 
    
    PS D:********.WebSitejsx> docker push 192.***.**.**:5000/westwin/msap/website-reactjs:v10 
    
    
    PS D:WestWinProjectsmsapSourceMSAP.WebSitejsx> docker pull 192.***.**.**:5000/westwin/msap/website-reactjs:v10 
    

      

    # run.sh
    
    #!/usr/bin/env bash
    set -eo pipefail
    
    case $1 in
      start)
        # The '| cat' is to trick Node that this is an non-TTY terminal
        # then react-scripts won't clear the console.
        yarn start | cat
        ;;
      build)
        yarn build
        ;;
      test)
        yarn test $@
        ;;
      *)
        exec "$@"
        ;;
    esac
    

      

  • 相关阅读:
    Raft协议备注
    领域建模笔记
    Spark编程模型
    Spark如何删除无效rdd checkpoint
    Parquet 列式存储格式
    SpringBoot中ConditionalOnClass注解的原理
    SpringBoot定制Sevlet容器原理
    分析JDK的动态代理原理
    简述SpringCloud底层原理
    简述SpringCloud框架
  • 原文地址:https://www.cnblogs.com/panpanwelcome/p/12599270.html
Copyright © 2020-2023  润新知