在Jexus独立版出来之前都是需要采用Mono + Jexus的方式来部署Asp.NET MVC项目。现在只需用Jexus独立版就可以完成部署工作。
Jexus部署Asp.NET需要的文件
Dockerfile
FROM ubuntu:latest MAINTAINER Mongo<mongode@163.com> RUN apt-get update \ && apt-get -y upgrade RUN apt-get -y install wget \ && cd /usr \ && wget --no-check-certificate linuxdot.net/down/jexus-5.8.2.tar.gz \ && tar -zxvf jexus-5.8.2.tar.gz \ && ./jexus-5.8.2/install \ && rm -r jexus-5.8.2.tar.gz \ && apt-get -y autoremove wget COPY default /usr/jexus/siteconf/default EXPOSE 80 WORKDIR /usr/jexus CMD /usr/jexus/jws start && tail -f
default
###################### # Web Site: Default ######################################## port=80 root=/ /var/www/jexus hosts=* #OR your.com,*.your.com # addr=0.0.0.0 # CheckQuery=false NoLog=true # AppHost.Port=5000 # NoFile=/index.aspx # Keep_Alive=false # UseGZIP=false # UseHttps=true # DenyFrom=192.168.0.233, 192.168.1.*, 192.168.2.0/24 # AllowFrom=192.168.*.* # DenyDirs=~/cgi, ~/upfiles # indexes=myindex.aspx # rewrite=^/.+?\.(asp|php|cgi|pl|sh)$ /index.aspx # reproxy=/bbs/ http://192.168.1.112/bbs/ # host.Redirect=abc.com www.abc.com 301 # ResponseHandler.Add=myKey:myValue # Jexus php fastcgi address is '/var/run/jexus/phpsvr' ####################################################### # fastcgi.add=php|socket:/var/run/jexus/phpsvr # php-fpm listen address is '127.0.0.1:9000' ############################################ # fastcgi.add=php|tcp:127.0.0.1:9000
MVC Demo
MVC Demo下载链接;提取密码:h45o
部署Asp.NET MVC Demo
根据Dockerfile构建镜像
创建脚本;
vim start.sh
编辑脚本,内容如下;
#!/bin/bash
EXPORT="8099"
docker stop jmvc
docker rm jmvc
docker rmi jmvc:latest
docker rmi $(docker images | awk '$1 == "<none>" && $2 == "<none>" {print $3}')
docker build -t jmvc:latest .
docker run -d -p $EXPORT:80 --name jmvc --restart=always -v $(pwd)/mvcdemo:/var/www/jexus jmvc:latest
echo
ip addr show eth1 | awk '$1 == "inet" {split($2,ip,"/");print "Please use the browser to access this address => http://"ip[1]":""'"$EXPORT"'"}'
echo
赋予脚本可执行权限;
chmod +x ./start.sh
创建并启动容器
运行脚本;
./start.sh
然后就可以点击页面输出的网址通过浏览器进行访问了。