部署react 应用

  1. FROM 192.168.100.36:1179/xiaoke/node:12.15.0 AS builder
  2. WORKDIR /home/node/app
  3. COPY package.json .yarnrc /home/node/app/
  4. RUN yarn config set registry https://registry.npm.taobao.org/ && yarn
  5. COPY . /home/node/app
  6. RUN npm run build:test
  7. FROM 192.168.100.36:1179/xiaoke/nginx:alpine
  8. COPY --from=builder /home/node/app/nginx.default.conf /etc/nginx/conf.d/default.conf
  9. COPY --from=builder /home/node/app/build /usr/share/nginx/html
  10. EXPOSE 80
  11. 其中nginx.default.conf
  12. server {
  13. listen 80 default_server;
  14. index index.html;
  15. server_name localhost;
  16. location / {
  17. root /usr/share/nginx/html/;
  18. index index.html;
  19. try_files $uri $uri/ /index.html;
  20. expires -1;
  21. add_header Cache-Control max-age=0;
  22. }
  23. }


部署node 应用

  1. FROM 192.168.100.36:1179/base/node:v1
  2. WORKDIR /home/node/app/
  3. ENV HOME=/home/node/app/ \
  4. APP_NAME=home \
  5. ENABLE_NODE_LOG=YES \
  6. NODE_LOG_DIR=/tmp
  7. COPY package.json .yarnrc ./
  8. RUN yarn
  9. COPY . ./
  10. RUN npm run build:test
  11. EXPOSE 80
  12. EXPOSE 6020
  13. CMD ["./release/pm2start.sh"]
  14. 其中pm2start.sh内容为
  15. #!/bin/sh
  16. echo $NODE_ENV
  17. pm2-runtime start ecosystem.config.js --env $NODE_ENV

部署java 应用

  1. FROM 192.168.100.36:1179/kkb/jre-sky-agent:alpine_v1
  2. ADD run.sh /
  3. RUN chmod +x /run.sh
  4. RUN sed -i 's/dl-cdn\.alpinelinux\.org/mirrors\.aliyun\.com/g' /etc/apk/repositories
  5. ADD app.jar /
  6. CMD ["/run.sh"]
  7. 其中 app.jar为实际项目打成jar包以后改名为app.jar,例如 mv corgi-message.jar app.jar
  8. 其中run.sh的内容为
  9. #!/bin/sh
  10. JAVA_OPTS=${JAVA_OPTS:-"-Dfile.encoding=UTF-8"}
  11. CATALINA_OPTS="$CATALINA_OPTS $JAVA_OPTS"
  12. if [[ ${PROFILE} = "dev" ]] ; then
  13. CATALINA_OPTS="$CATALINA_OPTS -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=5006,suspend=n"
  14. fi
  15. echo ${CATALINA_OPTS}
  16. java ${CATALINA_OPTS} -Duser.timezone=Asia/Shanghai -Dfile.encoding=utf-8 -jar /app.jar --spring.profiles.active=${PROFILE}



部署python 应用

  1. FROM 192.168.100.36:1179/xiaoke/api-test-frunner-server:v7
  2. WORKDIR /opt/
  3. RUN mkdir -p /usr/share/nginx/html/
  4. RUN yum -y install kde-l10n-Chinese glibc-common
  5. RUN cp -f /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
  6. RUN localedef -c -f UTF-8 -i zh_CN zh_CN.UFT-8 && echo 'LANG="zh_CN.uft8"' > /etc/locale.conf && export LC_ALL="zh_CN.uft8" && echo 'LANG="zh_CN.uft8"' >>/etc/profile && echo "export LC_ALL="zh_CN.uft8"" >>/etc/profile
  7. ENV LC_ALL="zh_CN.uft8"
  8. ENV LANG="zh_CN.uft8"
  9. RUN echo "if [ -f /etc/bashrc ]; then"> ~/.bashrc && \
  10. echo " . /etc/bashrc" >> ~/.bashrc && \
  11. echo "source /etc/profile" >> ~/.bashrc && \
  12. echo "fi" >> ~/.bashrc
  13. RUN /usr/local/python3/bin/pip3 install -r /opt/FasterRunner/requirements.txt --no-cache
  14. RUN /usr/local/python3/bin/easy_install-3.6 install email
  15. RUN mkdir -p /opt/FasterRunner/logs
  16. EXPOSE 8113
  17. CMD ["supervisord", "-n", "-c", "/opt/FasterRunner/conf/supervisor-app.conf"]

部署php 应用