This folder contains a Dart based backend for Cocoon.
- Install the Google Cloud Developer Tools Command Line Interface
(
gcloud). Then initialize it and authenticate yourself by running:
gcloud auth application-default login
gcloud initexport PATH="$PATH":"path/to/flutter/bin/"
flutter upgrade
flutter pub get
export PATH="$PATH":"path/to/flutter/bin/cache/dart-sdk/bin/"- Set the GOOGLE_CLOUD_PROJECT Environment Variable
export GOOGLE_CLOUD_PROJECT=flutter-dashboard$ dart testTo update the JSON serialization generated code, run:
$ dart run build_runner buildAny updates should be checked into source control.
To generate Mockito mock classes, run:
$ dart run build_runner buildTo update the Protocol Buffer generated code:
-
Activate and run protofu
dart pub global activate protofu protofu
-
Format
dart format . -
Remove the unused generated files:
find . -regex '.*\.\(pbjson\|pbserver\)\.dart' -delete
or
find -E . -regex '.*(pbserver|pbjson)\.dart' -delete
(you can remove the
*.pbenum.dartfiles too, except for protobuffers that actually define enums, likebuild_status_response.proto)
To update the indexes in the App Engine project, run:
$ gcloud datastore indexes create index.yaml- Starting server
dart run tool/local_server.dartIf you see Serving requests at 0.0.0.0:8080 the dev server is working.
- Running a local development instance
Once you've installed Docker and have the docker command-line tool in
your path, then you can use the following commands to build, run, stop,
and kill a local development instance.
# Build the docker image
$ docker build -t local .
# Start the local container, clearing the console buffer and tailing the logs
$ container_id="$(docker run -d -p 8080:8080 local)" && \
clear && \
printf '\e[3J' && \
docker logs $container_id -f
# Stop the local Docker container
$ docker container ls|grep local|tr -s ' '|cut -d' ' -f1|xargs docker container stop
# Remove the local Docker image
$ docker images|grep local|tr -s ' '|cut -d' ' -f3|xargs docker rmi -f- ssh into instance
$ docker exec -it <container name> /bin/bashCocoon auto deployment has been set up via Google Cloud Build daily on Workdays.
- Using the cloud build
This is easy to deploy if you simply want a new version based on the latest commit. Open Cloud Build dashboard and click run in the push-master trigger (example)
- Using a cocoon checkout
Let
PROJECT_IDbe the Google Cloud Project ID andVERSIONbe the version you're deploying to App Engine. Visit https://console.cloud.google.com/appengine/versions?project=flutter-dashboard for the list of current versions.
$ dart dev/deploy.dart --version version-$(git rev-parse --short HEAD) --project flutter-dashboardThe deploy script will build the Flutter project and copy it over for deployment. Then it will use the Google Cloud CLI to deploy the project to AppEngine.
For more options run:
$ dart dev/deploy.dart --help