Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to customize proxy's docker images #1359

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion docs/docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,15 @@ module.exports = {
// Add an nginx config that is used proxy-wide.
// This config can add additional upstream and server blocks if needed.
nginxConfig: './path/to/config',
// Environment variables for nginx proxy

// Customize the base image running Nginx proxy
nginxProxyImage: 'zodern/nginx-proxy',
nginxProxyVersion: 'v1.1.0',
// Customize the base image running letsencrypt nginx proxy companion
letsencryptCompanionImage: 'jrcs/letsencrypt-nginx-proxy-companion',
letsencryptCompanionVersion: 'v1.13.1',

// Environment variables for nginx proxy
env: {
DEFAULT_HOST: 'foo.bar.com'
},
Expand Down
18 changes: 17 additions & 1 deletion src/plugins/proxy/assets/templates/shared-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,20 @@ export HTTPS_PORT=<%= httpsPort %>

<% if (clientUploadLimit) { %>
export CLIENT_UPLOAD_LIMIT=<%= clientUploadLimit %>
<% } %>
<% } %>

<% if (nginxProxyImage) { %>
export NGINX_PROXY_IMAGE=<%= nginxProxyImage %>
<% } %>

<% if (nginxProxyVersion) { %>
export NGINX_PROXY_VERSION=<%= nginxProxyVersion %>
<% } %>

<% if (letsencryptCompanionImage) { %>
export LETSENCRYPT_COMPANION_IMAGE=<%= letsencryptCompanionImage %>
<% } %>

<% if (letsencryptCompanionVersion) { %>
export LETSENCRYPT_COMPANION_VERSION=<%= letsencryptCompanionVersion %>
<% } %>
18 changes: 10 additions & 8 deletions src/plugins/proxy/assets/templates/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@

APPNAME=<%= appName %>
APP_PATH=/opt/$APPNAME
NGINX_PROXY_VERSION="v1.1.0"
LETSENCRYPT_COMPANION_VERSION="v1.13.1"

# Shared settings
source $APP_PATH/config/shared-config.sh
: ${HTTP_PORT:=80}
: ${HTTPS_PORT:=443}
: ${CLIENT_UPLOAD_LIMIT="10M"}
: ${NGINX_PROXY_IMAGE="zodern/nginx-proxy"}
: ${NGINX_PROXY_VERSION="v1.1.0"}
: ${LETSENCRYPT_COMPANION_IMAGE="jrcs/letsencrypt-nginx-proxy-companion"}
: ${LETSENCRYPT_COMPANION_VERSION="v1.13.1"}

ENV_FILE=$APP_PATH/config/env.list
ENV_FILE_LETSENCRYPT=$APP_PATH/config/env_letsencrypt.list
Expand All @@ -18,10 +20,10 @@ ENV_FILE_LETSENCRYPT=$APP_PATH/config/env_letsencrypt.list

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

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

sleep 2s
Expand All @@ -78,8 +80,8 @@ sudo docker run \
--log-opt max-size=100m \
--log-opt max-file=3 \
-v /var/run/docker.sock:/var/run/docker.sock:ro \
jrcs/letsencrypt-nginx-proxy-companion:$LETSENCRYPT_COMPANION_VERSION
echo "Ran jrcs/letsencrypt-nginx-proxy-companion"
$LETSENCRYPT_COMPANION_IMAGE:$LETSENCRYPT_COMPANION_VERSION
echo "Ran $LETSENCRYPT_COMPANION_IMAGE"

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