2015-03-09 11:12:59 -05:00
---
2015-03-10 02:51:26 -05:00
page_title: Building from source
page_description: Building from source Grafana.
page_keywords: grafana, build, contribute, documentation
2015-03-09 11:12:59 -05:00
---
2015-03-10 03:03:05 -05:00
# Building Grafana from source
2015-03-09 11:12:59 -05:00
2015-08-10 16:44:08 -05:00
This guide will help you create packages from source and get grafana up and running in
dev environment. Grafana ships with its own required backend server; also completely open-source. It's written in [Go ](http://golang.org ) and has a full [HTTP API ](/v2.1/reference/http_api/ ).
2015-03-09 11:12:59 -05:00
2015-03-10 03:03:05 -05:00
## Dependencies
2015-03-09 11:12:59 -05:00
2016-01-08 03:22:51 -06:00
- [Go 1.5 ](https://golang.org/dl/ )
2015-08-10 16:44:08 -05:00
- [NodeJS ](https://nodejs.org/download/ )
2015-03-09 11:12:59 -05:00
2015-03-10 03:03:05 -05:00
## Get Code
2015-08-10 16:44:08 -05:00
Create a directory for the project and set your path accordingly. Then download and install Grafana into your $GOPATH directory
2015-03-10 03:03:05 -05:00
```
2015-07-09 15:49:27 -05:00
export GOPATH=`pwd`
2015-03-10 03:03:05 -05:00
go get github.com/grafana/grafana
```
2015-03-09 11:12:59 -05:00
2015-08-11 13:58:30 -05:00
## Building the backend
2015-03-10 03:03:05 -05:00
```
cd $GOPATH/src/github.com/grafana/grafana
2015-08-11 13:58:30 -05:00
go run build.go setup # (only needed once to install godep)
2015-10-22 00:09:07 -05:00
$GOPATH/bin/godep restore # (will pull down all golang lib dependencies in your current GOPATH)
2015-08-11 13:58:30 -05:00
go run build.go build # (or 'go build .')
2015-03-10 03:03:05 -05:00
```
2015-03-09 11:12:59 -05:00
2015-08-10 16:44:08 -05:00
#### Building on Windows
2015-04-19 02:44:14 -05:00
The Grafana backend includes Sqlite3 which requires GCC to compile. So in order to compile Grafana on windows you need
to install GCC. We recommend [TDM-GCC ](http://tdm-gcc.tdragon.net/download ).
2015-08-10 16:44:08 -05:00
## Build the Front-end Assets
2015-03-09 11:12:59 -05:00
2016-02-02 06:17:06 -06:00
To build less to css for the frontend you will need a recent version of node (v0.12.0),
2015-03-10 03:03:05 -05:00
npm (v2.5.0) and grunt (v0.4.5). Run the following:
```
npm install
npm install -g grunt-cli
grunt
```
2015-08-11 13:58:30 -05:00
## Recompile backend on source change
To rebuild on source change (requires that you executed godep restore)
```
go get github.com/Unknwon/bra
bra run
```
2015-08-10 16:44:08 -05:00
## Running Grafana Locally
You can run a local instance of Grafana by running:
2015-03-10 03:03:05 -05:00
```
2016-01-08 03:22:51 -06:00
./bin/grafana-server
2015-03-10 03:03:05 -05:00
```
2015-08-11 14:41:12 -05:00
If you built the binary with `go run build.go build` , run `./bin/grafana-server`
If you built it with `go build .` , run `./grafana`
2015-03-10 03:03:05 -05:00
2015-08-11 13:58:30 -05:00
Open grafana in your browser (default [http://localhost:3000 ](http://localhost:3000 )) and login with admin user (default user/pass = admin/admin).
2015-08-10 16:44:08 -05:00
## Developing for Grafana
2016-01-08 03:22:51 -06:00
To add features, customize your config, etc, you'll need to rebuild on source change (requires that you executed [godep restore ](#build-the-backend ), as outlined above).
2015-03-10 03:03:05 -05:00
```
2015-08-10 16:44:08 -05:00
go get github.com/Unknwon/bra
bra run
2015-03-10 03:03:05 -05:00
```
2015-08-10 16:44:08 -05:00
You'll also need to run `grunt watch` to watch for changes to the front-end.
2015-03-10 03:03:05 -05:00
2015-03-30 04:08:46 -05:00
## Creating optimized release packages
2015-06-11 00:59:57 -05:00
This step builds linux packages and requires that fpm is installed. Install fpm via `gem install fpm` .
2015-03-30 04:08:46 -05:00
```
go run build.go build package
```
2015-03-10 03:03:05 -05:00
## Dev config
Create a custom.ini in the conf directory to override default configuration options.
You only need to add the options you want to override. Config files are applied in the order of:
1. grafana.ini
2015-04-13 00:34:55 -05:00
2. custom.ini
2015-03-09 11:12:59 -05:00
2015-08-11 13:58:30 -05:00
Learn more about Grafana config options in the [Configuration section ](/installation/configuration/ )
2015-03-09 11:12:59 -05:00
## Create a pull requests
2016-01-08 03:22:51 -06:00
Please contribute to the Grafana project and submit a pull request! Build new features, write or update documentation, fix bugs and generally make Grafana even more awesome.
2015-03-09 11:12:59 -05:00
2015-08-10 16:44:08 -05:00
Before or after you create a pull request, sign the [contributor license agreement ](/project/cla.html ).
2016-01-08 03:22:51 -06:00
Together we can build amazing software faster.