Skip to content

Commit

Permalink
Docker: Support for --loom and --httpPort (#221)
Browse files Browse the repository at this point in the history
Modified start_urbit.sh script to allow the user to pick loom size and
http port.
This is the start script Native Planet uses for our docker container

Resolves #189
  • Loading branch information
matthew-levan committed Feb 14, 2023
2 parents 62425eb + 71a1c85 commit 1a9f3ab
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
5 changes: 5 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ For best performance, you must map the Ames UDP port to the *same* port on the h

For this purpose you can force Ames to use a custom port. `/bin/start-urbit --port=$AMES_PORT` can be passed as an argument to the `docker start` command. Passing `/bin/start-urbit --port=13436` for example, would use port 13436. You must pass the name of the start script `/bin/start-urbit` in order to also pass arguments, if this is omitted your container will not start.

You can also set the http port using `--http-port=$HTTP_PORT`. Passing `/bin/start-urbit --http-port=8085` for example, would use port 8085. The default http port is 8080.

### Variable Loom Size
You can also set a variable loom size using `--loom=$LOOM_SIZE`. Passing `/bin/start-urbit --loom=32` for example, would setup a 4GB loom. The default loom size is 31 (2GB).

### Examples
Creating a volume for ~sampel=palnet:
```
Expand Down
26 changes: 18 additions & 8 deletions docker/start_urbit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,26 @@
set -eu

# set defaults
amesPort=34343
amesPort="34343"
httpPort="80"
loom="31"

# check args
for i in "$@"
do
case $i in
-p=*|--port=*)
amesPort="''${i#*=}"
shift
;;
-p=*|--port=*)
amesPort="${i#*=}"
shift
;;
--http-port=*)
httpPort="${i#*=}"
shift
;;
--loom=*)
loom="${i#*=}"
shift
;;
esac
done

Expand All @@ -34,7 +44,7 @@ if [ -e *.key ]; then
mv $keyname /tmp

# Boot urbit with the key, exit when done booting
urbit $ttyflag -w $(basename $keyname .key) -k /tmp/$keyname -c $(basename $keyname .key) -p $amesPort -x
urbit $ttyflag -w $(basename $keyname .key) -k /tmp/$keyname -c $(basename $keyname .key) -p $amesPort -x --http-port $httpPort --loom $loom

# Remove the keyfile for security
rm /tmp/$keyname
Expand All @@ -45,12 +55,12 @@ elif [ -e *.comet ]; then
cometname=''${comets[0]}
rm *.comet

urbit $ttyflag -c $(basename $cometname .comet) -p $amesPort -x
urbit $ttyflag -c $(basename $cometname .comet) -p $amesPort -x --http-port $httpPort --loom $loom
fi

# Find the first directory and start urbit with the ship therein
dirnames="*/"
dirs=( $dirnames )
dirname=''${dirnames[0]}

exec urbit $ttyflag -p $amesPort $dirname
exec urbit $ttyflag -p $amesPort --http-port $httpPort --loom $loom $dirname

0 comments on commit 1a9f3ab

Please sign in to comment.