Damien
Damien

Reputation: 4121

How to deploy GO Echo my app to Elastic Beanstalk

I am trying to deploy a Go echo app to elastic beanstalk. I am using go modules and go.mod and go.sum are checked into my repo I have the following files in the root of my repo also

Buildfile

build: go build -o bin/application application.go

Procfile

web: bin/application

Every few times I deploy a build - it fails. When I log onto the ec2 instance created by elastic beanstalk and check teh file /var/log/eb-activity.log - I see the following

         creating: /var/app/staging/pkg/usermanagement/
    inflating: /var/app/staging/pkg/usermanagement/usermanagement.go
    inflating: /var/app/staging/pkg/usermanagement/usermanagement_test.go
     creating: /var/app/staging/scripts/
    inflating: /var/app/staging/scripts/00_init.sql
    inflating: /var/app/staging/scripts/10_indices_for_loading.sql
    inflating: /var/app/staging/scripts/20_indices_for_searching.sql
    inflating: /var/app/staging/scripts/create_coded_adsbx.py
     creating: /var/app/staging/scripts/db-data/
    inflating: /var/app/staging/scripts/db-data/aircraft_current-2020-01-27-coded.csv
     creating: /var/app/staging/scripts/db-data/localities_sys-shapefiles-admin-1/
    inflating: /var/app/staging/scripts/db-data/localities_sys-shapefiles-admin-1/ne_10m_admin_1_states_provinces.README.html
   extracting: /var/app/staging/scripts/db-data/localities_sys-shapefiles-admin-1/ne_10m_admin_1_states_provinces.VERSION.txt
   extracting: /var/app/staging/scripts/db-data/localities_sys-shapefiles-admin-1/ne_10m_admin_1_states_provinces.cpg
    inflating: /var/app/staging/scripts/db-data/localities_sys-shapefiles-admin-1/ne_10m_admin_1_states_provinces.dbf
    inflating: /var/app/staging/scripts/db-data/localities_sys-shapefiles-admin-1/ne_10m_admin_1_states_provinces.prj
    inflating: /var/app/staging/scripts/db-data/localities_sys-shapefiles-admin-1/ne_10m_admin_1_states_provinces.shp
    inflating: /var/app/staging/scripts/db-data/localities_sys-shapefiles-admin-1/ne_10m_admin_1_states_provinces.shx
    inflating: /var/app/staging/scripts/init.sh
   extracting: /var/app/staging/scripts/init_db.py
    inflating: /var/app/staging/scripts/localities_sys_setup.sql
  Executing: HOME=/tmp /opt/elasticbeanstalk/lib/ruby/bin/ruby /opt/elasticbeanstalk/lib/ruby/bin/foreman start --procfile /tmp/d20200320-5495-eutama/eb-buildtask-0 --root /var/app/staging --env /var/elasticbeanstalk/staging/elasticbeanstalk.env
  13:17:25 build.1 | started with pid 5508
  13:17:25 build.1 | $GOPATH/go.mod exists but should not
  13:17:25 build.1 | exited with code 1
  13:17:25 system  | sending SIGTERM to all processes

It doesnt seem to download the required dependencies I was wondering am I missing something, should go.mod be include in my repo (I can't see why it shouldn't)

The result from running go.env is as follows

GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/ec2-user/.cache/go-build"
GOENV="/home/ec2-user/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/ec2-user/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/opt/elasticbeanstalk/lib/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/opt/elasticbeanstalk/lib/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/var/app/current/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build578441755=/tmp/go-build -gno-record-gcc-switches"

Upvotes: 4

Views: 400

Answers (1)

Damien
Damien

Reputation: 4121

I generated the application artifact in circleci and used .ebignore files to only push that lib. No building takes place on Elasticbeanstalk and all is working now

Upvotes: 3

Related Questions