Hanzo is a scalable DX platform designed to power next-gen internet companies.
You can use make to setup your development enviroment. Running:
$ make deps
...will download the Go App Engine SDK and unzip it into sdk/. When hacking on
things you'll want to ensure $GOROOT and $GOPATH point to their respective
directories inside sdk/.
You can source the provided .env file to set these variables, or use
autoenv to set them automatically
whenever you cd into the project directory.
You can install the common Go command line tools and configure gocode to work
with App Engine by running:
$ make toolsYou can then use make serve to run the local development server and make test to run tests.
You can create a local config.json file containing configuration variables to
customize settings locally (for instance to disable the auto fixture loading).
This Makefile is used to build, test, and deploy a Go application running on Google App Engine, with dependencies managed through a combination of Go tools, Python SDK scripts, and Node.js for asset compilation. Here's a detailed breakdown of how it works and the general flow of operations:
- Google App Engine: This is the platform used for deploying and managing the application.
- Go SDK and App Engine SDK: Go is the language used, and the App Engine SDK is required for running the app locally and deploying it to the cloud.
- Node.js Assets: JavaScript and CSS assets are handled using tools like
requisite,uglifyjs, andstylus. - Staging and Production Environments: Different configurations are used for deploying to development, staging, and production environments.
os: Detects the operating system (linuxordarwin) and converts it to lowercase for uniformity.pwd: Stores the current directory path.platform: Constructs the platform string based on the OS and architecture.sdk: Defines the specific App Engine SDK version to be used.sdk_path,goroot,gopath: Defines paths where the Go SDK and Go environment will be installed.
The SDK is downloaded if it doesn’t exist. The following steps are performed:
-
.sdktarget: Downloads the App Engine SDK as a zip file and unzips it into a.sdkfolder.- It also performs extra setup (e.g., downloading
mtime_file_watcher.pyto monitor file changes).
- It also performs extra setup (e.g., downloading
-
.sdk/go: Creates a wrapper script to use thegoappcommand from the SDK. -
.sdk/gpm: Downloadsgpm, a Go dependency manager, to the.sdkdirectory.
depstarget: Ensures all Go and JS/CSS dependencies are installed.deps-assets: Runsnpm updateto update JS/CSS dependencies.deps-go: Installs Go dependencies usinggpmfrom theGodepsfile.
-
The
gae_development,gae_staging,gae_production, andgae_sandboxvariables hold different configurations (YAML files) for deploying the app to various environments. -
project_env,project_id,gae_config: Select the appropriate environment based on Makefile options (production,sandbox, etc.).
-
buildtarget: Builds the Go modules listed undermodulesusinggoappfrom the App Engine SDK. -
installtarget: Installs the Go application and all dependencies.
-
JavaScript: Files are compiled and minified using
requisite,coffee, anduglifyjs.compile-js: Compiles CoffeeScript files and aggregates JavaScript withrequisite.compile-js-min: Minifies the compiled JavaScript files.
-
CSS: Files are compiled and autoprefixed using
stylusandautoprefixer.compile-css: Compiles Stylus files into CSS.compile-css-min: Minifies CSS and applies prefixes for cross-browser compatibility.
-
testtarget: Runs unit tests usingginkgo, with options for verbose and focused tests. -
benchtarget: Runs benchmark tests. -
test-watch: Watches the files and runs the tests on changes.
servetarget: Starts the App Engine development server using thedev_appserver.pycommand from the SDK.serve-clear-datastore: Clears the local datastore before starting the server.serve-public: Starts the server with a public-facing IP (0.0.0.0).
-
deploytarget: Deploys the app to the selected environment (staging,production, etc.).rollbacktarget: Rolls back the deployment if needed.
-
deploy-apptarget: Updates the environment configuration and deploys each module usingappcfg.py(App Engine deployment tool). -
datastore-export,datastore-import: Commands for exporting and importing Google Cloud Datastore data.
- Download Dependencies: Run
make depsto install all Go, JS, and CSS dependencies. - Build the Project: Use
make buildto build the Go application. - Run Development Server: Use
make serveto start the local App Engine server.
-
Staging: Run
make deployto deploy the app to the staging environment.- Make sure the environment variables are set to the correct staging project ID (
project_id).
- Make sure the environment variables are set to the correct staging project ID (
-
Production: Set the
production=1flag when callingmake deployto deploy to the production environment. -
Rolling Back: Use
make rollbackto revert to a previous version if needed.
Various Go tools are included in the tools target to assist with development (linting, formatting, etc.). These tools are installed using the goapp get and goapp install commands.