This guide helps you get started developing MLP.
Make sure you have the following dependencies installed before setting up your developer environment:
- Git
- Go 1.13 (see go.mod for minimum required version)
- Node.js 12 (LTS version or greater)
- Yarn
- Docker
MLP uses Google Sign-in to authenticate the user to access the API and UI. You can follow this tutorial to create your credential. After you get the client ID, specify it into OAUTH_CLIENT_ID in the root's .env.development and REACT_APP_OAUTH_CLIENT_ID in the ui/packages/app/.env.development.
We recommend using the Git command-line interface to download the source code for the MLP project:
- Create
github.com/gojekdirectory in your$GOPATHby running:mkdir -p $GOPATH/src/github.com/gojekfrom your terminal. - Run
cd $GOPATH/src/github.com/gojekto go to the newly created gojek directory. - Run
git clone git@github.com/gojek/mlp.git mlpto downloads MLP repository to a newmlpdirectory. - Open the
mlpdirectory using your favorite code editor.
MLP server consists of two components; the ui (frontend) and the api (backend).
Before we can build the UI assets, we need to install the dependencies:
make init-dep-uiAfter the command has finished, we can start building our UI source code:
make start-uiOnce make start-ui has built the assets, it will continue to do so whenever any of the UI files change. This means you don't have to manually build the assets every time you change the code.
Next, we'll build the web server that will serve the frontend assets we just built.
Build and run the backend by running:
make init-dep-api
make build-api
make local-db
make runThese commands download dependencies, compile the Go source code, start Postgres Docker container, and start the web server.
By default, you can access the web server at http://localhost:8080/.
The test suite consists of two types of tests: unit tests and end-to-end tests.
make test-apimake it-test-api-localMLP follows the twelve-factor app by storing the config in the environment. By default, we include the .env.development in the root directory into Makefile. You can override the default configuration by changing this file. If you run the MLP server without using make command, you need to set the environment variables value by yourself.
MLP requires Postgresql to run. We uses Docker to make the task of setting up Postgresql databases a little easier.
make local-dbThe script runs Postgresql Docker container and do the database migration.
To build a Docker image, run:
build-dockerThe resulting image will be tagges as gojektech/mlp:dev.