From 70d2244e49e60e11877f850803d33ef1e3900fa6 Mon Sep 17 00:00:00 2001
From: leigh capili <stealthybox@users.noreply.github.com>
Date: Fri, 23 Aug 2019 17:44:24 -0600
Subject: [PATCH] Support SSH_LISTEN_PORT env var in docker app.ini template
 (#7829)

Signed-off-by: leigh capili <leigh@null.net>
---
 docker/root/etc/s6/gitea/setup                     | 1 +
 docker/root/etc/templates/app.ini                  | 1 +
 docs/content/doc/installation/with-docker.en-us.md | 1 +
 3 files changed, 3 insertions(+)

diff --git a/docker/root/etc/s6/gitea/setup b/docker/root/etc/s6/gitea/setup
index c4fbf5d65e..f87ce9115e 100755
--- a/docker/root/etc/s6/gitea/setup
+++ b/docker/root/etc/s6/gitea/setup
@@ -31,6 +31,7 @@ if [ ! -f ${GITEA_CUSTOM}/conf/app.ini ]; then
     ROOT_URL=${ROOT_URL:-""} \
     DISABLE_SSH=${DISABLE_SSH:-"false"} \
     SSH_PORT=${SSH_PORT:-"22"} \
+    SSH_LISTEN_PORT=${SSH_LISTEN_PORT:-"${SSH_PORT}"} \
     LFS_START_SERVER=${LFS_START_SERVER:-"false"} \
     DB_TYPE=${DB_TYPE:-"sqlite3"} \
     DB_HOST=${DB_HOST:-"localhost:3306"} \
diff --git a/docker/root/etc/templates/app.ini b/docker/root/etc/templates/app.ini
index 212cd854d3..e05c24a09b 100644
--- a/docker/root/etc/templates/app.ini
+++ b/docker/root/etc/templates/app.ini
@@ -17,6 +17,7 @@ HTTP_PORT        = $HTTP_PORT
 ROOT_URL         = $ROOT_URL
 DISABLE_SSH      = $DISABLE_SSH
 SSH_PORT         = $SSH_PORT
+SSH_LISTEN_PORT  = $SSH_LISTEN_PORT
 LFS_START_SERVER = $LFS_START_SERVER
 LFS_CONTENT_PATH = /data/git/lfs
 
diff --git a/docs/content/doc/installation/with-docker.en-us.md b/docs/content/doc/installation/with-docker.en-us.md
index 2bca5c5b95..becbc25431 100644
--- a/docs/content/doc/installation/with-docker.en-us.md
+++ b/docs/content/doc/installation/with-docker.en-us.md
@@ -245,6 +245,7 @@ You can configure some of Gitea's settings via environment variables:
 * `RUN_MODE`: **dev**: For performance and other purposes, change this to `prod` when deployed to a production environment.
 * `SSH_DOMAIN`: **localhost**: Domain name of this server, used for the displayed clone URL in Gitea's UI.
 * `SSH_PORT`: **22**: SSH port displayed in clone URL.
+* `SSH_LISTEN_PORT`: **%(SSH\_PORT)s**: Port for the built-in SSH server.
 * `DISABLE_SSH`: **false**: Disable SSH feature when it's not available.
 * `HTTP_PORT`: **3000**: HTTP listen port.
 * `ROOT_URL`: **""**: Overwrite the automatically generated public URL. This is useful if the internal and the external URL don't match (e.g. in Docker).