From bce9f99b0be317423e9b02b52d55e45826ae8e2b Mon Sep 17 00:00:00 2001 From: gar Date: Tue, 9 Aug 2016 20:47:09 -0700 Subject: [PATCH 1/8] Updating docker container with the new usage flag --- Dockerfile | 4 ++-- README.md | 27 ++++++++++++++++++++------- docker/run.sh | 11 ++--------- 3 files changed, 24 insertions(+), 18 deletions(-) diff --git a/Dockerfile b/Dockerfile index bc19a48..2b929da 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:14.04.1 +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 @@ -15,4 +15,4 @@ RUN chmod 777 /opt/run.sh EXPOSE 57575 -CMD ["/opt/run.sh"] \ No newline at end of file +ENTRYPOINT ["/opt/run.sh"] diff --git a/README.md b/README.md index 0cca3c2..faece1b 100644 --- a/README.md +++ b/README.md @@ -102,15 +102,28 @@ The js part is based on [term.js](https://github.com/chjj/term.js/) which is bas 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 +``` +docker run \ +--env PASSWORD=password \ +--env PORT=57575 \ +-p 57575:57575 \ +-d garland/butterfly --unsecure --host=0.0.0.0 --port=57575 --login +``` + +Starting with no password + +``` +docker run \ +--env PASSWORD=password \ +--env PORT=57575 \ +-p 57575:57575 \ +-d garland/butterfly --unsecure --host=0.0.0.0 --port=57575 --login +``` diff --git a/docker/run.sh b/docker/run.sh index 4b4e7ec..b7e11f9 100644 --- a/docker/run.sh +++ b/docker/run.sh @@ -1,13 +1,6 @@ -#!/bin/sh +#!/bin/sh -x # Set password echo "root:${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 +/opt/app/butterfly.server.py $@ From 524e578fca0b6998f9d6ffe56e43faf345a07466 Mon Sep 17 00:00:00 2001 From: gar Date: Tue, 9 Aug 2016 20:51:19 -0700 Subject: [PATCH 2/8] Updating readme with correct no password usage --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index faece1b..20ad40e 100644 --- a/README.md +++ b/README.md @@ -113,7 +113,6 @@ Starting with login and password ``` docker run \ --env PASSWORD=password \ ---env PORT=57575 \ -p 57575:57575 \ -d garland/butterfly --unsecure --host=0.0.0.0 --port=57575 --login ``` @@ -122,8 +121,7 @@ Starting with no password ``` docker run \ ---env PASSWORD=password \ --env PORT=57575 \ -p 57575:57575 \ --d garland/butterfly --unsecure --host=0.0.0.0 --port=57575 --login +-d garland/butterfly --unsecure --host=0.0.0.0 --port=57575 ``` From 1ec50810f933f5839a303b8016a9320f0ca7b152 Mon Sep 17 00:00:00 2001 From: gar Date: Wed, 10 Aug 2016 09:07:51 -0700 Subject: [PATCH 3/8] Make script executable --- Dockerfile | 1 - docker/run.sh | 0 2 files changed, 1 deletion(-) mode change 100644 => 100755 docker/run.sh diff --git a/Dockerfile b/Dockerfile index 2b929da..b054fb1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,7 +11,6 @@ RUN python setup.py build RUN python setup.py install ADD docker/run.sh /opt/run.sh -RUN chmod 777 /opt/run.sh EXPOSE 57575 diff --git a/docker/run.sh b/docker/run.sh old mode 100644 new mode 100755 From cc510500a5eaec903386690508821fd8b27ee6eb Mon Sep 17 00:00:00 2001 From: gar Date: Wed, 10 Aug 2016 09:19:14 -0700 Subject: [PATCH 4/8] Do @thaJeztah container efficiency suggestions --- Dockerfile | 18 +++++++++++++----- README.md | 4 ++-- docker/run.sh | 14 +++++++++++--- 3 files changed, 26 insertions(+), 10 deletions(-) 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 "$@" From 2d3bed2fef8688ac819d5216d3c3179c7e55ad53 Mon Sep 17 00:00:00 2001 From: Philippe Vaucher Date: Tue, 6 Sep 2016 08:56:45 +0200 Subject: [PATCH 5/8] Use ubuntu:14.04 base image --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index fedb3de..a959007 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:14.04.4 +FROM ubuntu:14.04 RUN apt-get update \ && apt-get install -y -q --no-install-recommends \ From b72da2e4efb528b30aa6c9f17f93e8667aa7595f Mon Sep 17 00:00:00 2001 From: Philippe Vaucher Date: Tue, 6 Sep 2016 08:59:23 +0200 Subject: [PATCH 6/8] Prettify README code blocks --- README.md | 56 +++++++++++++++++++++++++++---------------------------- 1 file changed, 27 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index 00f159f..0a43682 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,24 +81,23 @@ 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 @@ -110,7 +108,7 @@ into this repository: https://registry.hub.docker.com/u/garland/butterfly/ Starting with login and password -``` +``` bash docker run \ --env PASSWORD=password \ -p 57575:57575 \ @@ -119,7 +117,7 @@ docker run \ Starting with no password -``` +``` bash docker run \ --env PORT=57575 \ -p 57575:57575 \ From e5eb7050e8694c49f2ce18e31429bc9704d5342a Mon Sep 17 00:00:00 2001 From: Philippe Vaucher Date: Tue, 6 Sep 2016 09:02:11 +0200 Subject: [PATCH 7/8] Add .dockerignore --- .dockerignore | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .dockerignore 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 From a3e78112a68007794e3d1251aa0cbaef8e33d3ef Mon Sep 17 00:00:00 2001 From: Philippe Vaucher Date: Tue, 6 Sep 2016 09:05:11 +0200 Subject: [PATCH 8/8] Improve README examples --- README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 0a43682..bd62763 100644 --- a/README.md +++ b/README.md @@ -109,17 +109,17 @@ into this repository: https://registry.hub.docker.com/u/garland/butterfly/ Starting with login and password ``` bash -docker run \ ---env PASSWORD=password \ --p 57575:57575 \ --d garland/butterfly --port=57575 --login +docker run --env PASSWORD=password -d garland/butterfly --login ``` Starting with no password ``` bash -docker run \ ---env PORT=57575 \ --p 57575:57575 \ --d garland/butterfly --port=57575 +docker run -d -p 57575:57575 garland/butterfly +``` + +Starting with a different port + +``` bash +docker run -d -p 12345:12345 garland/butterfly --port=12345 ```