部署react 应用
FROM 192.168.100.36:1179/xiaoke/node:12.15.0 AS builder
WORKDIR /home/node/app
COPY package.json .yarnrc /home/node/app/
RUN yarn config set registry https://registry.npm.taobao.org/ && yarn
COPY . /home/node/app
RUN npm run build:test
FROM 192.168.100.36:1179/xiaoke/nginx:alpine
COPY --from=builder /home/node/app/nginx.default.conf /etc/nginx/conf.d/default.conf
COPY --from=builder /home/node/app/build /usr/share/nginx/html
EXPOSE 80
其中nginx.default.conf为
server {
listen 80 default_server;
index index.html;
server_name localhost;
location / {
root /usr/share/nginx/html/;
index index.html;
try_files $uri $uri/ /index.html;
expires -1;
add_header Cache-Control max-age=0;
}
}
部署node 应用
FROM 192.168.100.36:1179/base/node:v1
WORKDIR /home/node/app/
ENV HOME=/home/node/app/ \
APP_NAME=home \
ENABLE_NODE_LOG=YES \
NODE_LOG_DIR=/tmp
COPY package.json .yarnrc ./
RUN yarn
COPY . ./
RUN npm run build:test
EXPOSE 80
EXPOSE 6020
CMD ["./release/pm2start.sh"]
其中pm2start.sh内容为
#!/bin/sh
echo $NODE_ENV
pm2-runtime start ecosystem.config.js --env $NODE_ENV
部署java 应用
FROM 192.168.100.36:1179/kkb/jre-sky-agent:alpine_v1
ADD run.sh /
RUN chmod +x /run.sh
RUN sed -i 's/dl-cdn\.alpinelinux\.org/mirrors\.aliyun\.com/g' /etc/apk/repositories
ADD app.jar /
CMD ["/run.sh"]
其中 app.jar为实际项目打成jar包以后改名为app.jar,例如 mv corgi-message.jar app.jar
其中run.sh的内容为
#!/bin/sh
JAVA_OPTS=${JAVA_OPTS:-"-Dfile.encoding=UTF-8"}
CATALINA_OPTS="$CATALINA_OPTS $JAVA_OPTS"
if [[ ${PROFILE} = "dev" ]] ; then
CATALINA_OPTS="$CATALINA_OPTS -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=5006,suspend=n"
fi
echo ${CATALINA_OPTS}
java ${CATALINA_OPTS} -Duser.timezone=Asia/Shanghai -Dfile.encoding=utf-8 -jar /app.jar --spring.profiles.active=${PROFILE}
部署python 应用
FROM 192.168.100.36:1179/xiaoke/api-test-frunner-server:v7
WORKDIR /opt/
RUN mkdir -p /usr/share/nginx/html/
RUN yum -y install kde-l10n-Chinese glibc-common
RUN cp -f /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
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
ENV LC_ALL="zh_CN.uft8"
ENV LANG="zh_CN.uft8"
RUN echo "if [ -f /etc/bashrc ]; then"> ~/.bashrc && \
echo " . /etc/bashrc" >> ~/.bashrc && \
echo "source /etc/profile" >> ~/.bashrc && \
echo "fi" >> ~/.bashrc
RUN /usr/local/python3/bin/pip3 install -r /opt/FasterRunner/requirements.txt --no-cache
RUN /usr/local/python3/bin/easy_install-3.6 install email
RUN mkdir -p /opt/FasterRunner/logs
EXPOSE 8113
CMD ["supervisord", "-n", "-c", "/opt/FasterRunner/conf/supervisor-app.conf"]
部署php 应用