Failing to deploy Go app to elastic beanstalk

0

I am trying to deploy a go app on AWS elastic beanstalk, but I always get:

2023/10/31 14:01:25.797145 [ERROR] An error occurred during execution of command [app-deploy] - [Check Procfile For Golang Application]. Stop running the command. Error: no application binary from source 

or

2023/11/01 17:31:03.667171 [ERROR] An error occurred during execution of command [app-deploy] - [Golang Specific Build Application]. Stop running the command. Error: build application failed on command ./build.sh with error: startProcess Failure: starting process "make" failed: Command /bin/sh -c systemctl start make.service failed with error exit status 1. Stderr:Job for make.service failed because the control process exited with error code.
See "systemctl status make.service" and "journalctl -xeu make.service" for details.

Depending on the configuration that I am trying. I created a gitlab repo with a basic example that can reproduce this issue. It also includes the zip that is used to deploy the code. I have tried cloning the demo repoand working from there. I have found that from this repo even just adding a go.mod and go.sum already makes the deployment fail and so does simply updating the application.go file to look like this:

package main

// required packages
import (
    "fmt"

    "github.com/gin-gonic/gin"
    "github.com/gin-contrib/cors"
)


func serveApplication() {
    corsConfig := cors.Config {
        AllowOrigins: []string{"http://localhost:3000"},
        AllowMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
        AllowHeaders: []string{"Origin", "Content-Type", "Authorization"},
        AllowCredentials: true,
    }

    router := gin.Default()
    router.Use(cors.New(corsConfig))
    router.StaticFile("/", "./public/index.html")
    router.Run(":5000")
    fmt.Println("Server running on port 5000")
}

func main() {
    // start the server
    serveApplication()

}

Is there something that I am not considering that is breaking the build? I have tried to add a Buildfile, Procfile and build.sh or even directly binaries. This stackoverflow has more detail on everything I tried

asked 6 months ago90 views
No Answers

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions