From 0b6d872e25040b6f4f29097e2ee2621c19c29e1e Mon Sep 17 00:00:00 2001 From: Alec Reynolds Date: Tue, 5 Dec 2023 16:37:03 -0500 Subject: [PATCH] Get rid of render template and add nginx 1.25 support (#33) * Update pinPairs and add nginx 1.25 support. * Get rid of render-template. * Add tests for nginx 1.25. --- .github/workflows/pr-nginx-tests.yml | 1 + builders/nginx.js | 17 ++++------- config/launch.sh | 15 ++-------- examples/1.25/.lando.yml | 11 +++++++ examples/1.25/README.md | 44 ++++++++++++++++++++++++++++ examples/1.25/index.html | 1 + 6 files changed, 66 insertions(+), 23 deletions(-) create mode 100644 examples/1.25/.lando.yml create mode 100644 examples/1.25/README.md create mode 100644 examples/1.25/index.html diff --git a/.github/workflows/pr-nginx-tests.yml b/.github/workflows/pr-nginx-tests.yml index ab2898f..e951c5d 100644 --- a/.github/workflows/pr-nginx-tests.yml +++ b/.github/workflows/pr-nginx-tests.yml @@ -27,6 +27,7 @@ jobs: - examples/1.22 - examples/1.23 - examples/1.24 + - examples/1.25 - examples/custom steps: diff --git a/builders/nginx.js b/builders/nginx.js index 1b90a58..7211a8d 100644 --- a/builders/nginx.js +++ b/builders/nginx.js @@ -9,12 +9,13 @@ module.exports = { name: 'nginx', config: { version: '1.17', - supported: ['1.14', '1.16', '1.17', '1.18', '1.19', '1.20', '1.21', '1.22', '1.23', '1.24'], + supported: ['1.14', '1.16', '1.17', '1.18', '1.19', '1.20', '1.21', '1.22', '1.23', '1.24', '1.25'], legacy: ['1.14'], pinPairs: { - '1.24': 'bitnami/nginx:1.24.0-debian-11-r1', - '1.23': 'bitnami/nginx:1.23.4-debian-11-r10', - '1.22': 'bitnami/nginx:1.22.1-debian-11-r64', + '1.25': 'bitnami/nginx:1.25.3-debian-11-r1', + '1.24': 'bitnami/nginx:1.24.0-debian-11-r153', + '1.23': 'bitnami/nginx:1.23.4-debian-11-r24', + '1.22': 'bitnami/nginx:1.22.1-debian-11-r66', '1.21': 'bitnami/nginx:1.21.6-debian-11-r21', '1.20': 'bitnami/nginx:1.20.2-debian-11-r9', '1.19': 'bitnami/nginx:1.19.10-debian-10-r94', @@ -42,7 +43,6 @@ module.exports = { }, ssl: false, webroot: '.', - renderTemplate: '1.0.5-5', }, parent: '_webserver', builder: (parent, config) => class LandoNginx extends parent { @@ -64,11 +64,6 @@ module.exports = { options.defaultFiles = _.merge({}, options.defaultFiles, {server: 'nginx.conf.tpl'}); } - // swap to older render template as needed - if (mv === '1.14' || mv === '1.15' || mv === '1.16') { - options.renderTemplate = '1.0.0-3'; - } - // Get the config files final destination // @TODO: we cp the files instead of directly mounting them to // prevent unexpected edits to this files @@ -78,7 +73,7 @@ module.exports = { // Build the default stuff here const nginx = { image: `bitnami/nginx:${options.version}`, - command: `/launch.sh ${vhosts} ${server} ${params} ${options.renderTemplate}`, + command: `/launch.sh ${vhosts} ${server} ${params}`, environment: { NGINX_HTTP_PORT_NUMBER: '80', NGINX_DAEMON_USER: 'root', diff --git a/config/launch.sh b/config/launch.sh index c099430..b6987b0 100755 --- a/config/launch.sh +++ b/config/launch.sh @@ -7,7 +7,6 @@ set -e : ${VHOST:="$1"} : ${SERVER:="$2"} : ${PARAMS:="$3"} -: ${RENDER_TEMPLATE:="$4"} : ${VHOST_SOURCE:="/tmp/vhosts.conf.lando"} : ${SERVER_SOURCE:="/tmp/server.conf.lando"} : ${PARAMS_SOURCE:="/tmp/fastcgi_params.lando"} @@ -35,18 +34,10 @@ if [ -f "$PARAMS_SOURCE" ]; then cp -f "$PARAMS_SOURCE" "$PARAMS" fi -# Unpack components -if [ -f "/opt/bitnami/scripts/libcomponent.sh" ] && ! command -v render-template &> /dev/null; then - . /opt/bitnami/scripts/libcomponent.sh && component_unpack "render-template" "$RENDER_TEMPLATE" -fi +# Replace LANDO_WEBROOT in the vhost template +lando_info "Using sed to place correct webroot in vhost template" +sed 's@{{LANDO_WEBROOT}}@'"${LANDO_WEBROOT}"'@g' "$VHOST_SOURCE" > /opt/bitnami/nginx/conf/vhosts/lando.conf -# Render the template if render-template exists -if [ -x "$(command -v render-template)" ]; then - render-template "$VHOST_SOURCE" > /opt/bitnami/nginx/conf/vhosts/lando.conf -else - lando_info "Command render-template not found, using sed" - sed 's@{{LANDO_WEBROOT}}@'"${LANDO_WEBROOT}"'@g' "$VHOST_SOURCE" > /opt/bitnami/nginx/conf/vhosts/lando.conf -fi lando_info "Rendered template /tmp/vhosts.lando to /opt/bitnami/nginx/conf/vhosts/lando.conf" lando_debug $(cat /opt/bitnami/nginx/conf/vhosts/lando.conf) diff --git a/examples/1.25/.lando.yml b/examples/1.25/.lando.yml new file mode 100644 index 0000000..7892bfd --- /dev/null +++ b/examples/1.25/.lando.yml @@ -0,0 +1,11 @@ +name: lando-nginx-125 +services: + defaults: + type: nginx:1.25 + build_as_root: + - apt-get update && apt-get install -y curl + +# This is important because it lets lando know to test against the plugin in this repo +# DO NOT REMOVE THIS! +plugins: + "@lando/nginx": ./../../ diff --git a/examples/1.25/README.md b/examples/1.25/README.md new file mode 100644 index 0000000..f38acf7 --- /dev/null +++ b/examples/1.25/README.md @@ -0,0 +1,44 @@ +nginx Example +============= + +This example exists primarily to test the following documentation: + +* [nginx Service](https://docs.devwithlando.io/tutorials/nginx.html) + +Start up tests +-------------- + +Run the following commands to get up and running with this example. + +```bash +# Should start up successfully +lando poweroff +lando start +``` + +Verification commands +--------------------- + +Run the following commands to validate things are rolling as they should. + +```bash +# Should use 1.25.x as the default version +lando ssh -s defaults -c "nginx -v 2>&1 | grep 1.25" + +# Should serve from the app root by default +lando ssh -s defaults -c "curl http://localhost | grep ROOTDIR" + +# Should only serve over http by default +lando ssh -s defaults -c "curl https://localhost" || echo $? | grep 1 +``` + +Destroy tests +------------- + +Run the following commands to trash this app like nothing ever happened. + +```bash +# Should be destroyed with success +lando destroy -y +lando poweroff +``` diff --git a/examples/1.25/index.html b/examples/1.25/index.html new file mode 100644 index 0000000..83213b2 --- /dev/null +++ b/examples/1.25/index.html @@ -0,0 +1 @@ +ROOTDIR