kemonine
/
lollipopcloud
Archived
1
0
Fork 0

document running gitea and postgres using docker-compose

This commit is contained in:
remotenemesis 2019-02-03 18:33:45 -08:00
parent c45ebef6c9
commit 8af4eb8928
3 changed files with 112 additions and 4 deletions

View File

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

View File

@ -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).

104
services/gitea.md Normal file
View File

@ -0,0 +1,104 @@
# Gitea with docker-compose
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.
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.
## 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.
/home/pi/lollipop/docker-compose.lollipop-gitea.yml:
```
version: "2"
networks:
gitea:
services:
server:
image: registry.lollipopcloud.solutions/arm32v7/gitea:latest
environment:
- 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
networks:
- gitea
volumes:
- {gitea-data}:/data
- {gitea-app}:/app/gitea/data
ports:
- "3000:3000"
- "222:22"
depends_on:
- db
db:
image: postgres:9.6
restart: always
environment:
- POSTGRES_USER=gitea
- POSTGRES_PASSWORD=gitea
- POSTGRES_DB=gitea
networks:
- gitea
volumes:
- {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](https://docs.gitea.io/en-us/install-with-docker/) and [postgres docker](https://docs.docker.com/samples/library/postgres/) 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:
/etc/systemd/system/lollipop-gitea.service:
```
[Unit]
Description=Run Lollipop services for gitea
After=network.target
[Service]
Type=simple
ExecStart=/usr/bin/docker-compose -f docker-compose.lollipop-gitea.yml up
ExecStop=/usr/bin/docker-compose -f docker-compose.lollipop-gitea.yml down
WorkingDirectory={lollipop-home}
User=pi
Group=pi
[Install]
WantedBy=multi-user.target
```
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.