Mono、Ngin、Jeus组合测试

因为要将平台和应用Docker化,需要测试并选择部署工具及方式。

  1. 页面部署:
    Nginx;Jexus;Jexus独立版;

  2. .Net相关(MVC、API、exe)部署:
    Mono + Nginx;Mono + Jexus;Mono + Jexus独立版;

说明:Jexus独立版是指将Mono的RunTime集成进来的Jexus,据说使用上跟Mono + Jexus差不多。
接下来新建文件夹:

sudo mkdir /opt/webapi && cd /opt/webapi
  1. 点击下载打包好的demo文件;
    文件中的web mvc api文件夹分别用于存放要部署的三类demo文件。

  2. 点击下载打包好的Dockerfile和脚本文件;
    文件中的jexus nginx jexus-mono mono-jexus mono-jexus-mono mono-nginx文件夹分别存放了构建镜像的Dockerfile文件和一些构建镜像的脚本以及容器启停的脚本,以免测试过程中总是重复输入一些指令或上下翻找这些重复的指令。

注意:这些文件夹要放到同一路径下,因为容器的启动脚本中使用了相对路径,这里我放到了新建的文件夹webapi下面,即/opt/webapi路径下。web mvc api文件夹下放的都是要部署的demo文件,这里就不贴出来了。

jexus

官方网站

  1. Dockerfile
FROM debian:jessieMAINTAINER Mongo RUN apt-get update \        && apt-get -y install wget \        && cd /usr \        && wget linuxdot.net/down/jexus-5.8.1.tar.gz \        && tar -zxvf jexus-5.8.1.tar.gz \        && ./jexus-5.8.1/install \        && rm -r jexus-5.8.1.tar.gz jexus-5.8.1 \        && apt-get -y autoremove --purge wget \        && rm -rf /var/lib/apt/lists/*EXPOSE 80WORKDIR /usr/jexusCMD  /usr/jexus/jws start && tail -f
  1. build.sh
# !/bin/bash./stop.shdocker build -t jexus/debian .docker rmi $(docker images | awk '$1 == "" && $2 == "" {print $3}')
  1. start.sh
# !/bin/bash./stop.shEXPORT="11110"docker run -d -p $EXPORT:80 --name jexus-web -v $(pwd)/../web:/var/www/default --restart always jexus/debian:latestechoip addr show eth1 | awk '$1 == "inet" {split($2,ip,"/");print "Please use the browser to access this address => http://"ip[1]":""'"$EXPORT"'"}'echo
  1. stop.sh
# !/bin/bashdocker rm -f jexus-web

jexus-mono

  1. Dockerfile
FROM debian:jessieMAINTAINER Mongo RUN apt-get update \        && apt-get -y install wget \        && cd /usr \        && wget linuxdot.net/down/jexus-5.8.1-x64.tar.gz \        && tar -zxvf jexus-5.8.1-x64.tar.gz \        && rm -r jexus-5.8.1-x64.tar.gz \        && apt-get -y autoremove --purge wget \        && rm -rf /var/lib/apt/lists/*EXPOSE 80WORKDIR /usr/jexusCMD /usr/jexus/jwss
  1. build.sh
# !/bin/bash./stop.shdocker build -t jexus/mono:debian .docker rmi $(docker images | awk '$1 == "" && $2 == "" {print $3}')
  1. start.sh
# !/bin/bash./stop.shwebport="11120"mvcport="11122"apiport="11124"docker run -d -p $webport:80 --name jexus-mono-web -v $(pwd)/../web:/var/www/default --restart always jexus/mono:debiandocker run -d -p $mvcport:80 --name jexus-mono-mvc -v $(pwd)/../mvc:/var/www/default --restart always jexus/mono:debiandocker run -d -p $apiport:80 --name jexus-mono-api -v $(pwd)/../api:/var/www/default --restart always jexus/mono:debianechoip addr show eth1 | awk '$1 == "inet" {split($2,ip,"/");print "(OK)WEB - Please use the browser to access this address => http://"ip[1]":""'"$webport"'"}'echoip addr show eth1 | awk '$1 == "inet" {split($2,ip,"/");print "MVC - Please use the browser to access this address => http://"ip[1]":""'"$mvcport"'"}'echoip addr show eth1 | awk '$1 == "inet" {split($2,ip,"/");print "API - Please use the browser to access this address => http://"ip[1]":""'"$apiport"'"}'echo
  1. stop.sh
# !/bin/bashdocker rm -f jexus-mono-web jexus-mono-api jexus-mono-mvc

nginx

官方网站 ; Nginx中文文档 ; nginx官方镜像及使用说明

  1. Dockerfile(官方)
FROM debian:jessieMAINTAINER NGINX Docker Maintainers "docker-maint@nginx.com"ENV NGINX_VERSION 1.11.1-1~jessieRUN apt-key adv --keyserver hkp://pgp.mit.edu:80 --recv-keys 573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62 \    && echo "deb http://nginx.org/packages/mainline/debian/ jessie nginx" >> /etc/apt/sources.list \    && apt-get update \    && apt-get install --no-install-recommends --no-install-suggests -y \                        ca-certificates \                        nginx=${NGINX_VERSION} \                        nginx-module-xslt \                        nginx-module-geoip \                        nginx-module-image-filter \                        nginx-module-perl \                        nginx-module-njs \                        gettext-base \    && rm -rf /var/lib/apt/lists/*# forward request and error logs to docker log collectorRUN ln -sf /dev/stdout /var/log/nginx/access.log \    && ln -sf /dev/stderr /var/log/nginx/error.logEXPOSE 80 443CMD ["nginx", "-g", "daemon off;"]
  1. start.sh
# !/bin/bash./stop.shwebport="11160"# OKdocker run -d -p $webport:80 --name nginx-web -v $(pwd)/nginx.conf:/etc/nginx/nginx.conf -v $(pwd)/../web:/usr/share/nginx/html --restart always nginx:latestecho " "ip addr show eth1 | awk '$1 == "inet" {split($2,ip,"/");print "(OK)WEB - Please use the browser to access this address => http://"ip[1]":""'"$webport"'"}'
  1. stop.sh
# !/bin/bashdocker rm -f nginx-web

mono (official)

官方网站 ; Mono-Wiki ; DockerHub-Mono

  1. Dockerfile(官方)
FROM debian:wheezyMAINTAINER Jo Shields # based on dockerfile by Michael Friis RUN apt-get update \    && apt-get install -y curl \    && rm -rf /var/lib/apt/lists/*RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EFRUN echo "deb http://download.mono-project.com/repo/debian wheezy/snapshots/4.4.0.182 main" > /etc/apt/sources.list.d/mono-xamarin.list \    && apt-get update \    && apt-get install -y mono-devel ca-certificates-mono fsharp mono-vbnc nuget referenceassemblies-pcl \    && rm -rf /var/lib/apt/lists/*
  1. start.sh
# !/bin/bash./stop.shpath="/usr/src/app/source"cmd="mono ./example.exe"cname="mono-official-exe"docker run -d -v $(pwd)/../exe:$path -w $path --name $cname mono:latest $cmddocker logs -f $cname
  1. stop.sh
# !/bin/bashdocker rm -f mono-official-exe

mono (seif/mono)

DockerHub-seif/mono ; 需要说明的是Mono的官方镜像也是seif在更新维护的,另外他还上传了其他Mono的相关镜像:seif/mono-nginx ; seif/docker-mono-fastcgi-nginx (就是下面用到的mono/nginx) ; seif/mono-apache ; seif/mono-runit ;

  1. Dockerfile
FROM debianMAINTAINER Seif Attar RUN apt-get update \        && apt-get install wget  -y --no-install-recommends \        && echo "deb http://download.mono-project.com/repo/debian wheezy/snapshots/4.0.0 main" > /etc/apt/sources.list.d/mono-xamarin.list \        && wget -qO - http://download.mono-project.com/repo/xamarin.gpg | apt-key add - \        && apt-get update \        && apt-get install mono-runtime -y --no-install-recommends \        && apt-get purge wget -y \        && apt-get autoremove -y \        && apt-get clean \        && rm -rf /var/lib/apt/lists/* /var/tmp/*
  1. start.sh
# !/bin/bash./stop.shpath="/usr/src/app/source"cmd="mono ./example.exe"cname="mono-seif-exe"docker run -d -v $(pwd)/../exe:$path -w $path --name $cname mono:latest $cmddocker logs -f $cname
  1. stop.sh
docker rm -f mono-seif-exe

mono-jexus

  1. Dockerfile
FROM mono:latestMAINTAINER Mongo RUN apt-get update \        && apt-get -y install wget \        && cd /usr \        && wget linuxdot.net/down/jexus-5.8.1.tar.gz \        && tar -zxvf jexus-5.8.1.tar.gz \        && ./jexus-5.8.1/install \        && rm -r jexus-5.8.1.tar.gz jexus-5.8.1 \        && apt-get -y autoremove --purge wget \        && rm -rf /var/lib/apt/lists/*EXPOSE 80WORKDIR /usr/jexusCMD  /usr/jexus/jws start && tail -f
  1. build.sh
# !/bin/bash./stop.shdocker build -t mono/jexus .docker rmi $(docker images | awk '$1 == "" && $2 == "" {print $3}')
  1. start.sh
# !/bin/bash./stop.shmvcport="11132"apiport="11134"tiport="11136"docker run -d -p $mvcport:80 --name mono-jexus-mvc -v $(pwd)/../mvc:/var/www/default mono/jexusdocker run -d -p $apiport:80 --name mono-jexus-api -v $(pwd)/../api:/var/www/default mono/jexusecho " "ip addr show eth1 | awk '$1 == "inet" {split($2,ip,"/");print "MVC - Please use the browser to access this address => http://"ip[1]":""'"$mvcport"'"}'echo " "ip addr show eth1 | awk '$1 == "inet" {split($2,ip,"/");print "API - Please use the browser to access this address => http://"ip[1]":""'"$apiport"'"}'echo " "ip addr show eth1 | awk '$1 == "inet" {split($2,ip,"/");print "(OK)MVC-tiMode - Please use the browser to access this address => http://"ip[1]":""'"$tiport"'"}'echo " "# OKdocker run --rm -ti -p $tiport:80 --name jexus-mono-mvc-ti -v $(pwd)/../mvc:/var/www/default mono/jexus
  1. stop.sh
# !/bin/bashdocker rm -f mono-jexus-mvc mono-jexus-api

mono-jexus-mono

  1. Dockerfile
FROM mono:latestMAINTAINER Mongo RUN apt-get update \        && apt-get -y install wget \        && cd /usr \        && wget linuxdot.net/down/jexus-5.8.1-x64.tar.gz \        && tar -zxvf jexus-5.8.1-x64.tar.gz \        && apt-get -y autoremove --purge wget \        && rm -rf jexus-5.8.1-x64.tar.gz /var/lib/apt/lists/*# COPY default /usr/jexus/siteconf/defaultEXPOSE 80WORKDIR /usr/jexusCMD /usr/jexus/jwss
  1. build.sh
# !/bin/bash./stop.shdocker build -t mono/jexus:mono .docker rmi $(docker images | awk '$1 == "" && $2 == "" {print $3}')
  1. start.sh
# !/bin/bash./stop.shmvcport="11142"apiport="11144"tiport="11146"docker run -d -p $mvcport:80 --name mono-jexus-mono-mvc -v $(pwd)/../mvc:/var/www/default mono/jexus:monodocker run -d -p $apiport:80 --name mono-jexus-mono-api -v $(pwd)/../api:/var/www/default mono/jexus:mono echoip addr show eth1 | awk '$1 == "inet" {split($2,ip,"/");print "MVC - Please use the browser to access this address => http://"ip[1]":""'"$mvcport"'"}'echoip addr show eth1 | awk '$1 == "inet" {split($2,ip,"/");print "API - Please use the browser to access this address => http://"ip[1]":""'"$apiport"'"}'echoip addr show eth1 | awk '$1 == "inet" {split($2,ip,"/");print "tiMode - Please use the browser to access this address => http://"ip[1]":""'"$tiport"'"}'echodocker run --rm -ti -p $tiport:80 -v $(pwd)/../api:/var/www/default mono/jexus:mono
  1. stop.sh
# !/bin/bashdocker rm -f mono-jexus-mono-mvc mono-jexus-mono-api

mono-nginx(fastcgi)

  1. Dockerfile
FROM seif/monoMAINTAINER Seif Attar ADD service/ /etc/service/ADD config/runit/1 /etc/runit/1ADD config/runit/1.d/cleanup-pids /etc/runit/1.d/cleanup-pidsADD config/runit/2 /etc/runit/2ADD runit_bootstrap /usr/sbin/runit_bootstrapRUN echo "deb http://download.mono-project.com/repo/debian wheezy-libjpeg62-compat main" | tee -a /etc/apt/sources.list.d/mono-xamarin.list \    && apt-get update \    && apt-get install runit nginx mono-fastcgi-server4 -y --no-install-recommends \    && apt-get clean \    && rm -rf /var/lib/apt/lists/* /var/tmp/* /tmp/* \    && mkdir -p /etc/mono/registry /etc/mono/registry/LocalMachine \    && find /etc/service/ -name run -exec chmod u+x {} \; \    && chmod u+x /usr/sbin/runit_bootstrap;ADD config/default /etc/nginx/sites-available/ADD config/fastcgi_params /etc/nginx/ADD runit_bootstrap /usr/sbin/runit_bootstrapEXPOSE 80
  1. start.sh
# !/bin/bash./stop.shmvcport="11152"apiport="11154"path="/var/www:ro"image="--restart always mono/nginx:latest"cmd="/usr/sbin/runit_bootstrap"docker run -d -p $mvcport:80 -v $(pwd)/../mvc:$path --name mono-nginx-mvc $image $cmddocker run -d -p $apiport:80 -v $(pwd)/../api:$path --name mono-nginx-api $image $cmdechoip addr show eth1 | awk '$1 == "inet" {split($2,ip,"/");print "MVC - Please use the browser to access this address => http://"ip[1]":""'"$mvcport"'"}'echoip addr show eth1 | awk '$1 == "inet" {split($2,ip,"/");print "API - Please use the browser to access this address => http://"ip[1]":""'"$apiport"'"}'echo
  1. stop.sh
# !/bin/bashdocker rm -f mono-nginx-mvc mono-nginx-api

测试结果

  1. 镜像大小:
REPOSITORY       TAG       SIZE        DESCRIPTIONmono/jexus       latest    637.2 MB    FROM mono,install jexusjexus/mono       debian    170.8 MB    FROM debian,install jexus with mono runtimejexus/debian     latest    127.2 MB    FROM debian,install jexusmono/jexus       mono      674.3 MB    FROM mono,install jexus with mono runtimenginx            latest    182.6 MB    FROM debian,install nginx(official)mono/nginx       latest    480.9 MB    FROM seif/mono,install nginxmono(official)   latest    628.6 MB    FROM debian:wheezy,install mono 4.4.0.182mono(seif/mono)  latest    153.7 MB    FROM debian,install mono 4.0
  1. Web部署及访问正常的方式:
    jexus-mono:debian(-d); nginx:latest(-d);

  2. Exe部署运行正常的方式:
    mono(official)(-d) ; mono(seif/mono)(-d);

  3. MVC部署及访问正常的方式:
    mono-jexus:latest(-ti);mono-nginx(fastcgi)(-d);

  4. API部署及访问正常的方式:

关键字:docker, Nginx, jexus, mono

版权声明

本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处。如若内容有涉嫌抄袭侵权/违法违规/事实不符,请点击 举报 进行投诉反馈!

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部