diff --git a/README.md b/README.md index bb9bacfbf..1ebb9326c 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,22 @@ on your `PATH`. `pytest test/` +# Manual Testing + +The port 8000 of the docker environment and the system are automatically binded when ``./run_docker`` is run. + +This can be used to test the ``pyodide`` builds running within the docker environment using external browser +programs of the system. + +To do this, simply run ``./bin/pyodide serve`` + +This serves the ``build`` directory of the ``pyodide`` project on port 8000. + +* To serve a different directory, use the ``--build_dir`` argument followed the path of the directory +* To serve on a different port, use the ``--port`` argument followed by the desired port number + +Make sure that the port passed in ``--port`` argument is same as the one defined as ``DOCKER_PORT`` in the ``run_docker`` script. + # Benchmarking Install the same dependencies as for testing. diff --git a/pyodide_build/serve.py b/pyodide_build/serve.py index 813727706..6d475438b 100644 --- a/pyodide_build/serve.py +++ b/pyodide_build/serve.py @@ -37,9 +37,9 @@ def main(args): build_dir = args.build_dir port = args.port httpd = server(port) + os.chdir(build_dir) + print("serving from {0} at localhost:".format(build_dir) + str(port)) try: - os.chdir(build_dir) - print("serving from {0} at localhost:".format(build_dir) + str(port)) httpd.serve_forever() except KeyboardInterrupt: print("\n...shutting down http server") diff --git a/run_docker b/run_docker index df5883829..15ed485f3 100755 --- a/run_docker +++ b/run_docker @@ -1,2 +1,5 @@ #!/bin/sh -docker run -p 8000:8000 --rm -v $PWD:/src --user root -e NB_UID=$UID -e NB_GID=$GID -it iodide/pyodide-env:0.3.1 /bin/bash +DOCKER_PORT=8000 +SYSTEM_PORT=8000 + +docker run -p $SYSTEM_PORT:$DOCKER_PORT --rm -v $PWD:/src --user root -e NB_UID=$UID -e NB_GID=$GID -it iodide/pyodide-env:0.3.1 /bin/bash