docker 启动 reactjs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# 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

  

1
2
3
4
PS D:\********.WebSite\jsx> docker build -t website-reactjs:v10 .
 
 
PS D:\********.WebSite\jsx>docker run -i -v ${PWD}:/app -v /app/node_modules -p 3001:3000 --rm 805147207dd5

  

 

1
2
3
4
5
6
PS D:\********.WebSite\jsx> docker tag website-reactjs:v10 192.168.33.21:5000/westwin/msap/website-reactjs:v10
 
PS D:\********.WebSite\jsx> docker push 192.***.**.**:5000/westwin/msap/website-reactjs:v10
 
 
PS D:\WestWin\Projects\msap\Source\MSAP.WebSite\jsx> docker pull 192.***.**.**:5000/westwin/msap/website-reactjs:v10

  

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# 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

  

posted @   PanPan003  阅读(322)  评论(0编辑  收藏  举报
编辑推荐:
· 没有源码,如何修改代码逻辑?
· 一个奇形怪状的面试题:Bean中的CHM要不要加volatile?
· [.NET]调用本地 Deepseek 模型
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· .NET Core 托管堆内存泄露/CPU异常的常见思路
阅读排行:
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· DeepSeek R1 简明指南:架构、训练、本地部署及硬件要求
· 没有源码,如何修改代码逻辑?
· NetPad:一个.NET开源、跨平台的C#编辑器
· 面试官:你是如何进行SQL调优的?
历史上的今天:
2018-03-30 Druid介绍2
2018-03-30 Druid介绍
2018-03-30 facebook ads api 全面介绍
2018-03-30 pgAdmin的数据导入之CSV
2018-03-30 代码规范
点击右上角即可分享
微信分享提示