Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Makefile for Revel apps for Elastic Beanstalk:
- HASH := $(shell git rev-parse --short HEAD)
- BUILD_RAW := $(shell git rev-list --count HEAD) # Removed '--first-parent' because it means build numbers can go down after a merge.
- BUILD := $(strip $(BUILD_RAW))
- help:
- cat Makefile
- run:
- revel run
- open:
- open http://localhost:9000
- revel run
- zip:
- # Clean
- rm -rf build || true
- rm EBApp_*.zip || true
- # Build the app/tmp and app/routes autogen stuff.
- revel clean
- revel build
- rm -rf src || true
- rm run.bat || true
- rm run.sh || true
- rm myAppBinary || true
- # Override the main to pull params from envars not cmdline, for easier EB deployment.
- cp main/main.go app/tmp
- # Build it
- cd app/tmp && GOARCH=amd64 GOOS=linux go build -o ../../build/application
- # Copy in assets
- mkdir -p build/src/github.com/myCompany/myApp/app
- mkdir -p build/src/github.com/revel/revel
- cp -R ~/go/src/github.com/revel/revel/conf build/src/github.com/revel/revel
- cp -R ~/go/src/github.com/revel/revel/templates build/src/github.com/revel/revel
- cp -R .ebextensions build
- cp -R app/views build/src/github.com/myCompany/myProject/app
- cp -R conf build/src/github.com/myCompany/myProject
- cp -R public build/src/github.com/myCompany/myProject
- # Zip up
- cd build && zip -r "../EBApp_$(BUILD)_$(HASH).zip" * .ebextensions -x "**/.DS_Store"
- open .
- <<EOF>>
- And in main/main.go:
- package main
- import (
- "os"
- "strconv"
- "github.com/aacapella/portal/app/tmp/run"
- "github.com/revel/revel"
- )
- func getEnvWithDefault(key string, def string) string {
- e := os.Getenv(key)
- if e == "" {
- return def
- }
- return e
- }
- func main() {
- runMode := getEnvWithDefault("RUNMODE", "prod")
- port, _ := strconv.Atoi(getEnvWithDefault("PORT", "5000"))
- importPath := getEnvWithDefault("IMPORTPATH", "github.com/aacapella/portal")
- srcPath := getEnvWithDefault("SRCPATH", "src")
- revel.Init(runMode, importPath, srcPath)
- run.Run(port)
- }
- <<EOF>>
- And in .ebextensions/go-settings.config:
- option_settings:
- aws:elasticbeanstalk:container:golang:staticfiles:
- /public: src/github.com/aacapella/portal/public
- Seems to work!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement