-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11551 from wellcomecollection/rk/everything-every…
…where-all-at-once-sausage-fingers Add configuration to run against local APIs
- Loading branch information
Showing
20 changed files
with
306 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
SCRIPTS_DIR=${DIR}/configure-local-apis | ||
|
||
# colours | ||
YELLOW='\033[1;33m' | ||
MAGENTA='\033[1;35m' | ||
GREEN='\033[1;32m' | ||
NC='\033[0m' # no colour - reset console colour | ||
|
||
setup_deps() {( set -e | ||
echo -e "${MAGENTA}Setting up OSX dependencies ...${NC}" | ||
if ! command -v brew &> /dev/null | ||
then | ||
echo "Please install brew.sh: https://brew.sh/" | ||
exit 1 | ||
fi | ||
brew install mkcert nginx | ||
)} | ||
|
||
install_certs() {( set -e | ||
echo -e "${MAGENTA}Setting up local certificates for wellcomecollection.org${NC} ..." | ||
$SCRIPTS_DIR/setup-mkcert.sh www-dev.wellcomecollection.org | ||
$SCRIPTS_DIR/setup-mkcert.sh api-dev.wellcomecollection.org | ||
)} | ||
|
||
add_to_etc_hosts() {( set -e | ||
echo -e "${MAGENTA}Adding entries to /etc/hosts ...${NC}" | ||
$SCRIPTS_DIR/add-to-etc-hosts.sh www-dev.wellcomecollection.org | ||
$SCRIPTS_DIR/add-to-etc-hosts.sh api-dev.wellcomecollection.org | ||
)} | ||
|
||
configure_nginx() {( set -e | ||
echo -e "${MAGENTA}Configuring nginx ...${NC}" | ||
$SCRIPTS_DIR/update-nginx-config.sh | ||
)} | ||
|
||
setup_deps | ||
install_certs | ||
add_to_etc_hosts | ||
configure_nginx | ||
|
||
# echo sparkles then "All done! in green | ||
|
||
echo -e "\n${GREEN} ✨ All done!${NC}" | ||
echo -e "\n${YELLOW}Please restart nginx: \"sudo bash -c 'nginx -s stop && nginx'\"${NC}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Developer NGINX configuration scripts | ||
|
||
The scripts in this folder assist with the configuration of a local nginx installation for development purposes. | ||
|
||
These scripts have been shamelessly adapted (mostly copied) from https://github.com/guardian/dev-nginx. Credit to | ||
the developers of that project! | ||
|
||
## Usage | ||
|
||
Run the `configure-local-apis.sh` script in the parent directory. | ||
|
||
You can view the nginx configuration files in [weco-local.conf](./weco-local.conf), | ||
it depends on thelocal APIs to be started successfully, and use the specified ports. | ||
|
||
- Catalogue Search, Works & Images API: http://localhost:8080 | ||
- Catalogue Items API: http://localhost:8081 | ||
- Concept API: http://localhost:3001 | ||
- Content API: http://localhost:3002 | ||
|
||
Configuration for Identity, Accounts and Requests is not included in this script. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
# colours | ||
YELLOW='\033[1;33m' | ||
NC='\033[0m' # no colour - reset console colour | ||
|
||
if [[ $# -lt 1 ]] | ||
then | ||
echo "add-to-hosts-file <DOMAIN>" | ||
echo "Add an entry to hosts file to resolve to 127.0.0.1" | ||
echo "Example: add-to-hosts-file foo.local" | ||
exit 1 | ||
fi | ||
|
||
DOMAIN=$1 | ||
|
||
if grep '127.0.0.1' /etc/hosts | grep ${DOMAIN} ; then | ||
echo -e "✅ /etc/hosts entry already exists for ${DOMAIN}" | ||
else | ||
echo -e "🔧 ${YELLOW}adding /etc/hosts entry for ${DOMAIN}. Requires sudo - enter password when prompted.${NC}" | ||
sudo sh -c "echo '127.0.0.1 ${DOMAIN}' >> /etc/hosts" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
nginx -V 2>&1 | grep "configure arguments:" | sed 's/[^*]*conf-path=\([^ ]*\)\/nginx\.conf.*/\1/g' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
# Create a certificate using mkcert. Assumes you have installed mkcert previously. | ||
# Will add the CA to the truststore for macOS, Firefox and Java. | ||
|
||
# colours | ||
YELLOW='\033[1;33m' | ||
NC='\033[0m' # no colour - reset console colour | ||
|
||
if [[ $# -lt 1 ]] | ||
then | ||
echo -e "Create a certificate for ${YELLOW}development use only${NC} using mkcert." | ||
echo -e "See https://github.com/FiloSottile/mkcert for more information." | ||
echo | ||
echo "Example usage: $0 foo.local" | ||
exit 1 | ||
fi | ||
|
||
if type -p java > /dev/null ; then | ||
# ensure JAVA_HOME is set for mkcert to install local root CA in the java trust store | ||
# see https://github.com/FiloSottile/mkcert#supported-root-stores | ||
if test -z ${JAVA_HOME} ; then | ||
if [[ $(uname -s) == Darwin ]] ; then | ||
echo -e "☕️ Running macOS and JAVA_HOME is not set. Attempting to set it..." | ||
export JAVA_HOME=$(/usr/libexec/java_home) | ||
echo -e "✅ JAVA_HOME now set to ${JAVA_HOME}" | ||
else | ||
echo -e "☕️ Java is installed but JAVA_HOME is not set. Set it before running this script." | ||
exit 1 | ||
fi | ||
fi | ||
else | ||
echo -e "☕️ Did not detect an installation of Java." | ||
fi | ||
|
||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
|
||
NGINX_HOME=$("${DIR}/locate-nginx.sh") | ||
CERT_DIRECTORY=$HOME/.weco/mkcert | ||
|
||
DOMAIN=$1 | ||
|
||
KEY_FILE=${CERT_DIRECTORY}/${DOMAIN}.key | ||
CERT_FILE=${CERT_DIRECTORY}/${DOMAIN}.crt | ||
|
||
mkcert -install | ||
|
||
echo -e "🔐 Creating certificate for: ${YELLOW}${DOMAIN}${NC}" | ||
mkdir -p ${CERT_DIRECTORY} | ||
mkcert -key-file=${KEY_FILE} -cert-file=${CERT_FILE} ${DOMAIN} | ||
|
||
echo -e "Symlinking the certificate for nginx at ${NGINX_HOME}" | ||
ln -sf ${KEY_FILE} ${NGINX_HOME}/${DOMAIN}.key | ||
ln -sf ${CERT_FILE} ${NGINX_HOME}/${DOMAIN}.crt | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
|
||
# colours | ||
YELLOW='\033[1;33m' | ||
NC='\033[0m' # no colour - reset console colour | ||
|
||
NGINX_HOME=$("${DIR}/locate-nginx.sh") | ||
|
||
# ensure $NGINX_HOME/servers exists | ||
mkdir -p $NGINX_HOME/servers | ||
|
||
# check if $NGINX_HOME/servers/weco-local.conf exists and has the same contents as $DIR/weco-local.conf | ||
if [ -f $NGINX_HOME/servers/weco-local.conf ]; then | ||
if cmp -s $DIR/weco-local.conf $NGINX_HOME/servers/weco-local.conf; then | ||
echo -e "✅ ${NGINX_HOME}/servers/weco-local.conf is up to date" | ||
exit 0 | ||
else | ||
echo -e "🔧 ${YELLOW}updating ${NGINX_HOME}/servers/weco-local.conf${NC}" | ||
fi | ||
else | ||
echo -e "🔧 ${YELLOW}creating ${NGINX_HOME}/servers/weco-local.conf${NC}" | ||
fi | ||
|
||
cp $DIR/weco-local.conf $NGINX_HOME/servers/ |
Oops, something went wrong.