Explorar o código

[annex] supervisor configuration instead of s6

cgars %!s(int64=8) %!d(string=hai) anos
pai
achega
87943f9082
Modificáronse 4 ficheiros con 72 adicións e 5 borrados
  1. 2 3
      Dockerfile
  2. 4 1
      docker/build.sh
  3. 48 1
      docker/start.sh
  4. 18 0
      docker/supervisord.conf

+ 2 - 3
Dockerfile

@@ -7,11 +7,11 @@ RUN apt-get update &&                                   \
                        gcc g++ libc6-dev make golang    \
                        git git-annex openssh-server     \
                        python-pip python-setuptools     \
-                       socat tzdata supervisor patch    \
+                       socat tzdata patch    \
                        libpam0g-dev \
     && rm -rf /var/lib/apt/lists/*
 
-RUN pip install pyyaml
+RUN pip install supervisor pyyaml
 
 
 ENV GOGS_CUSTOM /data/gogs
@@ -30,4 +30,3 @@ COPY docker/nsswitch.conf /etc/nsswitch.conf
 VOLUME ["/data"]
 EXPOSE 22 3000
 ENTRYPOINT ["/app/gogs/docker/start.sh"]
-CMD ["/bin/s6-svscan", "/app/gogs/docker/s6/"]

+ 4 - 1
docker/build.sh

@@ -20,5 +20,8 @@ rm -r $GOPATH
 
 
 # Create git user for Gogs
-adduser git --home /data/git --shell /bin/bash
+
+addgroup  git
+adduser --home /data/git --shell /bin/sh --ingroup git --disabled-password git
+passwd -d git
 echo "export GOGS_CUSTOM=${GOGS_CUSTOM}" >> /etc/profile

+ 48 - 1
docker/start.sh

@@ -57,9 +57,56 @@ else
     touch /app/gogs/docker/s6/crond/down
 fi
 
+#
+
+#SSH setup
+# Check if host keys are present, else create them
+if ! test -f /data/ssh/ssh_host_rsa_key; then
+    ssh-keygen -q -f /data/ssh/ssh_host_rsa_key -N '' -t rsa
+fi
+
+if ! test -f /data/ssh/ssh_host_dsa_key; then
+    ssh-keygen -q -f /data/ssh/ssh_host_dsa_key -N '' -t dsa
+fi
+
+if ! test -f /data/ssh/ssh_host_ecdsa_key; then
+    ssh-keygen -q -f /data/ssh/ssh_host_ecdsa_key -N '' -t ecdsa
+fi
+
+if ! test -f /data/ssh/ssh_host_ed25519_key; then
+    ssh-keygen -q -f /data/ssh/ssh_host_ed25519_key -N '' -t ed25519
+fi
+
+if ! test -d ~git/.ssh; then
+    mkdir -p ~git/.ssh
+    chmod 700 ~git/.ssh
+fi
+
+#Gogs setup
+if ! test -f ~git/.ssh/environment; then
+    echo "GOGS_CUSTOM=${GOGS_CUSTOM}" > ~git/.ssh/environment
+    chmod 600 ~git/.ssh/environment
+fi
+
+cd /app/gogs
+
+# Link volumed data with app data
+ln -sf /data/gogs/log  ./log
+ln -sf /data/gogs/data ./data
+
+# Backward Compatibility with Gogs Container v0.6.15
+ln -sf /data/git /home/git
+
+chown -R git:git /data /app/gogs ~git/
+chmod 0755 /data /data/gogs ~git/
+
+# Set correct right to ssh keys
+chown -R root:root /data/ssh/*
+chmod 0700 /data/ssh
+chmod 0600 /data/ssh/*
 # Exec CMD or S6 by default if nothing present
 if [ $# -gt 0 ];then
     exec "$@"
 else
-    exec /bin/s6-svscan /app/gogs/docker/s6/
+    exec supervisord -c /app/gogs/docker/supervisord.conf
 fi

+ 18 - 0
docker/supervisord.conf

@@ -0,0 +1,18 @@
+[supervisord]
+nodaemon=true
+
+[program:sshd]
+command=/usr/sbin/sshd -De -f /app/gogs/docker/sshd_config
+stdout_logfile=/dev/stdout
+stdout_logfile_maxbytes=0
+stderr_logfile=/dev/stderr
+stderr_logfile_maxbytes=0
+
+[program:gin]
+command=/app/gogs/gogs web
+user=git
+environment=HOME="/data",USER="git"
+stdout_logfile=/dev/stdout
+stdout_logfile_maxbytes=0
+stderr_logfile=/dev/stderr
+stderr_logfile_maxbytes=0