Fork 0

document running gitea and postgres using docker-compose

remotenemesis 4 years ago
parent c45ebef6c9
commit 8af4eb8928
  1. 8
  2. 4
  3. 104

@ -54,7 +54,7 @@ If you're not using the [link for beginners](for-beginners/, the follo
- [Postgresql](services/ 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
- [Monitoring](armbian/ basic system monitoring
- [NextCloud](services/ file syncing, calendar syncing, contact syncing; an alternative to Dropbox and iCloud
- [Syncthing](services/ sync for large numbers or large sized files, an alternative to NextCloud
- Gitea (documentation needed): self-hosted git, alternative to GitHub and GitLab
- [Wallabag](services/ save websites for later, alternative to Read it Later and Pocket
- [TT-RSS](services/ self-hosted RSS reader, alternative to Google Reader
- [Syncthing](services/ sync for large numbers or large sized files; an alternative to NextCloud
- [Gitea](services/ self-hosted git and web interface for issues, pull-requests; an alternative to GitHub and GitLab
- [Wallabag](services/ save websites for later; alternative to Read it Later and Pocket
- [TT-RSS](services/ self-hosted RSS reader; alternative to Google Reader

@ -66,6 +66,10 @@ apt-get update
apt-get install --no-install-recommends docker-ce
## Docker Compose
With docker installed, install docker-compose by running `sudo apt-get install docker-compose`.
# Connecting a Console Cable
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).

@ -0,0 +1,104 @@
# Gitea with docker-compose
Ensure you have installed docker-compose (see instructions for [Raspian](../raspbian/ 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.
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/, or somewhere other than the Micro SD Card hosting the operating system.
## Create data directories
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.
| Path | Example |
| gitea-data | /media/my-usb-drive/gitea/data |
| gitea-app | /media/my-usb-drive/gitea/app/data |
| gitea-postgres | /media/my-usb-drive/gitea/postgres/data |
| lollipop-home | /home/me/lollipop
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`).
## Define services with docker-compose
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.
version: "2"
- USER_UID=1000
- USER_GID=1000
- DB_TYPE=postgres
- DB_HOST=db:5432
- DB_NAME=gitea
- DB_USER=gitea
- DB_PASSWD=gitea
- SECRET_KEY="{secretkey}"
restart: always
- gitea
- {gitea-data}:/data
- {gitea-app}:/app/gitea/data
- "3000:3000"
- "222:22"
- db
image: postgres:9.6
restart: always
- gitea
- {gitea-postgres}:/var/lib/postgresql/data
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]( and [postgres docker]( documentation.
## First time configuration
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.
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.
If everything is good, shutdown your services with: `docker-compose -f {lollipop-home}/docker-compose.lollipop-gitea.yml down`.
## Start at boot
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:
Description=Run Lollipop services for gitea
ExecStart=/usr/bin/docker-compose -f docker-compose.lollipop-gitea.yml up
ExecStop=/usr/bin/docker-compose -f docker-compose.lollipop-gitea.yml down
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".
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.