Fix
This commit is contained in:
parent
69151ec931
commit
1e4b4a9d9a
19
Dockerfile
19
Dockerfile
@ -33,31 +33,32 @@ RUN apk --no-cache add \
|
|||||||
/gopath/src/code.gitea.io/gitea && \
|
/gopath/src/code.gitea.io/gitea && \
|
||||||
TAGS="bindata sqlite pam" make generate build && \
|
TAGS="bindata sqlite pam" make generate build && \
|
||||||
apk del build-deps && \
|
apk del build-deps && \
|
||||||
mkdir /app/ && \
|
mkdir -p /app/gitea && \
|
||||||
mv /gopath/src/code.gitea.io/gitea /app/gitea && \
|
mv /gopath/src/code.gitea.io/gitea/gitea /app/gitea/gitea && \
|
||||||
rm -rf "$GOPATH" /var/cache/apk/*
|
rm -rf "$GOPATH" /var/cache/apk/*
|
||||||
|
|
||||||
RUN addgroup -S git
|
RUN addgroup -S -g 1000 git
|
||||||
RUN adduser -G git -H -D -g 'Gogs Git User' git -h /data/git -s /bin/bash && \
|
RUN adduser -G git -S -H -D -g 'Gogs Git User' -h /data/git -s /bin/bash -u 1000 git && \
|
||||||
usermod -p '*' git && passwd -u git
|
echo "git:$(dd if=/dev/urandom bs=24 count=1 status=none | base64)" | chpasswd
|
||||||
ENV USER git
|
ENV USER git
|
||||||
|
|
||||||
WORKDIR /app/gitea/
|
WORKDIR /app/gitea/
|
||||||
|
|
||||||
# SSH login fix, otherwise user is kicked off after login
|
|
||||||
RUN echo "export VISIBLE=now" >> /etc/profile && \
|
|
||||||
echo "PermitUserEnvironment yes" >> /etc/ssh/sshd_config
|
|
||||||
|
|
||||||
# Setup ssh
|
# Setup ssh
|
||||||
COPY config/sshd_config /etc/ssh/sshd_config
|
COPY config/sshd_config /etc/ssh/sshd_config
|
||||||
|
|
||||||
|
# template config
|
||||||
|
COPY config/app.ini /etc/templates/app.ini
|
||||||
|
|
||||||
# Prepare data
|
# Prepare data
|
||||||
ENV GITEA_CUSTOM /data/gitea
|
ENV GITEA_CUSTOM /data/gitea
|
||||||
RUN echo "export GITEA_CUSTOM=/data/gitea" >> /etc/profile
|
RUN echo "export GITEA_CUSTOM=/data/gitea" >> /etc/profile
|
||||||
|
|
||||||
|
# redis
|
||||||
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
|
||||||
|
|
||||||
|
# supervisord and startup
|
||||||
COPY setup.sh /setup.sh
|
COPY setup.sh /setup.sh
|
||||||
RUN chmod +x /setup.sh
|
RUN chmod +x /setup.sh
|
||||||
COPY config/supervisord.conf /etc/supervisord.conf
|
COPY config/supervisord.conf /etc/supervisord.conf
|
||||||
|
@ -88,7 +88,7 @@ Note that the initial mysql must be run with
|
|||||||
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 `GITEA_SSH_PORT` (or 22 for default)
|
* `SSH Port` is set to what you specified in `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
|
||||||
@ -101,7 +101,7 @@ docker run -ti -d \
|
|||||||
--name=gitea \
|
--name=gitea \
|
||||||
-e VIRTUAL_HOST=<hostname> \
|
-e VIRTUAL_HOST=<hostname> \
|
||||||
-e VIRTUAL_PORT=3000 \
|
-e VIRTUAL_PORT=3000 \
|
||||||
-e GITEA_SSH_PORT=<ssh-port> \
|
-e SSH_PORT=<ssh-port> \
|
||||||
-p <sshport>:<sshport> \
|
-p <sshport>:<sshport> \
|
||||||
hasufell/alpine-gitea
|
hasufell/alpine-gitea
|
||||||
```
|
```
|
||||||
|
44
config/app.ini
Normal file
44
config/app.ini
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
APP_NAME = $APP_NAME
|
||||||
|
RUN_MODE = $RUN_MODE
|
||||||
|
|
||||||
|
[repository]
|
||||||
|
ROOT = /data/git/repositories
|
||||||
|
|
||||||
|
[repository.upload]
|
||||||
|
TEMP_PATH = /data/gitea/uploads
|
||||||
|
|
||||||
|
[server]
|
||||||
|
APP_DATA_PATH = /data/gitea
|
||||||
|
SSH_DOMAIN = $SSH_DOMAIN
|
||||||
|
HTTP_PORT = $HTTP_PORT
|
||||||
|
ROOT_URL = $ROOT_URL
|
||||||
|
DISABLE_SSH = $DISABLE_SSH
|
||||||
|
SSH_PORT = $SSH_PORT
|
||||||
|
|
||||||
|
[database]
|
||||||
|
PATH = /data/gitea/gitea.db
|
||||||
|
DB_TYPE = $DB_TYPE
|
||||||
|
HOST = $DB_HOST
|
||||||
|
NAME = $DB_NAME
|
||||||
|
USER = $DB_USER
|
||||||
|
PASSWD = $DB_PASSWD
|
||||||
|
|
||||||
|
[session]
|
||||||
|
PROVIDER_CONFIG = /data/gitea/sessions
|
||||||
|
|
||||||
|
[picture]
|
||||||
|
AVATAR_UPLOAD_PATH = /data/gitea/avatars
|
||||||
|
|
||||||
|
[attachment]
|
||||||
|
PATH = /data/gitea/attachments
|
||||||
|
|
||||||
|
[log]
|
||||||
|
ROOT_PATH = /data/gitea/log
|
||||||
|
|
||||||
|
[security]
|
||||||
|
INSTALL_LOCK = $INSTALL_LOCK
|
||||||
|
SECRET_KEY = $SECRET_KEY
|
||||||
|
|
||||||
|
[service]
|
||||||
|
DISABLE_REGISTRATION = $DISABLE_REGISTRATION
|
||||||
|
REQUIRE_SIGNIN_VIEW = $REQUIRE_SIGNIN_VIEW
|
@ -1,4 +1,3 @@
|
|||||||
Port 22
|
|
||||||
AddressFamily any
|
AddressFamily any
|
||||||
ListenAddress 0.0.0.0
|
ListenAddress 0.0.0.0
|
||||||
ListenAddress ::
|
ListenAddress ::
|
||||||
|
@ -12,6 +12,6 @@ autorestart=true
|
|||||||
priority=2
|
priority=2
|
||||||
|
|
||||||
[program:gitea]
|
[program:gitea]
|
||||||
command=sudo -u git /app/gitea/gitea web
|
command=su-exec git /app/gitea/gitea web
|
||||||
autorestart=true
|
autorestart=true
|
||||||
priority=999
|
priority=999
|
||||||
|
103
setup.sh
103
setup.sh
@ -1,38 +1,87 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
if [[ ! -d /data/gitea ]] ; then
|
# create folders
|
||||||
mkdir -p /var/run/sshd
|
mkdir -p /data/gitea/log
|
||||||
mkdir -p /data/gitea/data /data/gitea/conf /data/gitea/log /data/git /data/gitea/custom
|
|
||||||
|
|
||||||
|
# system ssh
|
||||||
|
if [ ! -d /data/ssh ]; then
|
||||||
|
mkdir -p /data/ssh
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! -d /data/ssh ]] ; then
|
if [ ! -f /data/ssh/ssh_host_ed25519_key ]; then
|
||||||
mkdir /data/ssh
|
echo "Generating /data/ssh/ssh_host_ed25519_key..."
|
||||||
ssh-keygen -q -f /data/ssh/ssh_host_rsa_key -N '' -t rsa
|
ssh-keygen -t ed25519 -b 4096 -f /data/ssh/ssh_host_ed25519_key -N "" > /dev/null
|
||||||
ssh-keygen -q -f /data/ssh/ssh_host_dsa_key -N '' -t dsa
|
|
||||||
ssh-keygen -q -f /data/ssh/ssh_host_ed25519_key -N '' -t ed25519
|
|
||||||
chown -R root:root /data/ssh/*
|
|
||||||
chmod 600 /data/ssh/*
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ln -sf /data/gitea/custom ./custom
|
if [ ! -f /data/ssh/ssh_host_rsa_key ]; then
|
||||||
ln -sf /data/gitea/log ./log
|
echo "Generating /data/ssh/ssh_host_rsa_key..."
|
||||||
ln -sf /data/gitea/data ./data
|
ssh-keygen -t rsa -b 2048 -f /data/ssh/ssh_host_rsa_key -N "" > /dev/null
|
||||||
ln -sf /data/git /home/git
|
|
||||||
|
|
||||||
|
|
||||||
if [[ ! -d ~git/.ssh ]] ; then
|
|
||||||
mkdir ~git/.ssh
|
|
||||||
chmod 700 ~git/.ssh
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! -f ~git/.ssh/environment ]] ; then
|
if [ ! -f /data/ssh/ssh_host_dsa_key ]; then
|
||||||
echo "GITEA_CUSTOM=/data/gitea" > ~git/.ssh/environment
|
echo "Generating /data/ssh/ssh_host_dsa_key..."
|
||||||
chown git:git ~git/.ssh/environment
|
ssh-keygen -t dsa -f /data/ssh/ssh_host_dsa_key -N "" > /dev/null
|
||||||
chown 600 ~git/.ssh/environment
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
chown -R git:git /data .
|
if [ ! -f /data/ssh/ssh_host_ecdsa_key ]; then
|
||||||
|
echo "Generating /data/ssh/ssh_host_ecdsa_key..."
|
||||||
if [[ ${GITEA_SSH_PORT} ]] ; then
|
ssh-keygen -t ecdsa -b 256 -f /data/ssh/ssh_host_ecdsa_key -N "" > /dev/null
|
||||||
echo "Port ${GITEA_SSH_PORT}" >> /etc/ssh/sshd_config
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
chown root:root /data/ssh/*
|
||||||
|
chmod 0700 /data/ssh
|
||||||
|
chmod 0600 /data/ssh/*
|
||||||
|
|
||||||
|
|
||||||
|
# certs
|
||||||
|
/usr/sbin/update-ca-certificates
|
||||||
|
|
||||||
|
|
||||||
|
# git ssh
|
||||||
|
if [ ! -d /data/git/.ssh ]; then
|
||||||
|
mkdir -p /data/git/.ssh
|
||||||
|
chmod 700 /data/git/.ssh
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -f /data/git/.ssh/environment ]; then
|
||||||
|
echo "GITEA_CUSTOM=/data/gitea" >| /data/git/.ssh/environment
|
||||||
|
chmod 600 /data/git/.ssh/environment
|
||||||
|
fi
|
||||||
|
echo "Port ${SSH_PORT:-22}" >> /etc/ssh/sshd_config
|
||||||
|
|
||||||
|
|
||||||
|
# config
|
||||||
|
if [ ! -f /data/gitea/conf/app.ini ]; then
|
||||||
|
mkdir -p /data/gitea/conf
|
||||||
|
|
||||||
|
# Set INSTALL_LOCK to true only if SECRET_KEY is not empty and
|
||||||
|
# INSTALL_LOCK is empty
|
||||||
|
if [ -n "$SECRET_KEY" ] && [ -z "$INSTALL_LOCK" ]; then
|
||||||
|
INSTALL_LOCK=true
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Substitude the environment variables in the template
|
||||||
|
APP_NAME=${APP_NAME:-"Gitea: Git with a cup of tea"} \
|
||||||
|
RUN_MODE=${RUN_MODE:-"dev"} \
|
||||||
|
SSH_DOMAIN=${SSH_DOMAIN:-"localhost"} \
|
||||||
|
HTTP_PORT=${HTTP_PORT:-"3000"} \
|
||||||
|
ROOT_URL=${ROOT_URL:-""} \
|
||||||
|
DISABLE_SSH=${DISABLE_SSH:-"false"} \
|
||||||
|
SSH_PORT=${SSH_PORT:-"22"} \
|
||||||
|
DB_TYPE=${DB_TYPE:-"sqlite3"} \
|
||||||
|
DB_HOST=${DB_HOST:-"localhost:3306"} \
|
||||||
|
DB_NAME=${DB_NAME:-"gitea"} \
|
||||||
|
DB_USER=${DB_USER:-"root"} \
|
||||||
|
DB_PASSWD=${DB_PASSWD:-""} \
|
||||||
|
INSTALL_LOCK=${INSTALL_LOCK:-"false"} \
|
||||||
|
DISABLE_REGISTRATION=${DISABLE_REGISTRATION:-"false"} \
|
||||||
|
REQUIRE_SIGNIN_VIEW=${REQUIRE_SIGNIN_VIEW:-"false"} \
|
||||||
|
SECRET_KEY=${SECRET_KEY:-""} \
|
||||||
|
envsubst < /etc/templates/app.ini > /data/gitea/conf/app.ini
|
||||||
|
fi
|
||||||
|
|
||||||
|
# permissions
|
||||||
|
chown -R git:git /data/gitea /app/gitea /data/git
|
||||||
|
chmod 0755 /data/gitea /app/gitea /data/git
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user