Go & Docker: I can start go web server when using stdlib, when I use custom package errors

Please note that the code works fine when I run the code on my laptop.

The following two groups of code will work on my laptop. However, the second group (which uses my custom package) does not work on the Elastic Beanstalk docker.

Lib standard only

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

Uses a 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 create Docker image. aws_beanstalk / staging-app: andlers: exit status 128 [0mtime = "2015-08-14T05: 08: 17Z" level = "info" msg = "The [/ bin / sh -c go-wrapper download] command returns a non-zero code: 1". View snapshot logs for more information.

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

cron.yaml

 version: 1 cron: - name: "task1" url: "/scheduled" schedule: "* * * * *" 
+5
source share
1 answer

You need a Dockerfile and / or 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 eb command line to deploy?

0
source

All Articles