summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDemitri Swan <demitris@bu.edu>2020-02-27 08:09:56 -0800
committerGitHub <noreply@github.com>2020-02-27 08:09:56 -0800
commitcd01ddcdc1546ace85225e40b356bd2d595e965a (patch)
tree8a272a06b56e98a5627f355821b5ee72a9f86f83
parentbf8a79f72b153c76833af28aa3fb49e4b81dc910 (diff)
Update development environment to expose port 8000 by default (#17)
* Update development environment to expose port 8000 by default
-rwxr-xr-xautolib/cmd/dev29
-rw-r--r--example/README.md10
2 files changed, 28 insertions, 11 deletions
diff --git a/autolib/cmd/dev b/autolib/cmd/dev
index 2f5ed13..8165f8f 100755
--- a/autolib/cmd/dev
+++ b/autolib/cmd/dev
@@ -21,6 +21,8 @@ MUST NOT execute this command from an existing docker container.
-e Execute the following executable
-a Pass an argument to the executable given by -e. You may specify
this flag multiple times. The order is preserved.
+-p Port to map to the host environment.
+ Default: 8000
-i The docker image to use.
Default: ubuntu:18.04
Options: ubuntu:18.04, ubuntu:16.04, debian:buster, debian:stretch, debian:jessie
@@ -48,6 +50,7 @@ source $(dirname ${BASH_SOURCE[0]})/../autolib.sh
declare DOCKER_IMAGE=${DOCKER_IMAGE:=ubuntu:18.04}
declare DOCKER_EXEC
+declare DOCKER_PORT=${DOCKER_PORT=8000}
declare -a DOCKER_EXEC_ARGS
run(){
@@ -64,21 +67,22 @@ run(){
autolib_output_banner "Entering development environment"
declare -a args
- args+=(--name prometheus-client-c-dev) # Give the running container a name to use instead of the ID
- args+=(--interactive) # Interactive shell
- args+=(--tty) # We'll need a tty
- args+=(--volume "${PWD}:/code") # Mount code into the container
- args+=(--env DEV=1) # Enables check if executing in dev environment
- args+=(--net host) # Use host networking
- args+=(--cap-add=SYS_PTRACE) # Required for valgrind and gdb
- args+=(--security-opt seccomp=unconfined) # Required for debugging
- args+=(--rm) # Remove when done
-
+ args+=(--name prometheus-client-c-dev) # Give the running container a name to use instead of the ID
+ args+=(--interactive) # Interactive shell
+ args+=(--tty) # We'll need a tty
+ args+=(--volume "${PWD}:/code") # Mount code into the container
+ args+=(--env DEV=1) # Enables check if executing in dev environment
+ args+=(--cap-add=SYS_PTRACE) # Required for valgrind and gdb
+ args+=(--security-opt seccomp=unconfined) # Required for debugging
+ args+=(--publish $DOCKER_PORT:$DOCKER_PORT) # map DOCKER_PORT to the host
+ args+=(--rm) # Remove when done
+
+ echo ${args[@]}
docker run ${args[@]} prometheus-client-c-dev ${DOCKER_EXEC} ${DOCKER_EXEC_ARGS[@]}
}
main(){
- while getopts "he:a:i:" opt; do
+ while getopts "he:a:i:p:" opt; do
case $opt in
( h ) {
usage && exit 0
@@ -92,6 +96,9 @@ main(){
( a ) {
DOCKER_EXEC_ARGS+=($OPTARG)
} ;;
+ ( p ) {
+ DOCKER_PORT=${OPTARG}
+ } ;;
esac
done
run $@; exit $?
diff --git a/example/README.md b/example/README.md
new file mode 100644
index 0000000..1936c99
--- /dev/null
+++ b/example/README.md
@@ -0,0 +1,10 @@
+# Example
+
+To run this example:
+
+* Execute `./auto dev` from the root of the project directory to enter the development environment
+* Execute `cd example`
+* Execute `make`
+* This process will build a binary called example in the current working directory. Execute `./example` to execute the
+ example.
+* In another shell, execute `curl http://0.0.0.0:8000/metrics` \ No newline at end of file