Debugging and deploying a Flutter web app with Dart HTTP web server to App Engine Flex
Setting | Value |
---|---|
Purpose | Debugging Flutter web app with dart web server hosted on App Engine |
Client | Flutter web app |
Server | Dart http web server |
Client Language | Dart |
Server Language | Dart |
Architecture | Flutter/Dart |
IDE | Visual Studio Code |
CI | Travis CI |
Hosting | App Engine Flex |
License | GPL v3 |
Tutorial | Youtube Tutorial |
- Run
cd ./client
to change into the server directory. - Run
pub get
to initialize the project. - Run
flutter run -d chrome
- Run
cd ./server
to change into the server directory. - Run
pub get
to initialize the project. - Run
dart ./lib/server/server.dart
- Use the VS Code Launcher
1. Launch Server
- Use the VS Code Launcher
2. Launch Flutter Web App
- http://localhost:54432/#/ - client
- http://localhost:8080 - server
- http://localhost:8080/api - server
- http://localhost:8080/api/getMessage - server
Used for debugging deployment config.
- Run
sh ./debug-docker-container-config.sh
- Open http://localhost:8080
Docker cmd | Details |
---|---|
docker ps | list the docker containers and [container id]s |
docker exec -it [container id] bash | /bin/bash into the container. (The container name could be used as well.) |
The dart tools are required to use this project.
Install the Dart VS Code plugin.
Add the program launcher, to launch the web server.
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch Web Server",
"program": "lib/server.dart",
"request": "launch",
"type": "dart"
}
]
}
- Generate a Flutter Web App Instructions
- I ran
flutter create client
to create an app named client.
- Sign up for Google Cloud Compute.
- Create a GCP project.
- Create an App Engine Application https://console.cloud.google.com/appengine/start.
- This app is Node.js & a Standard App Engine deployment.
- Download Cloud SDK CLI tools
- Run
gcloud init
- Run
gcloud app create
- create a flex project
- Create a service account for App Engine Admin for deployments.
- And be sure you add the
Cloud Build API
permissions to the services account. - And turn on the Cloud API Dash for the project.
- And be sure you add the
- Create an App Engine project in the console https://console.cloud.google.com/appengine.
- After you create an app engine project, follow the App Engine getting strted instructions on how to install Cloud CLI.
app.yaml configures the App Engine web hosting service options. app.yaml reference