全部指南

Go

Detects go.mod and builds a static binary.

  1. 1main.go

    The platform sets the PORT environment variable (default 8080). Listen on 0.0.0.0:$PORT.

    go
    func main() {
    	port := os.Getenv("PORT")
    	if port == "" {
    		port = "8080"
    	}
    	http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { w.Write([]byte("Hello OneCloud")) })
    	log.Fatal(http.ListenAndServe(":"+port, nil))
    }
  2. 2Deploy (pick one)

    ① Connect GitHub: Project → Add service → GitHub repository (deploys on push) ② From this folder: oc up --wait (builds even without a Dockerfile) ③ Upload a folder or zip in the console: Add service → Upload source

    bash
    oc login
    oc project create my-app --link
    oc up --wait

相关指南