Getting Started With Cloud Engine
If you are planning to use Cloud Functions and Hooks rather than deploy a general-purpose backend program, see Getting Started With Cloud Functions and Hooks.
To deploy a frontend app, see Frontend Runtime Environment § Getting Started.
Cloud Engine is a platform that lets you host backends for your applications. If you have web apps or backend programs built with Node.js, Python, Java, PHP, .NET, Go, or C++, you can deploy them to Cloud Engine and it will automatically build runnable versions from the source code and run them in independent containers. Cloud Engine provides capabilities including log viewing, monitoring, load balancing, zero downtime deployment, and autoscaling that you can use out of the box. Additional features provided by Cloud Engine include scheduled tasks, domain and certificate management, and hosted database management systems including Redis, MySQL, MongoDB, and Elasticsearch.
Create a Project
The easiest way to start a new project is to use our boilerplate.
Please first install the latest CLI by following CLI Guide § Installation, then log in to your account by following CLI Guide § Logging In.
If you haven’t created an app on the dashboard, please do it first. Once you have your app created, create a new project by running lean new
:
$ lean new my-engine-app
[?] Please select an app template:
1) Node.js - Express
2) Node.js - Koa
3) Python - Flask
4) Python - Django
5) Java - Servlet
6) Java - Spring Boot
7) PHP - Slim
8) .NET Core
9) Go - Echo
10) React Web App (via create-react-app)
11) Vue Web App (via @vue/cli)
=> 1
[?] Please select an app:
1) my-engine-app
=> 1
[INFO] Downloading templates 7.71 KiB / 7.71 KiB [==================] 100.00% 0s
[INFO] Creating project...
[INFO] Created Node.js - Express project in `my-engine-app`
[INFO] Lean how to use Express at https://expressjs.com
lean new
will create a directory with the name you provided. We can now run cd my-engine-app
and install the dependencies:
- Node.js
- Python
- PHP
- Java
- .NET (C#)
- Go
npm install
pip install -Ur requirements.txt
composer install
mvn package
Install the .NET SDK with the version specified in global.json.
go mod tidy
Binding a Project
To associate an existing project to a Cloud Engine application, you can use the lean switch
:
$ lean switch
[?] Please select an app:
1) my-engine-app
=> 1
Switching to my-engine-app (group: web)
Run and Debug Locally
You can define routes with the web framework for the language of your choice so the program can handle requests sent to the paths specified. Feel free to look into the examples within the boilerplate:
- Node.js
- Python
- PHP
- Java
- .NET (C#)
- Go
app.get("/", function (req, res) {
res.render("index", { currentTime: new Date() });
});
@app.route('/')
def index():
return render_template('index.html')
$app->get('/', function (Request $request, Response $response) {
return $this->view->render($response, "index.phtml", array(
"currentTime" => new \DateTime(),
));
});
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
app.UseEndpoints(endpoints => {
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
})
e.GET("/", routes.Index)
func Index(c echo.Context) error {
return c.Render(http.StatusOK, "index", time.Now().String())
}
With all the dependencies correctly installed, run the project locally by running the CLI under the project’s root directory:
$ lean up
See Cloud Engine CLI Guide for more information on the CLI as well as debugging your project locally.
Deploy to Cloud Engine
Run the following command to deploy your project to the production environment:
lean deploy --prod
Projects deployed to Cloud Engine can only be accessed with domains configured. You can bind domains by going to Dashboard > LeanEngine > Manage deployment > Your group > Settings > Domains.
For example, if you have bound the domain web.example.com
, you will be able to access your app on https://web.example.com
(production environment).
More
Continue reading Cloud Engine Platform Features to learn about the additional features provided by Cloud Engine. You may also skip to the dedicated pages for specific runtime environments: