Switch to gitea

This commit is contained in:
Julian Ospald 2018-06-06 17:01:22 +02:00
parent 4981389824
commit d237d5653a
No known key found for this signature in database
GPG Key ID: 511B62C09D50CD28
4 changed files with 56 additions and 42 deletions

View File

@ -5,14 +5,14 @@ MAINTAINER Julian Ospald <hasufell@posteo.de>
ENV GOPATH /gopath
ENV PATH $PATH:$GOROOT/bin:$GOPATH/bin
WORKDIR /gopath/src/github.com/gogs/gogs/
WORKDIR /gopath/src/code.gitea.io/gitea
RUN apk --no-cache add \
bash \
ca-certificates \
curl \
gettext \
git \
go \
linux-pam \
openssh \
redis \
@ -20,26 +20,29 @@ RUN apk --no-cache add \
socat \
sqlite \
sudo \
su-exec \
supervisor \
tzdata \
&& \
apk --no-cache add --virtual build-deps \
build-base \
linux-pam-dev \
go \
&& \
git clone --depth=1 https://github.com/gogs/gogs.git \
/gopath/src/github.com/gogs/gogs && \
make build TAGS="sqlite redis memcache cert pam" && \
git clone --depth=1 https://github.com/go-gitea/gitea.git \
/gopath/src/code.gitea.io/gitea && \
TAGS="bindata sqlite pam" make generate build && \
apk del build-deps && \
mkdir /app/ && \
mv /gopath/src/github.com/gogs/gogs/ /app/gogs/ && \
mv /gopath/src/code.gitea.io/gitea /app/gitea && \
rm -rf "$GOPATH" /var/cache/apk/*
RUN addgroup -S git
RUN adduser -G git -H -D -g 'Gogs Git User' git -h /data/git -s /bin/bash && \
usermod -p '*' git && passwd -u git
ENV USER git
WORKDIR /app/gogs/
WORKDIR /app/gitea/
# SSH login fix, otherwise user is kicked off after login
RUN echo "export VISIBLE=now" >> /etc/profile && \
@ -49,8 +52,8 @@ RUN echo "export VISIBLE=now" >> /etc/profile && \
COPY config/sshd_config /etc/ssh/sshd_config
# Prepare data
ENV GOGS_CUSTOM /data/gogs
RUN echo "export GOGS_CUSTOM=/data/gogs" >> /etc/profile
ENV GITEA_CUSTOM /data/gitea
RUN echo "export GOGS_CUSTOM=/data/gitea" >> /etc/profile
RUN chown -R redis /var/log/redis
RUN sed -i -e 's/daemonize yes/daemonize no/' /etc/redis.conf

View File

@ -1,15 +1,15 @@
# Gogs via Docker
# Gitea via Docker
## Concept
* nginx reverse proxy (in docker container), automatically configured (except for the ssl certificates)
* backend gogs instance (in docker container)
* backend gitea instance (in docker container)
## Getting the images
Just pull them:
```sh
docker pull hasufell/alpine-gogs
docker pull hasufell/alpine-gitea
docker pull hasufell/alpine-nginx-proxy
```
@ -19,16 +19,16 @@ 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`:
* `VIRTUAL_HOST`: sets the hostname for connecting to the gogs backend server
* `VIRTUAL_HOST`: sets the hostname for connecting to the gitea backend server
* `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
of the gogs instance (e.g. if you will access gogs via
`https://gogs.foo.com`, then you name your certificates files
`gogs.foo.crt` and `gogs.foo.key`).
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`).
Just drop these in a directory. We will mount this directory into the
container later.
@ -39,10 +39,10 @@ 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 \
--name=gogs-volumes \
--name=gitea-volumes \
-v /data \
hasufell/alpine-gogs \
echo gogs-volumes
hasufell/alpine-gitea \
echo gitea-volumes
```
Now we start the front proxy.
@ -55,42 +55,53 @@ docker run -ti -d \
hasufell/alpine-nginx-proxy
```
Now we can start the gogs instance.
Now we can start the gitea instance.
```sh
docker run -ti -d \
--volumes-from gogs-volumes \
--name=gogs \
--volumes-from gitea-volumes \
--name=gitea \
-e VIRTUAL_HOST=<hostname> \
-e VIRTUAL_PORT=3000 \
-e GOGS_SSH_PORT=<ssh-port> \
-e GITEA_SSH_PORT=<ssh-port> \
-p <sshport>:<sshport> \
hasufell/alpine-gogs
hasufell/alpine-gitea
```
Note that `VIRTUAL_HOST` and `VIRTUAL_PORT` are __strictly__ necessary,
because they are used by the front proxy to update its configuration
automatically.
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`
## Initial web configuration
Make sure:
* `Database Type` is SQLite3
* `Domain` is set to your domain
* `SSH Port` is set to what you specified in `GOGS_SSH_PORT` (or 22 for default)
* `SSH Port` is set to what you specified in `GITEA_SSH_PORT` (or 22 for default)
* `Application URL` is `https://<domain>/` (not `http`) _without_ the Port 3000
## Update procedure
```sh
docker stop gogs
docker rm gogs
docker pull hasufell/alpine-gogs
docker stop gitea
docker rm gitea
docker pull hasufell/alpine-gitea
docker run -ti -d \
--volumes-from gogs-volumes \
--name=gogs \
--volumes-from gitea-volumes \
--name=gitea \
-e VIRTUAL_HOST=<hostname> \
-e VIRTUAL_PORT=3000 \
-e GOGS_SSH_PORT=<ssh-port> \
-e GITEA_SSH_PORT=<ssh-port> \
-p <sshport>:<sshport> \
hasufell/alpine-gogs
hasufell/alpine-gitea
```

View File

@ -11,7 +11,7 @@ command=sudo -u redis redis-server /etc/redis.conf
autorestart=true
priority=2
[program:gogs]
command=sudo -u git /app/gogs/gogs web
[program:gitea]
command=sudo -u git /app/gitea/gitea web
autorestart=true
priority=999

View File

@ -1,8 +1,8 @@
#!/bin/bash
if [[ ! -d /data/gogs ]] ; then
if [[ ! -d /data/gitea ]] ; then
mkdir -p /var/run/sshd
mkdir -p /data/gogs/data /data/gogs/conf /data/gogs/log /data/git /data/gogs/custom
mkdir -p /data/gitea/data /data/gitea/conf /data/gitea/log /data/git /data/gitea/custom
fi
if [[ ! -d /data/ssh ]] ; then
@ -14,9 +14,9 @@ if [[ ! -d /data/ssh ]] ; then
chmod 600 /data/ssh/*
fi
ln -sf /data/gogs/custom ./custom
ln -sf /data/gogs/log ./log
ln -sf /data/gogs/data ./data
ln -sf /data/gitea/custom ./custom
ln -sf /data/gitea/log ./log
ln -sf /data/gitea/data ./data
ln -sf /data/git /home/git
@ -26,13 +26,13 @@ if [[ ! -d ~git/.ssh ]] ; then
fi
if [[ ! -f ~git/.ssh/environment ]] ; then
echo "GOGS_CUSTOM=/data/gogs" > ~git/.ssh/environment
echo "GITEA_CUSTOM=/data/gitea" > ~git/.ssh/environment
chown git:git ~git/.ssh/environment
chown 600 ~git/.ssh/environment
fi
chown -R git:git /data .
if [[ ${GOGS_SSH_PORT} ]] ; then
echo "Port ${GOGS_SSH_PORT}" >> /etc/ssh/sshd_config
if [[ ${GITEA_SSH_PORT} ]] ; then
echo "Port ${GITEA_SSH_PORT}" >> /etc/ssh/sshd_config
fi