1 07. Helper scripts
Asif Bacchus edited this page 2021-01-16 06:23:50 -07:00
This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

Helper scripts

This section is completely optional and not at all required to run the container.

Ive put together a few scripts to make things easier for you and reduce the amount of typing required to get everything mounted and running correctly. I use these in my own deployments for the same reasons, so maybe theyll be useful for you too.

Contents

Get the scripts
The update script
The helper-script
The params file

Get the scripts

The scripts are located in the /helpers directory of the git repo associated with this container. You can get them in any of the following ways:

  • Clone the repo:

    This will download all the repo contents including the Dockerfile, sample configurations and the helper scripts.

    # scripts will be located in ./ab-nginx/helpers
    git clone https://git.asifbacchus.app/ab-docker/ab-nginx.git
    
  • Download the latest release:

    This will download the latest scripts along with sample (generic) configurations and a basic directory structure. No other git repo contents will be downloaded (i.e. no Dockerfile, etc.)

    # visit https://git.asifbacchus.app/ab-docker/ab-nginx/releases to find the latest version tag
    wget -O scripts.tar.gz https://git.asifbacchus.app/ab-docker/ab-nginx/releases/tag/<version_tag>
    tar -xzf scripts.tar.gz --strip 2
    
  • Download the update script and run it:

    This will download the latest scripts. No sample configurations or other git repo contents will be downloaded.

    wget https://asifbacchus.app/updates/docker/nginx/ab-nginx/update.sh
    chmod +x update.sh
    
    # if you run update.sh without any options it will pull/update the container and download scripts
    ./update.sh --scripts-only
    

The update script

The update script provides a simple way to keep your container and the helper-scripts up to date. Simply run the shell script and, by default, it will update everything. After the updates are downloaded, you can manually stop your old container whenever it is convenient and start the new one either manually or using the helper-script.

You can see the script options by running ./update.sh --help.

The helper-script

The helper script is meant to save you typing, prevent errors in starting the container and make it simple to launch the container with the desired options. The script automates:

  • binding certificates
  • selecting TLS1.2+1.3 vs TLS1.3
  • enforcing HSTS
  • locations of configuration files, server-blocks and webroot files
  • creation of a dedicated docker network, optionally using a specific subnet
  • launching an auto-removed container in shell mode to troubleshoot configuration settings

You can see the script options by running ./ab-nginx.sh --help.

The params file

The helper-script is totally dependant on the .params file bearing the same name as the script. That file is fully annotated with detailed descriptions about the meaning and use of each parameter contained within it. In addition, it plainly states which parameters are required and which are optional. The best way to understand the file is to simply open it and read the comments I promise, I kept it pretty simple 😛.

Before filling out the .params file, you need to rename the template file that comes with the helper-script archive/update.

cp ab-nginx.params.template ab-nginx.params

Once the .params file is filled out with at least a webroot and optionally, but quite likely, SSL certificate locations, you will be able to start the helper-script and it will auto-configure all the bind-mounts and variables for you:

./ab-nginx.sh

Thats it!