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: "* * * * *"

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 ?