mirror of https://github.com/pyodide/pyodide.git
run_docker: Allow to run arbitrary command in docker (#1424)
Useful for unattended builds.
This commit is contained in:
parent
52045b7802
commit
2c98abfd73
|
@ -149,6 +149,8 @@ substitutions:
|
|||
[#987](https://github.com/pyodide/pyodide/pull/987).
|
||||
- {{ Enhancement }} Optionally to disable docker port binding
|
||||
[#1423](https://github.com/pyodide/pyodide/pull/1423).
|
||||
- {{ Enhancement }} Run arbitrary command in docker
|
||||
[#1424](https://github.com/pyodide/pyodide/pull/1424)
|
||||
|
||||
### REPL
|
||||
|
||||
|
|
34
run_docker
34
run_docker
|
@ -5,20 +5,21 @@ set -eo pipefail
|
|||
|
||||
function usage() {
|
||||
cat > /dev/stdout <<EOF
|
||||
Usage:
|
||||
run_docker [OPTIONS]
|
||||
Usage: run_docker [OPTIONS] [COMMAND] [ARG...]
|
||||
|
||||
Optional flags:
|
||||
-h, --help Show this information and exit
|
||||
--pre-built Use the prebuilt pyodide image.
|
||||
This is ignored if the env var PYODIDE_DOCKER_IMAGE is set
|
||||
-p, --port <port> System port to which to forward.
|
||||
This is ignored if the env var PYODIDE_SYSTEM_PORT is set
|
||||
If set to 'none', docker instance will not bind to any port
|
||||
(Useful for running the docker in multi-user environment)
|
||||
Runs COMMAND in a new Pyodide docker container. If no COMMAND is provided, starts a bash
|
||||
shell in the container.
|
||||
|
||||
Prerequisites:
|
||||
Docker has to be set up on your system
|
||||
Options:
|
||||
-h, --help Show this information and exit.
|
||||
--pre-built Use the prebuilt Pyodide image.
|
||||
This is ignored if the env var PYODIDE_DOCKER_IMAGE is set.
|
||||
-p, --port <port> System port to which to forward.
|
||||
This is ignored if the env var PYODIDE_SYSTEM_PORT is set.
|
||||
If set to 'none', docker instance will not bind to any port.
|
||||
|
||||
Prerequisites:
|
||||
Docker has to be set up on your system.
|
||||
EOF
|
||||
}
|
||||
|
||||
|
@ -32,6 +33,7 @@ PYODIDE_IMAGE_TAG="12"
|
|||
PYODIDE_PREBUILT_IMAGE_TAG="0.17.0a2"
|
||||
DEFAULT_PYODIDE_DOCKER_IMAGE="iodide/pyodide-env:${PYODIDE_IMAGE_TAG}"
|
||||
DEFAULT_PYODIDE_SYSTEM_PORT="8000"
|
||||
DOCKER_COMMAND="/bin/bash"
|
||||
|
||||
while [[ $# -gt 0 ]]
|
||||
do
|
||||
|
@ -60,10 +62,14 @@ do
|
|||
DEFAULT_PYODIDE_SYSTEM_PORT=$2
|
||||
shift 2
|
||||
;;
|
||||
*)
|
||||
-*)
|
||||
>&2 echo "Unknown option $1"
|
||||
error
|
||||
;;
|
||||
*)
|
||||
DOCKER_COMMAND="$@"
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
|
@ -92,4 +98,4 @@ exec docker run \
|
|||
--user root -e NB_UID=$UID -e NB_GID=$GID \
|
||||
--shm-size 2g \
|
||||
"${PYODIDE_DOCKER_IMAGE}" \
|
||||
/bin/bash
|
||||
$DOCKER_COMMAND
|
||||
|
|
Loading…
Reference in New Issue