Switch to gitea
This commit is contained in:
parent
4981389824
commit
d237d5653a
21
Dockerfile
21
Dockerfile
@ -5,14 +5,14 @@ MAINTAINER Julian Ospald <hasufell@posteo.de>
|
|||||||
ENV GOPATH /gopath
|
ENV GOPATH /gopath
|
||||||
ENV PATH $PATH:$GOROOT/bin:$GOPATH/bin
|
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 \
|
RUN apk --no-cache add \
|
||||||
bash \
|
bash \
|
||||||
ca-certificates \
|
ca-certificates \
|
||||||
curl \
|
curl \
|
||||||
|
gettext \
|
||||||
git \
|
git \
|
||||||
go \
|
|
||||||
linux-pam \
|
linux-pam \
|
||||||
openssh \
|
openssh \
|
||||||
redis \
|
redis \
|
||||||
@ -20,26 +20,29 @@ RUN apk --no-cache add \
|
|||||||
socat \
|
socat \
|
||||||
sqlite \
|
sqlite \
|
||||||
sudo \
|
sudo \
|
||||||
|
su-exec \
|
||||||
supervisor \
|
supervisor \
|
||||||
tzdata \
|
tzdata \
|
||||||
&& \
|
&& \
|
||||||
apk --no-cache add --virtual build-deps \
|
apk --no-cache add --virtual build-deps \
|
||||||
build-base \
|
build-base \
|
||||||
linux-pam-dev \
|
linux-pam-dev \
|
||||||
|
go \
|
||||||
&& \
|
&& \
|
||||||
git clone --depth=1 https://github.com/gogs/gogs.git \
|
git clone --depth=1 https://github.com/go-gitea/gitea.git \
|
||||||
/gopath/src/github.com/gogs/gogs && \
|
/gopath/src/code.gitea.io/gitea && \
|
||||||
make build TAGS="sqlite redis memcache cert pam" && \
|
TAGS="bindata sqlite pam" make generate build && \
|
||||||
apk del build-deps && \
|
apk del build-deps && \
|
||||||
mkdir /app/ && \
|
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/*
|
rm -rf "$GOPATH" /var/cache/apk/*
|
||||||
|
|
||||||
RUN addgroup -S git
|
RUN addgroup -S git
|
||||||
RUN adduser -G git -H -D -g 'Gogs Git User' git -h /data/git -s /bin/bash && \
|
RUN adduser -G git -H -D -g 'Gogs Git User' git -h /data/git -s /bin/bash && \
|
||||||
usermod -p '*' git && passwd -u git
|
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
|
# SSH login fix, otherwise user is kicked off after login
|
||||||
RUN echo "export VISIBLE=now" >> /etc/profile && \
|
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
|
COPY config/sshd_config /etc/ssh/sshd_config
|
||||||
|
|
||||||
# Prepare data
|
# Prepare data
|
||||||
ENV GOGS_CUSTOM /data/gogs
|
ENV GITEA_CUSTOM /data/gitea
|
||||||
RUN echo "export GOGS_CUSTOM=/data/gogs" >> /etc/profile
|
RUN echo "export GOGS_CUSTOM=/data/gitea" >> /etc/profile
|
||||||
|
|
||||||
RUN chown -R redis /var/log/redis
|
RUN chown -R redis /var/log/redis
|
||||||
RUN sed -i -e 's/daemonize yes/daemonize no/' /etc/redis.conf
|
RUN sed -i -e 's/daemonize yes/daemonize no/' /etc/redis.conf
|
||||||
|
57
README.md
57
README.md
@ -1,15 +1,15 @@
|
|||||||
# Gogs via Docker
|
# Gitea via Docker
|
||||||
|
|
||||||
## Concept
|
## Concept
|
||||||
|
|
||||||
* nginx reverse proxy (in docker container), automatically configured (except for the ssl certificates)
|
* 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
|
## Getting the images
|
||||||
|
|
||||||
Just pull them:
|
Just pull them:
|
||||||
```sh
|
```sh
|
||||||
docker pull hasufell/alpine-gogs
|
docker pull hasufell/alpine-gitea
|
||||||
docker pull hasufell/alpine-nginx-proxy
|
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
|
In addition, the following environment variables can be passed via `-e` to
|
||||||
`docker run`:
|
`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
|
* `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)
|
* `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
|
### Certificates
|
||||||
|
|
||||||
We need certificates which are named according to the hostname
|
We need certificates which are named according to the hostname
|
||||||
of the gogs instance (e.g. if you will access gogs via
|
of the gitea instance (e.g. if you will access gitea via
|
||||||
`https://gogs.foo.com`, then you name your certificates files
|
`https://gitea.foo.com`, then you name your certificates files
|
||||||
`gogs.foo.crt` and `gogs.foo.key`).
|
`gitea.foo.crt` and `gitea.foo.key`).
|
||||||
|
|
||||||
Just drop these in a directory. We will mount this directory into the
|
Just drop these in a directory. We will mount this directory into the
|
||||||
container later.
|
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).
|
You should not remove it (keep in mind that this container is not running).
|
||||||
```sh
|
```sh
|
||||||
docker run \
|
docker run \
|
||||||
--name=gogs-volumes \
|
--name=gitea-volumes \
|
||||||
-v /data \
|
-v /data \
|
||||||
hasufell/alpine-gogs \
|
hasufell/alpine-gitea \
|
||||||
echo gogs-volumes
|
echo gitea-volumes
|
||||||
```
|
```
|
||||||
|
|
||||||
Now we start the front proxy.
|
Now we start the front proxy.
|
||||||
@ -55,42 +55,53 @@ docker run -ti -d \
|
|||||||
hasufell/alpine-nginx-proxy
|
hasufell/alpine-nginx-proxy
|
||||||
```
|
```
|
||||||
|
|
||||||
Now we can start the gogs instance.
|
Now we can start the gitea instance.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
docker run -ti -d \
|
docker run -ti -d \
|
||||||
--volumes-from gogs-volumes \
|
--volumes-from gitea-volumes \
|
||||||
--name=gogs \
|
--name=gitea \
|
||||||
-e VIRTUAL_HOST=<hostname> \
|
-e VIRTUAL_HOST=<hostname> \
|
||||||
-e VIRTUAL_PORT=3000 \
|
-e VIRTUAL_PORT=3000 \
|
||||||
-e GOGS_SSH_PORT=<ssh-port> \
|
-e GITEA_SSH_PORT=<ssh-port> \
|
||||||
-p <sshport>:<sshport> \
|
-p <sshport>:<sshport> \
|
||||||
hasufell/alpine-gogs
|
hasufell/alpine-gitea
|
||||||
```
|
```
|
||||||
|
|
||||||
Note that `VIRTUAL_HOST` and `VIRTUAL_PORT` are __strictly__ necessary,
|
Note that `VIRTUAL_HOST` and `VIRTUAL_PORT` are __strictly__ necessary,
|
||||||
because they are used by the front proxy to update its configuration
|
because they are used by the front proxy to update its configuration
|
||||||
automatically.
|
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
|
## Initial web configuration
|
||||||
|
|
||||||
Make sure:
|
Make sure:
|
||||||
* `Database Type` is SQLite3
|
* `Database Type` is SQLite3
|
||||||
* `Domain` is set to your domain
|
* `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
|
* `Application URL` is `https://<domain>/` (not `http`) _without_ the Port 3000
|
||||||
|
|
||||||
## Update procedure
|
## Update procedure
|
||||||
```sh
|
```sh
|
||||||
docker stop gogs
|
docker stop gitea
|
||||||
docker rm gogs
|
docker rm gitea
|
||||||
docker pull hasufell/alpine-gogs
|
docker pull hasufell/alpine-gitea
|
||||||
docker run -ti -d \
|
docker run -ti -d \
|
||||||
--volumes-from gogs-volumes \
|
--volumes-from gitea-volumes \
|
||||||
--name=gogs \
|
--name=gitea \
|
||||||
-e VIRTUAL_HOST=<hostname> \
|
-e VIRTUAL_HOST=<hostname> \
|
||||||
-e VIRTUAL_PORT=3000 \
|
-e VIRTUAL_PORT=3000 \
|
||||||
-e GOGS_SSH_PORT=<ssh-port> \
|
-e GITEA_SSH_PORT=<ssh-port> \
|
||||||
-p <sshport>:<sshport> \
|
-p <sshport>:<sshport> \
|
||||||
hasufell/alpine-gogs
|
hasufell/alpine-gitea
|
||||||
```
|
```
|
||||||
|
@ -11,7 +11,7 @@ command=sudo -u redis redis-server /etc/redis.conf
|
|||||||
autorestart=true
|
autorestart=true
|
||||||
priority=2
|
priority=2
|
||||||
|
|
||||||
[program:gogs]
|
[program:gitea]
|
||||||
command=sudo -u git /app/gogs/gogs web
|
command=sudo -u git /app/gitea/gitea web
|
||||||
autorestart=true
|
autorestart=true
|
||||||
priority=999
|
priority=999
|
||||||
|
16
setup.sh
16
setup.sh
@ -1,8 +1,8 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
if [[ ! -d /data/gogs ]] ; then
|
if [[ ! -d /data/gitea ]] ; then
|
||||||
mkdir -p /var/run/sshd
|
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
|
fi
|
||||||
|
|
||||||
if [[ ! -d /data/ssh ]] ; then
|
if [[ ! -d /data/ssh ]] ; then
|
||||||
@ -14,9 +14,9 @@ if [[ ! -d /data/ssh ]] ; then
|
|||||||
chmod 600 /data/ssh/*
|
chmod 600 /data/ssh/*
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ln -sf /data/gogs/custom ./custom
|
ln -sf /data/gitea/custom ./custom
|
||||||
ln -sf /data/gogs/log ./log
|
ln -sf /data/gitea/log ./log
|
||||||
ln -sf /data/gogs/data ./data
|
ln -sf /data/gitea/data ./data
|
||||||
ln -sf /data/git /home/git
|
ln -sf /data/git /home/git
|
||||||
|
|
||||||
|
|
||||||
@ -26,13 +26,13 @@ if [[ ! -d ~git/.ssh ]] ; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! -f ~git/.ssh/environment ]] ; then
|
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 git:git ~git/.ssh/environment
|
||||||
chown 600 ~git/.ssh/environment
|
chown 600 ~git/.ssh/environment
|
||||||
fi
|
fi
|
||||||
|
|
||||||
chown -R git:git /data .
|
chown -R git:git /data .
|
||||||
|
|
||||||
if [[ ${GOGS_SSH_PORT} ]] ; then
|
if [[ ${GITEA_SSH_PORT} ]] ; then
|
||||||
echo "Port ${GOGS_SSH_PORT}" >> /etc/ssh/sshd_config
|
echo "Port ${GITEA_SSH_PORT}" >> /etc/ssh/sshd_config
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user