Browse Source

document running gitea and postgres using docker-compose

pull/99/head
remotenemesis 5 months ago
parent
commit
8af4eb8928
3 changed files with 112 additions and 4 deletions
  1. 4
    4
      README.md
  2. 4
    0
      raspbian/README.md
  3. 104
    0
      services/gitea.md

+ 4
- 4
README.md View File

@@ -54,7 +54,7 @@ If you're not using the [link for beginners](for-beginners/README.md), the follo
54 54
 - [Postgresql](services/postgres.md): database server, required for NextCloud, Gitea, Wallabag, and TT-RSS, and other services; helpful if you will be a heavy user of your Lollipop Cloud
55 55
 - [Monitoring](armbian/monitoring.md): basic system monitoring
56 56
 - [NextCloud](services/nextcloud.md): file syncing, calendar syncing, contact syncing; an alternative to Dropbox and iCloud
57
-- [Syncthing](services/syncthing.md): sync for large numbers or large sized files, an alternative to NextCloud
58
-- Gitea (documentation needed): self-hosted git, alternative to GitHub and GitLab
59
-- [Wallabag](services/wallabag.md): save websites for later, alternative to Read it Later and Pocket
60
-- [TT-RSS](services/ttrss.md): self-hosted RSS reader, alternative to Google Reader
57
+- [Syncthing](services/syncthing.md): sync for large numbers or large sized files; an alternative to NextCloud
58
+- [Gitea](services/gitea.md): self-hosted git and web interface for issues, pull-requests; an alternative to GitHub and GitLab
59
+- [Wallabag](services/wallabag.md): save websites for later; alternative to Read it Later and Pocket
60
+- [TT-RSS](services/ttrss.md): self-hosted RSS reader; alternative to Google Reader

+ 4
- 0
raspbian/README.md View File

@@ -66,6 +66,10 @@ apt-get update
66 66
 apt-get install --no-install-recommends docker-ce
67 67
 ```
68 68
 
69
+## Docker Compose
70
+
71
+With docker installed, install docker-compose by running `sudo apt-get install docker-compose`.
72
+
69 73
 # Connecting a Console Cable
70 74
 
71 75
 Connecting your Pi to another computer via a console cable allows you to setup or debug a Raspberry Pi without having to connect a display, keyboard (and optionally a mouse). 

+ 104
- 0
services/gitea.md View File

@@ -0,0 +1,104 @@
1
+# Gitea with docker-compose
2
+
3
+Ensure you have installed docker-compose (see instructions for [Raspian](../raspbian/README.md)) and have added the user you wish to start gitea services to the `docker` group. To add the current user, use: `sudo usermod -aG docker $USER`, or specify the user you desire. On a Raspian you can use the default user `pi`. Relogin or simnply restart to make the changes effective.
4
+
5
+This setup uses systemd to run a docker-compose file that start gitea with a postgres database. You will also need to define directories to store the contents of the postgress data and gitea data such as config and git repositories. You will likely want to store these directories on a [USB drive](../hardware/usb-flash-drive.md), or somewhere other than the Micro SD Card hosting the operating system. 
6
+
7
+## Create data directories
8
+
9
+Create the following directories in a convient location (the paths are up to you). You will subsitute the path any time it appears in curly braces for the actual value you used for the rest of these instructions.
10
+
11
+| Path           | Example                                 |
12
+|----------------|-----------------------------------------|
13
+| gitea-data     | /media/my-usb-drive/gitea/data          |
14
+| gitea-app      | /media/my-usb-drive/gitea/app/data      | 
15
+| gitea-postgres | /media/my-usb-drive/gitea/postgres/data |
16
+| lollipop-home  | /home/me/lollipop 
17
+
18
+Ensure the user that is going to run docker-compose to launch the gitea services has read and write permissions on these directories. To ensure correct ownership is assigned to the the application config at `{gitea-data}/gitea/conf/app.ini` you may need to create an empty file before starting the docker services (`touch {gitea-data}/gitea/conf/app.ini`).
19
+
20
+## Define services with docker-compose
21
+
22
+Next create the following file in your `{lollipop-home}` directory of the user that will launch docker-compose. Replace all the values in curly-braces with a path from the table above and create a secretkey for your installation using an string of characters you prefer.
23
+
24
+/home/pi/lollipop/docker-compose.lollipop-gitea.yml:
25
+
26
+```
27
+version: "2"
28
+
29
+networks:
30
+  gitea:
31
+
32
+services:
33
+  server:
34
+    image: registry.lollipopcloud.solutions/arm32v7/gitea:latest
35
+    environment:
36
+      - USER_UID=1000
37
+      - USER_GID=1000
38
+      - DB_TYPE=postgres
39
+      - DB_HOST=db:5432
40
+      - DB_NAME=gitea
41
+      - DB_USER=gitea
42
+      - DB_PASSWD=gitea
43
+      - SECRET_KEY="{secretkey}"
44
+    restart: always
45
+    networks:
46
+      - gitea
47
+    volumes:
48
+      - {gitea-data}:/data
49
+      - {gitea-app}:/app/gitea/data
50
+    ports:
51
+      - "3000:3000"
52
+      - "222:22"
53
+    depends_on:
54
+      - db
55
+
56
+  db:
57
+    image: postgres:9.6
58
+    restart: always
59
+    environment:
60
+      - POSTGRES_USER=gitea
61
+      - POSTGRES_PASSWORD=gitea
62
+      - POSTGRES_DB=gitea
63
+    networks:
64
+      - gitea
65
+    volumes:
66
+      - {gitea-postgres}:/var/lib/postgresql/data
67
+```
68
+
69
+The file above instructs docker-compose to launch two services: a gitea server and a postgres server upon which it depends. The postgres image used is a standard image supplied on the main docker registry. We use the gitea image provided by the Lollipop Cloud project. The docker-compose file creates a virtual network for these services to communicate. For further information on the environment variables please see [gitea installation with docker](https://docs.gitea.io/en-us/install-with-docker/) and [postgres docker](https://docs.docker.com/samples/library/postgres/) documentation.
70
+
71
+## First time configuration
72
+
73
+Now would be a good time to test your installation: `docker-compose -f {lollipop-home}/docker-compose.lollipop-gitea.yml up` should start your services and gitea should be running on port 3000.
74
+
75
+Register an initial account. You will be prompted to confirm initial config. Ensure the database is set to _PostgreSQL_, the host and port are 'db:5432', and enter the password from the docker-compose config above. Set a host name for SSH and HTTPS.  
76
+
77
+If everything is good, shutdown your services with: `docker-compose -f {lollipop-home}/docker-compose.lollipop-gitea.yml down`.
78
+  
79
+##  Start at boot
80
+
81
+Next we will setup systemd to automatically launch gitea on boot, and generally provide a simple interface to manage starting, stopping and checking the status of the services. Create the following file:
82
+
83
+/etc/systemd/system/lollipop-gitea.service:
84
+
85
+```
86
+[Unit]
87
+Description=Run Lollipop services for gitea 
88
+After=network.target
89
+
90
+[Service]
91
+Type=simple
92
+ExecStart=/usr/bin/docker-compose -f docker-compose.lollipop-gitea.yml up
93
+ExecStop=/usr/bin/docker-compose -f docker-compose.lollipop-gitea.yml down
94
+WorkingDirectory={lollipop-home}
95
+User=pi
96
+Group=pi
97
+
98
+[Install]
99
+WantedBy=multi-user.target
100
+```
101
+
102
+You will need to inform systemd of a new service by running: `sudo systemctl daemon-reload`. Then you must enable the service by running `sudo systemctl enable lollipop-gitea.service".
103
+
104
+Start the service for the first time by running `sudo systemctl start lollipop-gitea.service`, and check the status by running `sudo systemctl status lollipop-gitea.service". Reboot your computer with `sudo reboot` and your service should start during the boot sequence.

Loading…
Cancel
Save