Skip to content

Commit ac5cb7b

Browse files
authored
Merge pull request #2 from digiwinfr/master
Add ability to customize proxy's docker images zodern#1359
2 parents 5359030 + c8ccde3 commit ac5cb7b

File tree

3 files changed

+36
-10
lines changed

3 files changed

+36
-10
lines changed

docs/docs.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,15 @@ module.exports = {
791791
// Add an nginx config that is used proxy-wide.
792792
// This config can add additional upstream and server blocks if needed.
793793
nginxConfig: './path/to/config',
794-
// Environment variables for nginx proxy
794+
795+
// Customize the base image running Nginx proxy
796+
nginxProxyImage: 'zodern/nginx-proxy',
797+
nginxProxyVersion: 'v1.1.0',
798+
// Customize the base image running letsencrypt nginx proxy companion
799+
letsencryptCompanionImage: 'jrcs/letsencrypt-nginx-proxy-companion',
800+
letsencryptCompanionVersion: 'v1.13.1',
801+
802+
// Environment variables for nginx proxy
795803
env: {
796804
DEFAULT_HOST: 'foo.bar.com'
797805
},

src/plugins/proxy/assets/templates/shared-config.sh

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,20 @@ export HTTPS_PORT=<%= httpsPort %>
1010

1111
<% if (clientUploadLimit) { %>
1212
export CLIENT_UPLOAD_LIMIT=<%= clientUploadLimit %>
13-
<% } %>
13+
<% } %>
14+
15+
<% if (nginxProxyImage) { %>
16+
export NGINX_PROXY_IMAGE=<%= nginxProxyImage %>
17+
<% } %>
18+
19+
<% if (nginxProxyVersion) { %>
20+
export NGINX_PROXY_VERSION=<%= nginxProxyVersion %>
21+
<% } %>
22+
23+
<% if (letsencryptCompanionImage) { %>
24+
export LETSENCRYPT_COMPANION_IMAGE=<%= letsencryptCompanionImage %>
25+
<% } %>
26+
27+
<% if (letsencryptCompanionVersion) { %>
28+
export LETSENCRYPT_COMPANION_VERSION=<%= letsencryptCompanionVersion %>
29+
<% } %>

src/plugins/proxy/assets/templates/start.sh

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@
22

33
APPNAME=<%= appName %>
44
APP_PATH=/opt/$APPNAME
5-
NGINX_PROXY_VERSION="v1.1.0"
6-
LETSENCRYPT_COMPANION_VERSION="v1.13.1"
75

86
# Shared settings
97
source $APP_PATH/config/shared-config.sh
108
: ${HTTP_PORT:=80}
119
: ${HTTPS_PORT:=443}
1210
: ${CLIENT_UPLOAD_LIMIT="10M"}
11+
: ${NGINX_PROXY_IMAGE="zodern/nginx-proxy"}
12+
: ${NGINX_PROXY_VERSION="v1.1.0"}
13+
: ${LETSENCRYPT_COMPANION_IMAGE="jrcs/letsencrypt-nginx-proxy-companion"}
14+
: ${LETSENCRYPT_COMPANION_VERSION="v1.13.1"}
1315

1416
ENV_FILE=$APP_PATH/config/env.list
1517
ENV_FILE_LETSENCRYPT=$APP_PATH/config/env_letsencrypt.list
@@ -18,10 +20,10 @@ ENV_FILE_LETSENCRYPT=$APP_PATH/config/env_letsencrypt.list
1820

1921
# We don't need to fail the deployment because of a docker hub downtime
2022
set +e
21-
sudo docker pull jrcs/letsencrypt-nginx-proxy-companion:$LETSENCRYPT_COMPANION_VERSION
22-
sudo docker pull zodern/nginx-proxy:$NGINX_PROXY_VERSION
23+
sudo docker pull $LETSENCRYPT_COMPANION_IMAGE:$LETSENCRYPT_COMPANION_VERSION
24+
sudo docker pull $NGINX_PROXY_IMAGE:$NGINX_PROXY_VERSION
2325
set -e
24-
echo "Pulled zodern/nginx-proxy and jrcs/letsencrypt-nginx-proxy-companion"
26+
echo "Pulled $NGINX_PROXY_IMAGE and $LETSENCRYPT_COMPANION_IMAGE"
2527

2628
# This updates nginx for all vhosts
2729
NGINX_CONFIG="client_max_body_size $CLIENT_UPLOAD_LIMIT;";
@@ -60,7 +62,7 @@ sudo docker run \
6062
-v /opt/$APPNAME/config/nginx-default.conf:/etc/nginx/conf.d/my_proxy.conf:ro \
6163
-v /var/run/docker.sock:/tmp/docker.sock:ro \
6264
-v /opt/$APPNAME/upstream:/etc/nginx/upstream \
63-
zodern/nginx-proxy:$NGINX_PROXY_VERSION
65+
$NGINX_PROXY_IMAGE:$NGINX_PROXY_VERSION
6466
echo "Ran nginx-proxy as $APPNAME"
6567

6668
sleep 2s
@@ -78,8 +80,8 @@ sudo docker run \
7880
--log-opt max-size=100m \
7981
--log-opt max-file=3 \
8082
-v /var/run/docker.sock:/var/run/docker.sock:ro \
81-
jrcs/letsencrypt-nginx-proxy-companion:$LETSENCRYPT_COMPANION_VERSION
82-
echo "Ran jrcs/letsencrypt-nginx-proxy-companion"
83+
$LETSENCRYPT_COMPANION_IMAGE:$LETSENCRYPT_COMPANION_VERSION
84+
echo "Ran $LETSENCRYPT_COMPANION_IMAGE"
8385

8486
<% if (swarmEnabled) { %>
8587
docker rm -f $APPNAME-swarm-upstream || true

0 commit comments

Comments
 (0)