2017-11-27 03:14:32 +05:30
|
|
|
---
|
|
|
|
date: "2016-12-01T16:00:00+02:00"
|
|
|
|
title: "Installation with Docker"
|
|
|
|
slug: "install-with-docker"
|
|
|
|
weight: 10
|
|
|
|
toc: true
|
|
|
|
draft: false
|
|
|
|
menu:
|
|
|
|
sidebar:
|
|
|
|
parent: "installation"
|
|
|
|
name: "With Docker"
|
|
|
|
weight: 10
|
|
|
|
identifier: "install-with-docker"
|
|
|
|
---
|
|
|
|
|
|
|
|
# Installation with Docker
|
|
|
|
|
2018-01-09 04:18:42 +05:30
|
|
|
Gitea provides automatically updated Docker images within its Docker Hub organization. It is
|
|
|
|
possible to always use the latest stable tag or to use another service that handles updating
|
|
|
|
Docker images.
|
2017-11-27 03:14:32 +05:30
|
|
|
|
2018-01-09 04:18:42 +05:30
|
|
|
This reference setup guides users through the setup based on `docker-compose`, the installation
|
|
|
|
of `docker-compose` is out of scope of this documentation. To install `docker-compose` follow
|
|
|
|
the official [install instructions](https://docs.docker.com/compose/install/).
|
2017-11-27 03:14:32 +05:30
|
|
|
|
|
|
|
## Basics
|
|
|
|
|
2018-01-09 04:18:42 +05:30
|
|
|
The most simple setup just creates a volume and a network and starts the `gitea/gitea:latest`
|
|
|
|
image as a service. Since there is no database available one can be initialized using SQLite3.
|
|
|
|
Create a directory like `gitea` and paste the following content into a file named `docker-compose.yml`.
|
2017-11-27 03:14:32 +05:30
|
|
|
|
|
|
|
```yaml
|
|
|
|
version: "2"
|
|
|
|
|
|
|
|
networks:
|
|
|
|
gitea:
|
|
|
|
external: false
|
|
|
|
|
|
|
|
services:
|
|
|
|
server:
|
|
|
|
image: gitea/gitea:latest
|
|
|
|
restart: always
|
|
|
|
networks:
|
|
|
|
- gitea
|
|
|
|
volumes:
|
|
|
|
- ./gitea:/data
|
|
|
|
ports:
|
2017-12-05 11:33:40 +05:30
|
|
|
- "3000:3000"
|
|
|
|
- "222:22"
|
2017-11-27 03:14:32 +05:30
|
|
|
```
|
|
|
|
|
|
|
|
## Custom port
|
|
|
|
|
2018-01-09 04:18:42 +05:30
|
|
|
To bind the integrated openSSH daemon and the webserver on a different port, adjust
|
|
|
|
the port section. It's common to just change the host port and keep the ports within
|
|
|
|
the container like they are.
|
2017-11-27 03:14:32 +05:30
|
|
|
|
|
|
|
```diff
|
|
|
|
version: "2"
|
|
|
|
|
|
|
|
networks:
|
|
|
|
gitea:
|
|
|
|
external: false
|
|
|
|
|
|
|
|
services:
|
|
|
|
server:
|
|
|
|
image: gitea/gitea:latest
|
|
|
|
restart: always
|
|
|
|
networks:
|
|
|
|
- gitea
|
|
|
|
volumes:
|
|
|
|
- ./gitea:/data
|
|
|
|
ports:
|
2017-12-05 11:33:40 +05:30
|
|
|
- - "3000:3000"
|
|
|
|
- - "222:22"
|
|
|
|
+ - "8080:3000"
|
|
|
|
+ - "2221:22"
|
2017-11-27 03:14:32 +05:30
|
|
|
```
|
|
|
|
|
|
|
|
## MySQL database
|
|
|
|
|
2018-01-09 04:18:42 +05:30
|
|
|
To start Gitea in combination with a MySQL database, apply these changes to the
|
|
|
|
`docker-compose.yml` file created above.
|
2017-11-27 03:14:32 +05:30
|
|
|
|
|
|
|
```diff
|
|
|
|
version: "2"
|
|
|
|
|
|
|
|
networks:
|
|
|
|
gitea:
|
|
|
|
external: false
|
|
|
|
|
|
|
|
services:
|
|
|
|
server:
|
|
|
|
image: gitea/gitea:latest
|
|
|
|
restart: always
|
|
|
|
networks:
|
|
|
|
- gitea
|
|
|
|
volumes:
|
|
|
|
- ./gitea:/data
|
|
|
|
ports:
|
2017-12-05 11:33:40 +05:30
|
|
|
- "3000:3000"
|
|
|
|
- "222:22"
|
2017-11-27 03:14:32 +05:30
|
|
|
+ depends_on:
|
|
|
|
+ - db
|
|
|
|
+
|
|
|
|
+ db:
|
|
|
|
+ image: mysql:5.7
|
|
|
|
+ restart: always
|
|
|
|
+ environment:
|
|
|
|
+ - MYSQL_ROOT_PASSWORD=gitea
|
|
|
|
+ - MYSQL_USER=gitea
|
|
|
|
+ - MYSQL_PASSWORD=gitea
|
|
|
|
+ - MYSQL_DATABASE=gitea
|
|
|
|
+ networks:
|
|
|
|
+ - gitea
|
|
|
|
+ volumes:
|
|
|
|
+ - ./mysql:/var/lib/mysql
|
|
|
|
```
|
|
|
|
|
|
|
|
## PostgreSQL database
|
|
|
|
|
2018-01-09 04:18:42 +05:30
|
|
|
To start Gitea in combination with a PostgreSQL database, apply these changes to
|
|
|
|
the `docker-compose.yml` file created above.
|
2017-11-27 03:14:32 +05:30
|
|
|
|
|
|
|
```diff
|
|
|
|
version: "2"
|
|
|
|
|
|
|
|
networks:
|
|
|
|
gitea:
|
|
|
|
external: false
|
|
|
|
|
|
|
|
services:
|
|
|
|
server:
|
|
|
|
image: gitea/gitea:latest
|
|
|
|
restart: always
|
|
|
|
networks:
|
|
|
|
- gitea
|
|
|
|
volumes:
|
|
|
|
- ./gitea:/data
|
|
|
|
ports:
|
2017-12-05 11:33:40 +05:30
|
|
|
- "3000:3000"
|
|
|
|
- "222:22"
|
2017-11-27 03:14:32 +05:30
|
|
|
+ depends_on:
|
|
|
|
+ - db
|
|
|
|
+
|
|
|
|
+ db:
|
|
|
|
+ image: postgres:9.6
|
|
|
|
+ restart: always
|
|
|
|
+ environment:
|
|
|
|
+ - POSTGRES_USER=gitea
|
|
|
|
+ - POSTGRES_PASSWORD=gitea
|
|
|
|
+ - POSTGRES_DB=gitea
|
|
|
|
+ networks:
|
|
|
|
+ - gitea
|
|
|
|
+ volumes:
|
|
|
|
+ - ./postgres:/var/lib/postgresql/data
|
|
|
|
```
|
|
|
|
|
|
|
|
## Named volumes
|
|
|
|
|
2018-01-09 04:18:42 +05:30
|
|
|
To use named volumes instead of host volumes, define and use the named volume
|
|
|
|
within the `docker-compose.yml` configuration. This change will automatically
|
|
|
|
create the required volume.
|
2017-11-27 03:14:32 +05:30
|
|
|
|
|
|
|
```diff
|
|
|
|
version: "2"
|
|
|
|
|
|
|
|
networks:
|
|
|
|
gitea:
|
|
|
|
external: false
|
|
|
|
|
|
|
|
+volumes:
|
|
|
|
+ gitea:
|
|
|
|
+ driver: local
|
|
|
|
+
|
|
|
|
services:
|
|
|
|
server:
|
|
|
|
image: gitea/gitea:latest
|
|
|
|
restart: always
|
|
|
|
networks:
|
|
|
|
- gitea
|
|
|
|
volumes:
|
|
|
|
- - ./gitea:/data
|
|
|
|
+ - gitea:/data
|
|
|
|
ports:
|
2017-12-05 11:33:40 +05:30
|
|
|
- "3000:3000"
|
|
|
|
- "222:22"
|
2017-11-27 03:14:32 +05:30
|
|
|
```
|
|
|
|
|
2018-01-09 04:18:42 +05:30
|
|
|
MySQL or PostgreSQL containers will need to be created separately.
|
2017-11-27 03:14:32 +05:30
|
|
|
|
|
|
|
## Start
|
|
|
|
|
2018-01-09 04:18:42 +05:30
|
|
|
To start this setup based on `docker-compose`, execute `docker-compose up -d`,
|
|
|
|
to launch Gitea in the background. Using `docker-compose ps` will show if Gitea
|
|
|
|
started properly. Logs can be viewed with `docker-compose logs`.
|
2017-11-27 03:14:32 +05:30
|
|
|
|
2018-01-09 04:18:42 +05:30
|
|
|
To shut down the setup, execute `docker-compose down`. This will stop
|
|
|
|
and kill the containers. The volumes will still exist.
|
2017-11-27 03:14:32 +05:30
|
|
|
|
2018-01-09 04:18:42 +05:30
|
|
|
Notice: if using a non-3000 port on http, change app.ini to match
|
|
|
|
`LOCAL_ROOT_URL = http://localhost:3000/`.
|
2017-11-30 16:48:35 +05:30
|
|
|
|
2017-11-27 03:14:32 +05:30
|
|
|
## Install
|
|
|
|
|
2018-01-09 04:18:42 +05:30
|
|
|
After starting the Docker setup via `docker-compose` Gitea should be available using a
|
|
|
|
favorite browser to finalize the installation. Visit http://server-ip:3000 and follow the
|
|
|
|
installation wizard. If the database was started with the `docker-compose` setup as
|
|
|
|
documented above please note that `db` must be used as the database hostname.
|
2017-11-27 03:14:32 +05:30
|
|
|
|
|
|
|
# Customization
|
|
|
|
|
2018-01-09 04:18:42 +05:30
|
|
|
Customization files described [here](https://docs.gitea.io/en-us/customizing-gitea/) should
|
|
|
|
be placed in `/data/gitea` directory. If using host volumes it's quite easy to access these
|
|
|
|
files; for named volumes this is done through another container or by direct access at
|
|
|
|
`/var/lib/docker/volumes/gitea_gitea/_data`. The configuration file will be saved at
|
|
|
|
`/data/gitea/conf/app.ini` after the installation.
|