浏览代码

Gogs actually needs sshd

Girish Ramakrishnan 10 年之前
父节点
当前提交
7c79e9e268
共有 5 个文件被更改,包括 41 次插入7 次删除
  1. 9 3
      Dockerfile
  2. 8 3
      app.ini.template
  3. 7 1
      start.sh
  4. 9 0
      supervisor/gogs.conf
  5. 8 0
      supervisor/sshd.conf

+ 9 - 3
Dockerfile

@@ -1,9 +1,10 @@
 FROM girish/base:0.2.0
 
-USER cloudron
+RUN apt-get update && \
+    apt-get install -y openssh-server && \
+    rm -r /var/cache/apt /var/lib/apt/lists
 
-# gogs uses this env to detect current user
-ENV USER cloudron
+ADD supervisor/ /etc/supervisor/conf.d/
 
 RUN cd /tmp && \
     wget https://github.com/gogits/gogs/releases/download/v0.6.1/linux_amd64.zip && \
@@ -13,5 +14,10 @@ RUN cd /tmp && \
 ADD app.ini.template /home/cloudron/app.ini.template
 ADD start.sh /home/cloudron/start.sh
 
+# disable pam authentication for sshd
+RUN sed 's/UsePAM yes/UsePAM no/' -i /etc/ssh/sshd_config
+RUN sed 's/UsePrivilegeSeparation yes/UsePrivilegeSeparation no/' -i /etc/ssh/sshd_config
+RUN echo "UseDNS no" >> /etc/ssh/sshd_config
+
 CMD [ "/home/cloudron/start.sh" ]
 

+ 8 - 3
app.ini.template

@@ -10,9 +10,9 @@ ROOT = /app/data
 SCRIPT_TYPE = bash
 
 [server]
-PROTOCOL = https
+PROTOCOL = http
 DOMAIN = ##HOSTNAME
-ROOT_URL = %(PROTOCOL)s://%(DOMAIN)s/
+ROOT_URL = https://%(DOMAIN)s/
 HTTP_ADDR =
 HTTP_PORT = 3000
 ; Disable SSH feature when not available
@@ -29,6 +29,11 @@ NAME = ##MYSQL_DATABASE
 USER = ##MYSQL_USERNAME
 PASSWD = ##MYSQL_PASSWORD
 
+[admin]
+
+[security]
+INSTALL_LOCK = true
+
 [mailer]
 ENABLED = true
 ; Name displayed in mail title
@@ -37,7 +42,7 @@ SUBJECT = %(APP_NAME)s
 ; Gmail: smtp.gmail.com:587
 ; QQ: smtp.qq.com:25
 ; Note, if the port ends with "465", SMTPS will be used. Using STARTTLS on port 587 is recommended per RFC 6409. If the server supports STARTTLS it will always be used.
-HOST = ##MAIL_SERVER
+HOST = ##MAIL_SERVER:##MAIL_PORT
 ; Do not verify the certificate of the server. Only use this for self-signed certificates
 SKIP_VERIFY = 
 ; Use client certificate

+ 7 - 1
start.sh

@@ -14,10 +14,16 @@ sed -e "s/##HOSTNAME/${fqdn}/g" \
     -e "s/##MYSQL_PASSWORD/${MYSQL_PASSWORD}/g" \
     -e "s/##MYSQL_DATABASE/${MYSQL_DATABASE}/g" \
     -e "s/##MAIL_SERVER/${MAIL_SMTP_SERVER}/g" \
+    -e "s/##MAIL_PORT/${MAIL_SMTP_PORT}/g" \
     -e "s/##MAIL_FROM/${MAIL_SMTP_USERNAME}@${MAIL_DOMAIN}/g" \
     /home/cloudron/app.ini.template > "/home/cloudron/gogs/custom/conf/app.ini"
 
 chown -R cloudron.cloudron /app/data
 
-/home/cloudron/gogs/gogs web
+# Dockerfile changes the ownership of this file to make it writable by cloudron user
+sed -e "s/^Port .*/Port ${SSH_PORT}/" \
+    -e "s/^#ListenAddress .*/ListenAddress 0.0.0.0/" \
+    -i /etc/ssh/sshd_config
+
+/usr/bin/supervisord --configuration /etc/supervisor/supervisord.conf --nodaemon -i Gogs
 

+ 9 - 0
supervisor/gogs.conf

@@ -0,0 +1,9 @@
+[program:gogs]
+directory=/home/cloudron/gogs
+command=/home/cloudron/gogs/gogs web
+user=cloudron
+autostart=true
+autorestart=true
+stdout_logfile=/var/log/supervisor/%(program_name)s.log
+stderr_logfile=/var/log/supervisor/%(program_name)s.log
+environment=USER="cloudron"

+ 8 - 0
supervisor/sshd.conf

@@ -0,0 +1,8 @@
+[program:sshd]
+directory=/
+command=/usr/sbin/sshd -D
+user=root
+autostart=true
+autorestart=true
+stdout_logfile=/var/log/supervisor/%(program_name)s.log
+stderr_logfile=/var/log/supervisor/%(program_name)s.log