diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..6103671 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +.git +.gitignore +.dockerignore +Dockerfile +README.md +butterfly.png diff --git a/Dockerfile b/Dockerfile index bc19a48..a959007 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,18 +1,25 @@ -FROM ubuntu:14.04.1 +FROM ubuntu:14.04 -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 -RUN chmod 777 /opt/run.sh EXPOSE 57575 -CMD ["/opt/run.sh"] \ No newline at end of file +CMD ["butterfly.server.py", "--unsecure", "--host=0.0.0.0"] +ENTRYPOINT ["docker/run.sh"] diff --git a/README.md b/README.md index 0cca3c2..bd62763 100644 --- a/README.md +++ b/README.md @@ -24,16 +24,16 @@ Butterfly is a xterm compatible terminal that runs in your browser. ## Try it -```bash - $ pip install butterfly - $ pip install libsass # If you want to use themes - $ butterfly +``` bash +$ pip install butterfly +$ pip install libsass # If you want to use themes +$ butterfly ``` A new tab should appear in your browser. Then type -```bash - $ butterfly help +``` bash +$ butterfly help ``` To get an overview of butterfly features. @@ -41,8 +41,8 @@ To get an overview of butterfly features. ## Run it as a server -```bash - $ butterfly.server.py --host=myhost --port=57575 +``` bash +$ butterfly.server.py --host=myhost --port=57575 ``` The first time it will ask you to generate the certificates (see: [here](http://paradoxxxzero.github.io/2014/03/21/butterfly-with-ssl-auth.html)) @@ -52,12 +52,12 @@ The first time it will ask you to generate the certificates (see: [here](http:// Systemd provides a way to automatically activate daemons when needed (socket activation): -```bash - $ cd /etc/systemd/system - # curl -O https://raw.githubusercontent.com/paradoxxxzero/butterfly/master/butterfly.service - # curl -O https://raw.githubusercontent.com/paradoxxxzero/butterfly/master/butterfly.socket - # systemctl enable butterfly.socket - # systemctl start butterfly.socket +``` bash +$ cd /etc/systemd/system +$ curl -O https://raw.githubusercontent.com/paradoxxxzero/butterfly/master/butterfly.service +$ curl -O https://raw.githubusercontent.com/paradoxxxzero/butterfly/master/butterfly.socket +$ systemctl enable butterfly.socket +$ systemctl start butterfly.socket ``` Don't forget to update the /etc/butterfly/butterfly.conf file with your server options (host, port, shell, ...) @@ -74,7 +74,6 @@ If you want to motivate me to continue working on this project you can tip me, s Client side development use [grunt](http://gruntjs.com/) and [bower](http://bower.io/). - ## Credits The js part is based on [term.js](https://github.com/chjj/term.js/) which is based on [jslinux](http://bellard.org/jslinux/). @@ -82,35 +81,45 @@ The js part is based on [term.js](https://github.com/chjj/term.js/) which is bas [Florian Mounier](http://paradoxxxzero.github.io/) - ## License ``` - butterfly Copyright (C) 2015 Florian Mounier +butterfly Copyright (C) 2015 Florian Mounier - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program. If not, see . +You should have received a copy of the GNU General Public License +along with this program. If not, see . ``` -## Docker Usage +## Docker There is a docker repository created for this project that is set to automatically rebuild when there is a push into this repository: https://registry.hub.docker.com/u/garland/butterfly/ -### Starting +### Example usage - docker run \ - --env PASSWORD=password \ - --env PORT=57575 \ - -p 57575:57575 \ - -d garland/butterfly +Starting with login and password +``` bash +docker run --env PASSWORD=password -d garland/butterfly --login +``` + +Starting with no password + +``` bash +docker run -d -p 57575:57575 garland/butterfly +``` + +Starting with a different port + +``` bash +docker run -d -p 12345:12345 garland/butterfly --port=12345 +``` diff --git a/docker/run.sh b/docker/run.sh old mode 100644 new mode 100755 index 4b4e7ec..c18acd3 --- a/docker/run.sh +++ b/docker/run.sh @@ -1,13 +1,14 @@ -#!/bin/sh +#!/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 -if [ -z ${PORT} ] -then - echo "Starting on default port: 57575" - /opt/app/butterfly.server.py --unsecure --host=0.0.0.0 -else - echo "Starting on port: ${PORT}" - /opt/app/butterfly.server.py --unsecure --host=0.0.0.0 --port=${PORT} -fi \ No newline at end of file +exec "$@"