github.com/drud/ddev@v1.21.5-alpha1.0.20230226034409-94fcc4b94453/containers/ddev-router/docker-entrypoint.sh (about)

     1  #!/bin/bash
     2  set -eu -o pipefail
     3  
     4  rm -f /tmp/healthy
     5  
     6  export HTTP2=http2
     7  if [ "${DISABLE_HTTP2:-}" = "true" ]; then HTTP2=""; fi
     8  
     9  # Warn if the DOCKER_HOST socket does not exist
    10  if [[ $DOCKER_HOST = unix://* ]]; then
    11  	socket_file=${DOCKER_HOST#unix://}
    12  	if ! [ -S $socket_file ]; then
    13  		cat >&2 <<-EOT
    14  			ERROR: you need to share your Docker host socket with a volume at $socket_file
    15  			Typically you should run this container with: \`-v /var/run/docker.sock:$socket_file:ro\`
    16  			See the documentation at http://git.io/vZaGJ
    17  		EOT
    18  		socketMissing=1
    19  	fi
    20  fi
    21  
    22  # Compute the DNS resolvers for use in the templates - if the IP contains ":", it's IPv6 and must be enclosed in []
    23  export RESOLVERS=$(awk '$1 == "nameserver" {print ($2 ~ ":")? "["$2"]": $2}' ORS=' ' /etc/resolv.conf | sed 's/ *$//g')
    24  if [ "x$RESOLVERS" = "x" ]; then
    25      echo "Warning: unable to determine DNS resolvers for nginx" >&2
    26      unset RESOLVERS
    27  fi
    28  
    29  # If the user has run the default command and the socket doesn't exist, fail
    30  if [ "${socketMissing:-}" = 1 -a "$1" = forego -a "$2" = start -a "$3" = '-r' ]; then
    31  	exit 1
    32  fi
    33  
    34  if [ ! -z "${USE_LETSENCRYPT:-}" ]; then
    35    echo "Lets Encrypt is enabled:"
    36    certbot certificates
    37  fi
    38  
    39  mkcert -install
    40  
    41  # It's unknown what docker event causes an attempt to use these certs/.crt files, but they might as well exist
    42  # to prevent it.
    43  mkcert -cert-file /etc/nginx/certs/.crt -key-file /etc/nginx/certs/.key "*.ddev.local" "*.ddev.site" 127.0.0.1 localhost ddev-router ddev-router.ddev
    44  
    45  if [ ! -f /etc/nginx/certs/master.crt ]; then
    46    mkcert -cert-file /etc/nginx/certs/master.crt -key-file /etc/nginx/certs/master.key "*.ddev.local" "*.ddev.site" "ddev-router" "ddev-router.ddev" 127.0.0.1 localhost
    47  fi
    48  exec "$@"