diff --git a/Dockerfile b/Dockerfile index b054fb1..fedb3de 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,17 +1,25 @@ FROM ubuntu:14.04.4 -RUN apt-get update -y -RUN apt-get install -y python-setuptools python-dev build-essential libffi-dev libssl-dev +RUN apt-get update \ + && apt-get install -y -q --no-install-recommends \ + build-essential \ + libffi-dev \ + libssl-dev \ + python-dev \ + python-setuptools \ + && apt-get clean \ + && rm -r /var/lib/apt/lists/* WORKDIR /opt ADD . /opt/app WORKDIR /opt/app -RUN python setup.py build -RUN python setup.py install +RUN python setup.py build \ + && python setup.py install ADD docker/run.sh /opt/run.sh EXPOSE 57575 -ENTRYPOINT ["/opt/run.sh"] +CMD ["butterfly.server.py", "--unsecure", "--host=0.0.0.0"] +ENTRYPOINT ["docker/run.sh"] diff --git a/README.md b/README.md index 20ad40e..00f159f 100644 --- a/README.md +++ b/README.md @@ -114,7 +114,7 @@ Starting with login and password docker run \ --env PASSWORD=password \ -p 57575:57575 \ --d garland/butterfly --unsecure --host=0.0.0.0 --port=57575 --login +-d garland/butterfly --port=57575 --login ``` Starting with no password @@ -123,5 +123,5 @@ Starting with no password docker run \ --env PORT=57575 \ -p 57575:57575 \ --d garland/butterfly --unsecure --host=0.0.0.0 --port=57575 +-d garland/butterfly --port=57575 ``` diff --git a/docker/run.sh b/docker/run.sh index b7e11f9..c18acd3 100755 --- a/docker/run.sh +++ b/docker/run.sh @@ -1,6 +1,14 @@ -#!/bin/sh -x +#!/bin/bash -e + +# if command starts with an option, prepend the default command and options +if [ "${1:0:1}" = '-' ]; then + set -- butterfly.server.py --unsecure --host=0.0.0.0 --port=${PORT:-57575} "$@" +elif [ "$1" = 'butterfly.server.py' ]; then + shift + set -- butterfly.server.py --unsecure --host=0.0.0.0 --port=${PORT:-57575} "$@" +fi # Set password -echo "root:${PASSWORD}" | chpasswd +echo "root:${PASSWORD:-password}" | chpasswd -/opt/app/butterfly.server.py $@ +exec "$@"