A Phaser 3 project with ES6 support via Babel 7 and Webpack 4 that includes hot-reloading for development and production-ready builds primed for OpenShift.
Command | Description |
---|---|
npm install |
Install project dependencies |
npm start |
Build project and open webserver for running project locally |
npm run build |
Builds code as a bundle for production (minification, uglification, etc..) |
Simple, that's just this:
npm install; npm start
(edit files all you want and hotdeploy will watch/update for you)
set the env var
export DEBUG_INPUT=true
to see the input panel and allow setting high scoresset the env var
export API_SERVER_URL=localhost:5000
to hook up to an API server (if you're running one)
When you run the npm run build
command, your code will be built into a single bundle located at dist/bundle.min.js
along with any other assets you project depends upon.
Containerizing and pushing this app into your OpenShift cluster is easy with the help of NodeShift. It will create the OpenShift configuration needed, do a build inside the cluster, then deploy the app, and expose a URL route into it. Just run this command
npx nodeshift --web-app --build.env OUTPUT_DIR=dist --expose
(edit files and rerun
npx nodeshift
and it will update OpenShift for you)add the env config
--build.env DEBUG_INPUT=true
to true to see the input panel and allow setting highscoresset the env var
--build.env API_SERVER_URL=http://route_to_api_service:80
to hook up to an API server (note this is the external openshift route not the service name)set the env var
--build-env API_SERVER_WEBSOCKET_URL=ws://route_to_api_service:80
to hook up to an API server (note this is the external openshift route not the service name)
Expose our app to outside the cluster
oc expose service openshift-highscores-phaser-ui
This is also pretty easy with the help of Source 2 Image (aka s2i). Run the following (after replacing the github URL with yours):
oc new-app nodeshift/ubi8-s2i-web-app:latest~https://github.com/CodeCafeOpenShiftGame/openshift-highscores-phaser-ui --build-env OUTPUT_DIR=dist
add the env config
--build-env DEBUG_INPUT=true
to true to see the input panel and allow setting highscoresset the env var
--build-env API_SERVER_URL=http://route_to_api_service:80
to hook up to an API server (note this is the external openshift route not the service name)set the env var
--build-env API_SERVER_WEBSOCKET_URL=ws://route_to_api_service:80
to hook up to an API server (note this is the external openshift route not the service name)
Expose our app to outside the cluster
oc expose service openshift-highscores-phaser-ui
API_SERVER_URL
andAPI_SERVER_WEBSOCKET_URL
can usehttps
andwss
as long as they a both set to be secure (use port 443)
Thanks to Richard Davey @ Phaser for the tutorials here that this was initially based upon.