alpine-gitea/README.md

108 lines
3.0 KiB
Markdown
Raw Permalink Normal View History

2018-06-06 15:01:22 +00:00
# Gitea via Docker
2016-03-17 18:11:40 +00:00
## Concept
* nginx reverse proxy (in docker container), automatically configured (except for the ssl certificates)
2018-06-06 15:01:22 +00:00
* backend gitea instance (in docker container)
2016-03-17 18:11:40 +00:00
## Getting the images
Just pull them:
```sh
2018-06-06 15:01:22 +00:00
docker pull hasufell/alpine-gitea
2016-03-17 18:11:40 +00:00
docker pull hasufell/alpine-nginx-proxy
```
## Configuration
Gogs is configured via the web interface once the instance has started.
In addition, the following environment variables can be passed via `-e` to
`docker run`:
2018-06-06 15:01:22 +00:00
* `VIRTUAL_HOST`: sets the hostname for connecting to the gitea backend server
2016-03-17 18:11:40 +00:00
* `VIRTUAL_PORT`: tells the front proxy on which port to contact the backend server
* `GOGS_SSH_PORT`: this only changes the port of the sshd service, you will still have to adjust it in the web configuration interface (optional, default 22)
### Certificates
We need certificates which are named according to the hostname
2018-06-06 15:01:22 +00:00
of the gitea instance (e.g. if you will access gitea via
`https://gitea.foo.com`, then you name your certificates files
`gitea.foo.crt` and `gitea.foo.key`).
2016-03-17 18:11:40 +00:00
Just drop these in a directory. We will mount this directory into the
container later.
## Running for the first time
Create the volumes. This will create a persistent data volume container.
You should not remove it (keep in mind that this container is not running).
```sh
docker run \
2018-06-06 15:01:22 +00:00
--name=gitea-volumes \
2016-03-17 18:11:40 +00:00
-v /data \
2018-06-06 15:01:22 +00:00
hasufell/alpine-gitea \
echo gitea-volumes
2016-03-17 18:11:40 +00:00
```
Now we start the front proxy.
```sh
docker run -ti -d \
-v /var/run/docker.sock:/tmp/docker.sock:ro \
-v <full-path-to-nginx-certs>:/etc/nginx/certs \
-p 80:80 \
-p 443:443 \
hasufell/alpine-nginx-proxy
```
2018-06-06 15:01:22 +00:00
Now we can start the gitea instance.
2016-03-17 18:11:40 +00:00
```sh
docker run -ti -d \
2018-06-06 15:01:22 +00:00
--volumes-from gitea-volumes \
--name=gitea \
2016-03-17 18:11:40 +00:00
-e VIRTUAL_HOST=<hostname> \
-e VIRTUAL_PORT=3000 \
2018-06-06 15:01:22 +00:00
-e GITEA_SSH_PORT=<ssh-port> \
2016-03-17 18:11:40 +00:00
-p <sshport>:<sshport> \
2018-06-06 15:01:22 +00:00
hasufell/alpine-gitea
2016-03-17 18:11:40 +00:00
```
Note that `VIRTUAL_HOST` and `VIRTUAL_PORT` are __strictly__ necessary,
because they are used by the front proxy to update its configuration
automatically.
2018-06-06 15:01:22 +00:00
When using a MySQL database, do something like:
```sh
docker exec -ti \
gitea-mysql \
/bin/bash -c "echo \"CREATE DATABASE gitea DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; CREATE USER gitea@'%' IDENTIFIED WITH mysql_native_password BY 'wurst'; GRANT ALL PRIVILEGES ON gitea.* TO gitea@'%';\" | mysql -u root -p"
```
Note that the initial mysql must be run with
`--default-authentication-plugin=mysql_native_password --default-storage-engine=InnoDB`
2016-03-17 18:11:40 +00:00
## Initial web configuration
Make sure:
* `Database Type` is SQLite3
* `Domain` is set to your domain
2018-06-06 17:47:29 +00:00
* `SSH Port` is set to what you specified in `SSH_PORT` (or 22 for default)
2016-03-17 18:11:40 +00:00
* `Application URL` is `https://<domain>/` (not `http`) _without_ the Port 3000
## Update procedure
```sh
2018-06-06 15:01:22 +00:00
docker stop gitea
docker rm gitea
docker pull hasufell/alpine-gitea
2016-03-17 18:11:40 +00:00
docker run -ti -d \
2018-06-06 15:01:22 +00:00
--volumes-from gitea-volumes \
--name=gitea \
2016-03-17 18:11:40 +00:00
-e VIRTUAL_HOST=<hostname> \
-e VIRTUAL_PORT=3000 \
2018-06-06 17:47:29 +00:00
-e SSH_PORT=<ssh-port> \
2016-03-17 18:11:40 +00:00
-p <sshport>:<sshport> \
2018-06-06 15:01:22 +00:00
hasufell/alpine-gitea
2016-03-17 18:11:40 +00:00
```