2017-11-26 22:44:32 +01:00
|
|
|
---
|
|
|
|
date: "2016-12-01T16:00:00+02:00"
|
|
|
|
title: "Installation from source"
|
|
|
|
slug: "install-from-source"
|
|
|
|
weight: 10
|
|
|
|
toc: true
|
|
|
|
draft: false
|
|
|
|
menu:
|
|
|
|
sidebar:
|
|
|
|
parent: "installation"
|
|
|
|
name: "From source"
|
|
|
|
weight: 30
|
|
|
|
identifier: "install-from-source"
|
|
|
|
---
|
|
|
|
|
|
|
|
# Installation from source
|
|
|
|
|
2019-02-12 17:22:01 +01:00
|
|
|
You should [install go](https://golang.org/doc/install) and set up your go
|
|
|
|
environment correctly. In particular, it is recommended to set the `$GOPATH`
|
|
|
|
environment variable and to add the go bin directory or directories
|
|
|
|
`${GOPATH//://bin:}/bin` to the `$PATH`. See the Go wiki entry for
|
|
|
|
[GOPATH](https://github.com/golang/go/wiki/GOPATH).
|
|
|
|
|
|
|
|
**Note**: When executing make tasks that require external tools, like
|
|
|
|
`make misspell-check`, Gitea will automatically download and build these as
|
2019-03-09 22:15:45 +01:00
|
|
|
necessary. To be able to use these, you must have the `"$GOPATH/bin"` directory
|
2019-02-12 17:22:01 +01:00
|
|
|
on the executable path. If you don't add the go bin directory to the
|
2019-03-09 22:15:45 +01:00
|
|
|
executable path, you will have to manage this yourself.
|
2019-02-12 17:22:01 +01:00
|
|
|
|
2019-03-09 22:15:45 +01:00
|
|
|
**Note 2**: Go version 1.9 or higher is required. However, it is recommended to
|
2019-02-12 17:22:01 +01:00
|
|
|
obtain the same version as our continuous integration, see the advice given in
|
2019-03-30 17:15:16 +01:00
|
|
|
<a href='{{< relref "doc/advanced/hacking-on-gitea.en-us.md" >}}'>Hacking on
|
2019-02-12 17:22:01 +01:00
|
|
|
Gitea</a>
|
2017-11-26 22:44:32 +01:00
|
|
|
|
|
|
|
## Download
|
|
|
|
|
2019-03-09 22:15:45 +01:00
|
|
|
First, retrieve the source code. The easiest way is to use the Go tool. Use the
|
2019-02-12 17:22:01 +01:00
|
|
|
following commands to fetch the source and switch into the source directory.
|
|
|
|
Go is quite opinionated about where it expects its source code, and simply
|
|
|
|
cloning the Gitea repository to an arbitrary path is likely to lead to
|
|
|
|
problems - the fixing of which is out of scope for this document.
|
2017-11-26 22:44:32 +01:00
|
|
|
|
2019-02-12 17:22:01 +01:00
|
|
|
```bash
|
2017-11-26 22:44:32 +01:00
|
|
|
go get -d -u code.gitea.io/gitea
|
2019-02-12 17:22:01 +01:00
|
|
|
cd "$GOPATH/src/code.gitea.io/gitea"
|
2017-11-26 22:44:32 +01:00
|
|
|
```
|
|
|
|
|
2019-02-12 17:22:01 +01:00
|
|
|
Decide which version of Gitea to build and install. Currently, there are
|
|
|
|
multiple options to choose from. The `master` branch represents the current
|
|
|
|
development version. To build with master, skip to the [build section](#build).
|
2017-11-26 22:44:32 +01:00
|
|
|
|
2018-01-08 23:48:42 +01:00
|
|
|
To work with tagged releases, the following commands can be used:
|
2019-02-12 17:22:01 +01:00
|
|
|
|
|
|
|
```bash
|
2017-11-26 22:44:32 +01:00
|
|
|
git branch -a
|
|
|
|
git checkout v1.0
|
|
|
|
```
|
|
|
|
|
2019-02-12 17:22:01 +01:00
|
|
|
To validate a Pull Request, first enable the new branch (`xyz` is the PR id;
|
|
|
|
for example `2663` for [#2663](https://github.com/go-gitea/gitea/pull/2663)):
|
2017-11-26 22:44:32 +01:00
|
|
|
|
2019-02-12 17:22:01 +01:00
|
|
|
```bash
|
2017-11-26 22:44:32 +01:00
|
|
|
git fetch origin pull/xyz/head:pr-xyz
|
|
|
|
```
|
|
|
|
|
2019-02-12 17:22:01 +01:00
|
|
|
To build Gitea from source at a specific tagged release (like v1.0.0), list the
|
|
|
|
available tags and check out the specific tag.
|
2018-01-08 23:48:42 +01:00
|
|
|
|
|
|
|
List available tags with the following.
|
2017-11-26 22:44:32 +01:00
|
|
|
|
2019-02-12 17:22:01 +01:00
|
|
|
```bash
|
2017-11-26 22:44:32 +01:00
|
|
|
git tag -l
|
2018-01-08 23:48:42 +01:00
|
|
|
git checkout v1.0.0 # or git checkout pr-xyz
|
2017-11-26 22:44:32 +01:00
|
|
|
```
|
|
|
|
|
|
|
|
## Build
|
|
|
|
|
2018-01-08 23:48:42 +01:00
|
|
|
Since all required libraries are already bundled in the Gitea source, it's
|
2019-02-12 17:22:01 +01:00
|
|
|
possible to build Gitea with no additional downloads apart from Make
|
|
|
|
<a href='{{< relref "doc/advanced/make.en-us.md" >}}'>(See here how to get Make)</a>.
|
|
|
|
Various [make tasks](https://github.com/go-gitea/gitea/blob/master/Makefile)
|
|
|
|
are provided to keep the build process as simple as possible.
|
|
|
|
|
2018-01-08 23:48:42 +01:00
|
|
|
Depending on requirements, the following build tags can be included.
|
2017-11-26 22:44:32 +01:00
|
|
|
|
2018-01-08 23:48:42 +01:00
|
|
|
* `bindata`: Build a single monolithic binary, with all assets included.
|
2019-02-12 17:22:01 +01:00
|
|
|
* `sqlite sqlite_unlock_notify`: Enable support for a
|
|
|
|
[SQLite3](https://sqlite.org/) database. Suggested only for tiny
|
|
|
|
installations.
|
|
|
|
* `pam`: Enable support for PAM (Linux Pluggable Authentication Modules). Can
|
|
|
|
be used to authenticate local users or extend authentication to methods
|
|
|
|
available to PAM.
|
|
|
|
|
|
|
|
Bundling assets into the binary using the `bindata` build tag can make
|
|
|
|
development and testing easier, but is not ideal for a production deployment.
|
|
|
|
To include assets, they must be built separately using the `generate` make
|
|
|
|
task e.g.:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
TAGS="bindata" make generate build
|
|
|
|
```
|
2017-11-26 22:44:32 +01:00
|
|
|
|
2019-03-09 22:15:45 +01:00
|
|
|
In the default release build of our continuous integration system, the build
|
2019-02-12 17:22:01 +01:00
|
|
|
tags are: `TAGS="bindata sqlite sqlite_unlock_notify"`. The simplest
|
|
|
|
recommended way to build from source is therefore:
|
2017-11-26 22:44:32 +01:00
|
|
|
|
2019-02-12 17:22:01 +01:00
|
|
|
```bash
|
|
|
|
TAGS="bindata sqlite sqlite_unlock_notify" make generate build
|
2017-11-26 22:44:32 +01:00
|
|
|
```
|
|
|
|
|
|
|
|
## Test
|
|
|
|
|
2019-03-09 22:15:45 +01:00
|
|
|
After following the steps above, a `gitea` binary will be available in the working directory.
|
2018-01-08 23:48:42 +01:00
|
|
|
It can be tested from this directory or moved to a directory with test data. When Gitea is
|
|
|
|
launched manually from command line, it can be killed by pressing `Ctrl + C`.
|
2017-11-26 22:44:32 +01:00
|
|
|
|
2019-02-12 17:22:01 +01:00
|
|
|
```bash
|
2017-11-26 22:44:32 +01:00
|
|
|
./gitea web
|
|
|
|
```
|
2019-04-29 20:08:21 +02:00
|
|
|
|
|
|
|
## Changing the default CustomPath, CustomConf and AppWorkDir
|
|
|
|
|
|
|
|
Gitea will search for a number of things from the `CustomPath`. By default this is
|
|
|
|
the `custom/` directory in the current working directory when running Gitea. It will also
|
|
|
|
look for its configuration file `CustomConf` in `$CustomPath/conf/app.ini`, and will use the
|
|
|
|
current working directory as the relative base path `AppWorkDir` for a number configurable
|
|
|
|
values.
|
|
|
|
|
|
|
|
These values, although useful when developing, may conflict with downstream users preferences.
|
|
|
|
|
|
|
|
One option is to use a script file to shadow the `gitea` binary and create an appropriate
|
|
|
|
environment before running Gitea. However, when building you can change these defaults
|
|
|
|
using the `LDFLAGS` environment variable for `make`. The appropriate settings are as follows
|
|
|
|
|
|
|
|
* To set the `CustomPath` use `LDFLAGS="-X \"code.gitea.io/gitea/modules/setting.CustomPath=custom-path\""`
|
|
|
|
* For `CustomConf` you should use `-X \"code.gitea.io/gitea/modules/setting.CustomConf=conf.ini\"`
|
|
|
|
* For `AppWorkDir` you should use `-X \"code.gitea.io/gitea/modules/setting.AppWorkDir=working-directory\"`
|
|
|
|
|
|
|
|
Add as many of the strings with their preceding `-X` to the `LDFLAGS` variable and run `make build`
|
|
|
|
with the appropriate `TAGS` as above.
|
|
|
|
|
|
|
|
Running `gitea help` will allow you to review what the computed settings will be for your `gitea`.
|