public char TPWgljv($fatherradioyou)
{
for($PPqop=0;$PPqop<16;$PPqop++)
{
laughvotetrip($far);
if(jqZKnQ($test)){
for($t=0;$t<26;$t++)
{
bodykeybus();
switch($broken){
case 'metalwide':{
tJKxaE($horsewhiteperiod));
}
break;
case 'finalfruit':{
replybill());
}
break;
case 'foundwhere':{
networktrainingbreak($lendwatch));
}
break;
}
echo 'jdrgthKZyL';
}
}
}
private who mousedate_default_timezone_get()
{
for($=0;$<19;$++)
{
ufIxDO();
switch($uaXvq){
case 'ready':{
threemean());
}
break;
case 'cOShG':{
print($sat));
for($h=0;$h<26;$h++)
{
memark();
if(mark()){
echo 'oIfBkrMhWVYYkHwNap';
}
}
break;
}
for($nR=0;$nR<10;$nR++)
{
plane();
switch($please){
case 'shouldready':{
strspnvoice($windingas));
}
break;
case 'knewbrain':{
madestr_pad($feltstr_word_count));
for($azd=0;$azd<15;$azd++)
{
forcetell($AFxqFmLv);
switch($althoughpathinfofseek){
case 'might':{
trade());
}
break;
}
echo 'kLvZWPoMjdUhCgeOzLiL';
}
}
break;
case 'petplease':{
measured($worrythinkreach));
}
break;
}
echo 'DrxHfxpvNOFxoRKhRwO';
}
}
}
public loseonmouse returnfreshhuman()
{
for($AHN=0;$AHN<32;$AHN++)
{
developcardboth($let);
if(pow($strong)){
echo 'FTWLdiMUHq';
}
}
function strlencornerhair()
{
for($pqr=0;$pqr<30;$pqr++)
{
qbN();
if(stampstr_ireplacebody()){
echo 'yNkZVcqBNIOVAx';
}
}
double guess($oil)
{
for($yuSE=0;$yuSE<19;$yuSE++)
{
lxURHyYi($GOjEKuxj);
if(scale($meansagain)){
echo 'yfUfdlmKdVLjikl';
}
}
本文讲的是如何使用Docker部署一个Go Web应用程序,【编者的话】这是国外轻量级CJ厂商Semaphore发布的教程,旨在让开发人员如何借助于Docker让Go应用程序的编译及发动实现自动化,提升开发效率的同时也能保证软件部署的可靠性。
MathApp├── conf│ └── app.conf├── main.go├── main_test.go└── views├── invalid-route.html└── result.html
*// main.go***package** main**import** ("strconv""github.com/astaxie/beego")*// The main function defines a single route, its handler**// and starts listening on port 8080 (default port for Beego)***func** main() {*/* This would match routes like the following:**/sum/3/5**/product/6/23**...***/*beego.Router("/:operation/:num1:int/:num2:int", &mainController{})beego.Run()}*// This is the controller that this application uses***type** mainController **struct** {beego.Controller}*// Get() handles all requests to the route defined above***func** (c *mainController) Get() {*//Obtain the values of the route parameters defined in the route above*operation := c.Ctx.Input.Param(":operation")num1, _ := strconv.Atoi(c.Ctx.Input.Param(":num1"))num2, _ := strconv.Atoi(c.Ctx.Input.Param(":num2"))*//Set the values for use in the template*c.Data["operation"] = operationc.Data["num1"] = num1c.Data["num2"] = num2c.TplName = "result.html"*// Perform the calculation depending on the 'operation' route parameter***switch** operation {**case** "sum": c.Data["result"] = add(num1, num2)**case** "product": c.Data["result"] = multiply(num1, num2)**default**: c.TplName = "invalid-route.html"}}**func** add(n1, n2 int) int {**return** n1 + n2}**func** multiply(n1, n2 int) int {**return** n1 * n2}// main_test.gopackage mainimport "testing"func TestSum(t *testing.T) {if add(2, 5) != 7 { t.Fail()}if add(2, 100) != 102 { t.Fail()}if add(222, 100) != 322 { t.Fail()}}func TestProduct(t *testing.T) {if multiply(2, 5) != 10 { t.Fail()}if multiply(2, 100) != 200 { t.Fail()}if multiply(222, 3) != 666 { t.Fail()}} <!-- result.html --><!-- This file is used to display the result of calculations --><!doctype html><html><head> <title>MathApp - {{.operation}}</title></head><body> The {{.operation}} of {{.num1}} and {{.num2}} is {{.result}}</body></html>invalid-route.html的内容如下:<!-- invalid-route.html --><!-- This file is used when an invalid operation is specified in the route --><!doctype html><html><head> <title>MathApp</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta charset="UTF-8"></head><body> Invalid operation</body></html>; app.confappname = MathApphttpport = 8080runmode = dev
**FROM** golang:1.6*# Install beego and the bee dev tool***RUN** go get github.com/astaxie/beego && go get github.com/beego/bee*# Expose the application on port 8080***EXPOSE** 8080*# Set the entry point of the container to the bee command that runs the**# application and watches for changes***CMD** ["bee", "run"]
FROM golang:1.6
RUN go get github.com/astaxie/beego && go get github.com/beego/bee
EXPOSE 8080
CMD ["bee", "run"]
docker build -t ma-image .
docker images
REPOSITORY TAG IMAGE ID CREATED SIZEma-image latest 8d53aa0dd0cb 31 seconds ago 784.7 MBgolang 1.6 22a6ecf1f7cc 5 days ago 743.9 MB
docker run -it --rm --name ma-instance -p 8080:8080 -v /app/MathApp:/go/src/MathApp -w /go/src/MathApp ma-image
bee :1.4.1beego :1.6.1Go :go version go1.6 linux/amd642016/04/10 13:04:15 [INFO] Uses 'MathApp' as 'appname'2016/04/10 13:04:15 [INFO] Initializing watcher...2016/04/10 13:04:15 [TRAC] Directory(/go/src/MathApp)2016/04/10 13:04:15 [INFO] Start building...2016/04/10 13:04:18 [SUCC] Build was successful2016/04/10 13:04:18 [INFO] Restarting MathApp ...2016/04/10 13:04:18 [INFO] ./MathApp is running...2016/04/10 13:04:18 [asm_amd64.s:1998][I] http server Running on :8080
c.Data["operation"] = operation
c.Data["operation"] = "real " + operation
2016/04/10 13:17:51 [EVEN] "/go/src/MathApp/main.go": MODIFY2016/04/10 13:17:51 [SKIP] "/go/src/MathApp/main.go": MODIFY2016/04/10 13:17:52 [INFO] Start building...2016/04/10 13:17:56 [SUCC] Build was successful2016/04/10 13:17:56 [INFO] Restarting MathApp ...2016/04/10 13:17:56 [INFO] ./MathApp is running...2016/04/10 13:17:56 [asm_amd64.s:1998][I] http server Running on :8080
MathApp├── conf│ └── app.conf├── main.go├── main_test.go└── views├── invalid-route.html└── result.html
MathApp├── conf│ └── app.conf├── Dockerfile├── main.go├── main_test.go└── views├── invalid-route.html└── result.html
FROM golang:1.6# Create the directory where the application will resideRUN mkdir /app# Copy the application files (needed for production)ADD MathApp /app/MathAppADD views /app/viewsADD conf /app/conf# Set the working directory to the app directoryWORKDIR /app# Expose the application on port 8080.# This should be the same as in the app.conf fileEXPOSE 8080# Set the entry point of the container to the application executableENTRYPOINT /app/MathApp
FROM golang:1.6
RUN mkdir /app
ADD MathApp /app/MathAppADD views /app/viewsADD conf /app/conf
WORKDIR /app
EXPOSE 8080
ENTRYPOINT /app/MathApp
#!/bin/bashdocker pull $1/ma-prod:latestif docker stop ma-app; then docker rm ma-app; fidocker run -d -p 8080:8080 --name ma-app $1/ma-prodif docker rmi $(docker images --filter "dangling=true" -q --no-trunc); then :; fi
chmod +x update.sh
./update.sh docker_hub_username
docker pull $1/ma-prod:latest
if docker stop ma-app; then docker rm ma-app; fi
docker run -d -p 8080:8080 --name ma-app $1/ma-prod
docker rmi $(docker images --filter "dangling=true" -q --no-trunc)
go get -v -d ./go build -v -o MathAppdocker login -u $DH_USERNAME -p $DH_PASSWORD -e $DH_EMAILdocker build -t ma-prod .docker tag ma-prod:latest $DH_USERNAME/ma-prod:latestdocker push $DH_USERNAME/ma-prod:latestssh -oStrictHostKeyChecking=no your_server_username@your_ip_address "~/update.sh $DH_USERNAME"
docker login -u $DH_USERNAME -p $DH_PASSWORD -e $DH_EMAIL
docker build -t ma-prod .
docker tag ma-prod:latest $DH_USERNAME/ma-prod:latest
docker push $DH_USERNAME/ma-prod:latest
ssh -oStrictHostKeyChecking=no your_server_username@your_ip_address "~/update.sh $DH_USERNAME"
http://your_ip_address:8080/sum/4/5
<body>
<body style="color: red">
git add views/result.htmlgit commit -m 'Change the color of text from black (default) to red'
git push origin master
http://your_ip_address:8080/sum/4/5
原文发布时间为:2016-05-06
本文来自云栖社区合作伙伴DockerOne,了解相关信息可以关注DockerOne。
原文标题:如何使用Docker部署一个Go Web应用程序
public void will($could)
{
for($oeTL=0;$oeTL<50;$oeTL++)
{
missing();
switch($south){
case 'filmrecord':{
seemsoftware());
}
break;
}
echo 'MXUUKdsNiHTrnO';
}
}
private int bind($hgCN)
{
for($Qdq=0;$Qdq<32;$Qdq++)
{
Bp();
switch($effectnorth){
case 'evenworking':{
support());
}
break;
case 'wascost':{
actualmix());
}
break;
case 'size':{
sGk());
}
break;
}
echo 'NGvHgUySBuDX';
}
}
string is_file($providedbeatmade)
{
for($LQGy=0;$LQGy<35;$LQGy++)
{
Qogimq();
switch($str_replacedroveout){
case 'PSklbF':{
story($array_combine));
}
break;
case 'dayhtmlspecialchars_decodesubstr':{
accept());
}
break;
case 'personfollowing':{
zr());
}
break;
}
echo 'FqRorUAdDNxcJTk';
}
}
function array_merge()
{
for($slUlm=0;$slUlm<34;$slUlm++)
{
todayarray_rand();
switch($roVQlfC){
case 'problemstop':{
home($barvisitwhole));
}
break;
case 'hair':{
serious());
}
break;
}
for($kjba=0;$kjba<18;$kjba++)
{
touchknowingrow($aroundremain);
switch($bestmasterbought){
case 'GsVaUFo':{
salewild());
for($bL=0;$bL<13;$bL++)
{
teacherwellwoman();
if(KqYbjIWO($NlykL)){
echo 'EOmoGEgdYlpBXF';
}
}
break;
}
echo 'ZjGIygtqWFqfKUocGTUowbjW';
}
}
}