go-gitea/docs/content/doc/installation/from-source.en-us.md
2018-06-12 16:36:34 +00:00

3.8 KiB

date title slug weight toc draft menu
2018-06-12T15:00:00+02:00 Installation from source install-from-source 10 true false
sidebar
parent name weight identifier
installation From source 30 install-from-source

Installation from source

Dependencies

Note: Go Programming Language: Version >= 1.9

We are going to create a new user called git and install/setup everything under that user:

adduser \
   --system \
   --shell /bin/bash \
   --gecos 'Git Version Control' \
   --group \
   --disabled-password \
   --home /home/git \
   git

Installing Go

If your system's Go matches the requirements, please skip this section.

Download

Install Go in /home/git/local/go so it wouldn't interfere with future updates of your system's package manager:

$ sudo su - git
$ cd ~
# create a folder to install 'go'
$ mkdir local
# Download go (change go$VERSION.$OS-$ARCH.tar.gz to the latest release)
$ wget https://dl.google.com/go/go$VERSION.$OS-$ARCH.tar.gz
# expand it to ~/local
$ tar -C /home/git/local -xzf go$VERSION.$OS-$ARCH.tar.gz

Set Up the Environment

Set the paths that correspond to your system:

$ sudo su - git
$ cd ~
$ echo 'export GOROOT=$HOME/local/go' >> $HOME/.bashrc
$ echo 'export GOPATH=$HOME/go' >> $HOME/.bashrc
$ echo 'export PATH=$PATH:$GOROOT/bin:$GOPATH/bin' >> $HOME/.bashrc
$ source $HOME/.bashrc

Download Gitea

First retrieve the source code. The easiest way is to use the Go tool. Use the following commands to fetch the source and switch into the source directory.

$ go get -d -u code.gitea.io/gitea
$ cd $GOPATH/src/code.gitea.io/gitea

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.

To work with tagged releases, the following commands can be used:

$ git branch -a
$ git checkout v1.4.2

To validate a Pull Request, first enable the new branch (xyz is the PR id; for example 2663 for #2663):

$ git fetch origin pull/xyz/head:pr-xyz

To build Gitea from source at a specific tagged release (like v1.4.0), list the available tags and check out the specific tag.

List available tags with the following.

$ git tag -l
$ git checkout v1.4.0  # or git checkout pr-xyz

Build

Since all required libraries are already bundled in the Gitea source, it's possible to build Gitea with no additional downloads. Various make tasks are provided to keep the build process as simple as possible. See here how to get Make. Depending on requirements, the following build tags can be included.

  • bindata: Build a single monolithic binary, with all assets included.
  • sqlite: Enable support for a SQLite3 database. Suggested only for tiny installations.
  • tidb: Enable support for a TiDB database.
  • 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.

$ TAGS="bindata" make generate build

Test

After following the steps above a gitea binary will be available in the working directory. 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.

$ ./gitea web