Easy quick phaser environment for anywhere Docker runs
Current latest version: Phaser 3.3
Install docker-phaser nodejs runtime with the latest supported Phaser library
docker pull chrisdlangton/docker-phaser:latest
Specify a specific supported Phaser version
docker pull chrisdlangton/docker-phaser:3.3
- Secure Docker Linux environment running nodejs 9.10 typical for Phaser3 projects
- Create Phaser Web games with ease: rblopes/generator-phaser-plus
- A simple static server written in node.js nbluis/static-server available on you're own configurable port (or default 3000)
- Helper functions that manage the Docker and Phaser web server (for UNIX-like environments)
- Official Phaser 3 Webpack Project Template photonstorm/phaser3-project-template available in directory
/phaser/boilerplate
The official Phaser 3 Webpack Project Template in /phaser/boilerplate
can be started with npm start
in it directory which starts a web server on port 8080.
You should get familiar with this boilerplate by making changes and testing, when ready to start you're own project it is recommended you fork the project yourself on your host and when running docker-phaser mount that project to /phaser/src
by following the next step below.
Here (phaser3-sandpit) is an example of where to start if you were to use the official phaser3 webpack template.
Enable the helper function in a UNIX-like environment (Mac/Linux) with
source phaser.bash
-
ensure you have a
package.json
in the project root -
create a
.env
file in the project root (using the.evn-example
as a reference)
DOCKER_PHASER_ROOT=/path/to/project # Required: set this to build and run docker-phaser with it's helper functions
PROJECT_NAME=docker-phaser # Required: set this to build and run docker-phaser with it's helper functions
DOCKERHUB_USER=chrisdlangton # Required: set this to build and run docker-phaser with it's helper functions
SERVER_PORT=3000 # optionally change the static server port to bind too insdie the container
HOST_PORT=3000 # optional, port to listen on the host side
HOST_ADDR=127.0.0.1 # optional, address to bind to on the host side
PHASER_INDEX=src/index.html # optionally change the static server index file from this default value
STATIC_SERVER_ARGS="--cors --no-cache" # optional arguments for the node static server (see the link in features section)
-
all of the phaser project files should be in the
src
directoy within the project root -
the static web server expects an
src/index.html
file, or you may choose to change it withPHASER_INDEX
in your.env
-
OPTIONALLY: to preserve bash history between running containers create a
.bash_history_docker
file in the project root -
OPTIONALLY: disable the static server, or rather run the webpack-dev-server only just add your own
Dockerfile
;
FROM chrisdlangton/docker-phaser
CMD [ "npm", "start" ]
and ensure you've added to you package.json
the following;
"scripts": {
"build": "webpack",
"start": "npm run build && webpack-dev-server --port=8080"
}
Ensure you've followed the Project structure
phaser-build
this will run the latest supported version of phaser, alternatively you may provide a version
phaser-build 3.3
Ensure you've first run build-phaser
phaser-start
And now in the browser visit the address output. Default is localhost:3000
optionally you can start the web server with a specific NODE_ENV
value with
phaser-start prod
you can run a 1-off command inside the contaienr with
phaser-exec ls -la
or drop into a shell with just phaser-exec
This can simply be done with phaser-stop
This can simply be done with phaser-restart
Extend the implementation by adding files and commands in your own project Dockerfile
with FROM chrisdlangton/docker-phaser
.
If the functionality you're adding is useful to others please consider contributing to this project by forking and createding a pull request.