Nginx unit Docker Run and PHP &&golang simple to use

Source: Internet
Author: User
Tags configuration php php language docker run

Note: Nginx unit nginx Open source new Nginx development platform, but plainly, personal feeling general, and official documents are not very good, API interface currently temporary document comparison .... , previously written about how virtual machines && physical machines were installed and deployed today, write a way to install and deploy using Docker, and add the use of the Golang language as a comparison, after all, most companies use containers again. 1. Reference items
https://github.com/rongfengliang/nginx-unit-docker-demo
2. Project description
A. Project structure ├──dockerfile//Docker build ├──jenkinsfile//Jenkins build ├──readme.md├──app.go//Golang language support ├──docker-compo  SE.YML//Docker-compose build ├──run.sh//application configuration, via rest interface ├──start.json//application configuration PHP && golang└──website└── index.php//php language B. Code description (Multi-stage build with Docker) Dockerfile Docker build from Golang:stretch as Build-envrun apt-get update# RUN apt-get install-y build-es Sentialrun git clone https://github.com/nginx/unit.git/go/src/github.com/nginx/unit## Note that the version must be consistent with your unit, or error, This is not good, it may be related to the current production availability. # # This is primarily the build of the Golang SDK run Cd/go/src/github.com/nginx/unit && git checkout tags/1.1 && amp;./configure &&./configure go && make go-installadd. /go/src/github.com/rongfengliang/nginx-unit-gorun cd/go/src/github.com/rongfengliang/nginx-unit-go && Go Build-o/appdemo app.gofrom nginx/unit:1.1-fullworkdir/appdemoadd start.json/appdemo/start.json COPY Website/appdemo /website/copy--from=build-env/appdemo/appdemo/website/appdemoexpoSE 8080 8000 8081CMD ["/USR/SBIN/UNITD", "--no-daemon", "--control", "0.0.0.0:8000"]jenkinsfile jenkinspipeline        Build Pipeline {agent {node {label ' docker-65 '}} stages {stage (' docker-compose build ') {steps { Sh ' docker-compose Build '}} stage (' Docker-compose run ') {steps {sh ' docker-compose up-d '}} stage (' Deploy service ') {steps {sh './run.sh '}}}}app.go Golang support Package Maini  Mport ("math" "net/http" "Nginx/unit" # # Note the unit version, feel a little bad, because the version cannot be published service) func term (Ch Chan float64, k float64) {ch <-4 * Math. Pow ( -1, K)/(2*k + 1)}func handler (w http. Responsewriter, R *http. Request) {W.write ([]byte ("Appdemorong"))}func Main () {http. Handlefunc ("/", Handler)//http. Listenandserve (": 8080", nil) unit.    Listenandserve (": 8089", nil)}docker-compose.yml relatively simple, needless to say version: "3" Services:nginx-unit:build:context:. Image:myunit ports:-"9080:8080"-"9000:8000"-"9001:8081" Run.sh Service Registration Shell#!/bin/shcurl-x put-d @ $PWD/start.json Http://localhost:9000start.json Description of the service configuration {"Listeners": {    "*:8080": {"Application": "Phpindex"}, "*:8081": {"Application": "Golang"} }, "Applications": {"Phpindex": {"type": "PHP", "processes": +, "root": "/appdemo/            Website "," index ":" index.php "}," Golang ": {" type ":" Go "," processes ": 30,  "Working_directory": "/appdemo/website", "Executable": "Appdemo"}}}website/index.php PHP Language support <?php phpinfo ()?>
3. Build && Start
docker-compose builddocker-compose up -d
4. Publishing services
./run.sh
5. Effect A. List of registered Services B.  Golang Service access C. PHP Service Access 6. Extended
多版本切换以及多版本也比较简单,就是服务注册配置文件的处理,总的来说,挺好的功能,但是在微服务,以及service mesh 的大趋势之下,就显得没有那么好的,
也只是个人的观点
7. References
http://unit.nginx.org/https://github.com/rongfengliang/nginx-unit-docker-demo

Nginx unit Docker Run and PHP &&golang simple to use

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.