dqtu14636 2015-08-14 05:34
浏览 35

Go和Docker:使用stdlib时,当我使用自定义包时,我能够运行go Web服务器

Note the code works perfectly fine when I'm running the code on my laptop.

The following two groups of code will run on my laptop. However the second group (which uses my custom package) doesn't work on Elastic Beanstalk running docker.

Standard Lib only

import (
    "net/http"
    "os"
)

func main() {
    port := os.Getenv("PORT")
    if port == "" {
        port = "3000"
    }
    http.ListenAndServe(":"+port, nil)
}

Uses Custom Package

import (
    "os"

    "github.com/sim/handlers"
)

func main() {
    port := os.Getenv("PORT")
    if port == "" {
        port = "3000"
    }
    handlers.ServeAndHandle(port) // wrapper of ListenAndServe
}

Error Messages:

Failed to build Docker image aws_beanstalk/staging-app: andlers: exit status 128 [0mtime="2015-08-14T05:08:17Z" level="info" msg="The command [/bin/sh -c go-wrapper download] returned a non-zero code: 1" . Check snapshot logs for details.

2015-08-14 01:08:15 UTC-0400 WARN Failed to build Docker image aws_beanstalk/staging-app, retrying...

cron.yaml

version: 1
cron: 
  - name: "task1"
    url: "/scheduled"
    schedule: "* * * * *"
  • 写回答

1条回答 默认 最新

  • doulianqi3870 2015-08-14 20:54
    关注

    You need a Dockerfile or/and Dockerrun.aws.json for your environment as per the documentation

    Dockerfile

    FROM FROM golang:1.3-onbuild
    
    EXPOSE 3000
    
    CMD ["go run <your.go.file>"]
    

    Dockerrun.aws.json

    {
      "AWSEBDockerrunVersion": "1",
      "Image": {
        "Name": "golang:1.3-onbuild",   # <-- don't need this if you are using a Dockerfile
        "Update": "true"
      },
      "Ports": [
        {
          "ContainerPort": "3000"
        }
      ],
      "Logging": "/var/log/go"
    }
    

    Using the eb command line to deploy ?

    评论

报告相同问题?

悬赏问题

  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图