Skip to content

Commit

Permalink
fix(build): issues/274 update proxy docker port mapping (#276)
Browse files Browse the repository at this point in the history
* build, API updates, proxy run origin header needs port 443
* docs, contributing reference added for port 443 troubleshooting
  • Loading branch information
cdcabrera committed May 8, 2020
1 parent 709060d commit 7e13684
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
11 changes: 10 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,15 @@ Serving content comes in 3 variations
Occasionally the proxy setup will attempt to connect, acknowledge that it's connected, but then fail to load the GUI.
Things to try:

#### It's the Port, maybe?
The API requires a secure origin header within its AJAX/XHR calls.
1. Stop the build
1. Confirm within `package.json` that the NPM scripts
- `$ yarn api:proxy` has a port parameter setting of `443`
- `$ start:proxy` has a browser open command aimed at `...proxy; open https://ci.foo.redhat.com...`
1. Run the build again, `$ yarn start:proxy`
1. Confirm you browser is pointed at `https://ci.foo.redhat.com/`

#### It's Docker?
1. Stop the build
1. Restart Docker
Expand Down Expand Up @@ -241,5 +250,5 @@ After setting up the repository...
```
$ yarn test:dev
```
1. Make sure your browser opened around the domain `https://*.foo.redhat.com:1337`
1. Make sure your browser opened around the domain `https://*.foo.redhat.com/`
1. Start developing...
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"api:dev": "mock -p 5000 -w ./src/services",
"api:docs": "node ./scripts/openapi.docs.js",
"api:proxy-hosts": "sh ./scripts/proxy.api.sh -s",
"api:proxy": "sh ./scripts/proxy.api.sh -d \"ci.foo.redhat.com\" -p 1337 -c \"$(pwd)/config/spandx.config.js\"",
"api:proxy": "sh ./scripts/proxy.api.sh -d \"https://ci.foo.redhat.com/beta/subscriptions/\" -p 443 -c \"$(pwd)/config/spandx.config.js\"",
"api:proxyClean": "sh ./scripts/proxy.api.sh -u",
"build": "run-s -l build:pre build:js build:post test:integration",
"build:js": "react-scripts build",
Expand All @@ -64,7 +64,7 @@
"release": "standard-version",
"start": "run-s dev:chrome; run-p -l api:dev start:js",
"start:js": "react-scripts start",
"start:proxy": "sh -ac '. ./.env.proxy; open https://ci.foo.redhat.com:1337/beta/subscriptions/; run-s api:proxy-hosts; run-p -l start:js api:proxy'",
"start:proxy": "sh -ac '. ./.env.proxy; run-s api:proxy-hosts; run-p -l start:js api:proxy'",
"start:standalone": "rm ./.env.development.local; run-p -l api:dev start:js",
"test": "run-s test:lint test:ci",
"test:ci": "export CI=true; react-scripts test --env=jsdom --roots=./src --coverage",
Expand Down
15 changes: 12 additions & 3 deletions scripts/proxy.api.sh
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,16 @@ runProxy()
RUN_CONFIG="-e CUSTOM_CONF=true -v ${RUN_CONFIG}:/config/spandx.config.js"
fi

docker run -d --rm -p $RUN_PORT:1337 $RUN_CONFIG -e PLATFORM -e PORT -e LOCAL_API -e SPANDX_HOST -e SPANDX_PORT --name $RUN_NAME $RUN_CONTAINER >/dev/null
docker run -d --rm -p $RUN_PORT:$RUN_PORT $RUN_CONFIG -e PLATFORM -e PORT -e LOCAL_API -e SPANDX_HOST -e SPANDX_PORT=$RUN_PORT --name $RUN_NAME $RUN_CONTAINER >/dev/null
fi

checkContainerRunning $RUN_NAME

if [ ! -z "$(docker ps | grep $RUN_CONTAINER)" ]; then
printf " ${YELLOW}Container: $(docker ps | grep $RUN_CONTAINER | cut -c 1-50)${NOCOLOR}\n"
echo " Development proxy running: http://${RUN_DOMAIN}:${RUN_PORT}/"
echo " Development proxy running on ${RUN_PORT}: ${RUN_DOMAIN}"
printf " To stop: $ ${YELLOW}docker stop ${RUN_NAME}${NOCOLOR}\n"
open "${RUN_DOMAIN}"
fi

exit 0
Expand All @@ -168,8 +169,8 @@ runProxy()
YELLOW="\e[33m"
NOCOLOR="\e[39m"

DOMAIN="localhost"
PORT=1337
DOMAIN=""
CONFIG=""
UPDATE=false
HOST_ONLY=false
Expand All @@ -193,6 +194,14 @@ runProxy()
esac
done

if [ -z "$DOMAIN" ]; then
if (( $PORT % 2 )); then
DOMAIN="https://localhost:$PORT"
else
DOMAIN="http://localhost:$PORT"
fi
fi

if [ "$UPDATE" = true ]; then
printf "${YELLOW}Updating ${CONTAINER_NAME}, Docker and data...${NOCOLOR}\n"
docker stop -t 0 $CONTAINER_NAME
Expand Down

0 comments on commit 7e13684

Please sign in to comment.