From e079c479f5f02abca1f8e8e03c9b90206bff71c6 Mon Sep 17 00:00:00 2001 From: chabad360 Date: Fri, 5 Oct 2018 11:50:11 -0700 Subject: [PATCH 1/9] dockerfile: clean up (#52) * Condensed Dockerfile Updated to latest node, and uses python-pip, also condensed a lot the Dockerfile. * Removed extra line * Removed MAINTAINER in favor of LABEL * all installs are in one apt command --- Dockerfile | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0d9bd63e..eaf29640 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,42 +2,33 @@ #bench Dockerfile FROM ubuntu:16.04 -MAINTAINER frappé +LABEL MAINTAINER frappé USER root -RUN apt-get update -RUN apt-get install -y iputils-ping -RUN apt-get install -y git build-essential python-setuptools python-dev libffi-dev libssl-dev -RUN apt-get install -y redis-tools redis-server software-properties-common libxrender1 libxext6 xfonts-75dpi xfonts-base -RUN apt-get install -y libjpeg8-dev zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev python-tk apt-transport-https libsasl2-dev libldap2-dev libtiff5-dev tcl8.6-dev tk8.6-dev -RUN apt-get install -y wget -RUN wget https://bootstrap.pypa.io/get-pip.py && python get-pip.py -RUN pip install --upgrade setuptools pip RUN useradd -ms /bin/bash frappe -RUN apt-get install -y curl -RUN apt-get install -y rlwrap -RUN apt-get install redis-tools -RUN apt-get install -y nano +RUN apt-get update +RUN apt-get install -y iputils-ping git build-essential python-setuptools python-dev libffi-dev libssl-dev \ + redis-tools redis-server software-properties-common libxrender1 libxext6 xfonts-75dpi xfonts-base \ + libjpeg8-dev zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev python-tk apt-transport-https libsasl2-dev libldap2-dev libtiff5-dev \ + tcl8.6-dev tk8.6-dev wget libmysqlclient-dev mariadb-client mariadb-common curl rlwrap redis-tools nano wkhtmltopdf python-pip +RUN pip install --upgrade setuptools pip # Generate locale C.UTF-8 for mariadb and general locale data ENV LANG C.UTF-8 #nodejs -RUN apt-get install curl -RUN curl https://deb.nodesource.com/node_6.x/pool/main/n/nodejs/nodejs_6.7.0-1nodesource1~xenial1_amd64.deb > node.deb \ +RUN curl https://deb.nodesource.com/node_10.x/pool/main/n/nodejs/nodejs_10.10.0-1nodesource1_amd64.deb > node.deb \ && dpkg -i node.deb \ && rm node.deb -RUN apt-get install -y wkhtmltopdf USER frappe WORKDIR /home/frappe RUN git clone -b master https://github.com/frappe/bench.git bench-repo USER root -RUN pip install -e bench-repo -RUN apt-get install -y libmysqlclient-dev mariadb-client mariadb-common -RUN npm install -g yarn -RUN chown -R frappe:frappe /home/frappe/* - +RUN pip install -e bench-repo \ + && npm install -g yarn \ + && chown -R frappe:frappe /home/frappe/* + USER frappe WORKDIR /home/frappe/frappe-bench From 2b1334d5a56d8b21ef8983d7b813df618e32cd1b Mon Sep 17 00:00:00 2001 From: chabad360 Date: Fri, 12 Oct 2018 20:05:29 -0700 Subject: [PATCH 2/9] improvements to travis and dbench (#53) This PR adds the `bench` script, which aims for near parity with frappe bench, it makes setting up far easier, because instead of running `./dbench -c "new-site site1.local"` you only white what you would if bench was installed on the local system (i.e. `./bench new-site site1.local`), it also adds other features as well. --- .travis.yml | 15 ++++---- Dockerfile | 20 +++++------ README.md | 24 ++++++------- dbench | 101 +++++++++++++++++++++++++--------------------------- 4 files changed, 74 insertions(+), 86 deletions(-) diff --git a/.travis.yml b/.travis.yml index bf15e5f7..cda2ba5d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,20 +2,17 @@ language: python python: - "2.7" env: - - DOCKER_COMPOSE_VERSION: 1.8.0 + - DOCKER_COMPOSE_VERSION: 1.22.0 services: - docker install: - - docker-compose build - - docker-compose up -d - - docker exec -it -u root frappe bash -c "cd /home/frappe && chown -R frappe:frappe ./*" - - docker exec -i frappe bash -c "cd .. && bench init frappe-bench --ignore-exist --skip-redis-config-generation && cd frappe-bench" - - docker exec -i frappe bash -c "mv Procfile_docker Procfile && mv sites/common_site_config_docker.json sites/common_site_config.json" - - docker exec -i frappe bash -c "bench new-site site1.local" - - docker exec -i -u root frappe bash -c "echo 127.0.0.1 site1.local >> /etc/hosts" - - sudo su -c 'echo 127.0.0.1 site1.local >> /etc/hosts' + - chmod ugo+x ./dbench + - ./dbench setup docker + - ./dbench init frappe-bench + - ./dbench new-site site1.local + - sudo ./dbench setup hosts - pip install --upgrade virtualenv - virtualenv -p python3 testenv - source testenv/bin/activate diff --git a/Dockerfile b/Dockerfile index eaf29640..d653bc99 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,17 +5,16 @@ FROM ubuntu:16.04 LABEL MAINTAINER frappé USER root -RUN useradd -ms /bin/bash frappe -RUN apt-get update -RUN apt-get install -y iputils-ping git build-essential python-setuptools python-dev libffi-dev libssl-dev \ - redis-tools redis-server software-properties-common libxrender1 libxext6 xfonts-75dpi xfonts-base \ - libjpeg8-dev zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev python-tk apt-transport-https libsasl2-dev libldap2-dev libtiff5-dev \ - tcl8.6-dev tk8.6-dev wget libmysqlclient-dev mariadb-client mariadb-common curl rlwrap redis-tools nano wkhtmltopdf python-pip -RUN pip install --upgrade setuptools pip - # Generate locale C.UTF-8 for mariadb and general locale data ENV LANG C.UTF-8 +RUN apt-get update && apt-get install -y iputils-ping git build-essential python-setuptools python-dev libffi-dev libssl-dev libjpeg8-dev \ + redis-tools redis-server software-properties-common libxrender1 libxext6 xfonts-75dpi xfonts-base zlib1g-dev libfreetype6-dev \ + liblcms2-dev libwebp-dev python-tk apt-transport-https libsasl2-dev libldap2-dev libtiff5-dev tcl8.6-dev tk8.6-dev \ + wget libmysqlclient-dev mariadb-client mariadb-common curl rlwrap redis-tools nano wkhtmltopdf python-pip vim sudo +RUN pip install --upgrade setuptools pip +RUN useradd -ms /bin/bash -G sudo frappe && printf '# User rules for frappe\nfrappe ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers.d/frappe + #nodejs RUN curl https://deb.nodesource.com/node_10.x/pool/main/n/nodejs/nodejs_10.10.0-1nodesource1_amd64.deb > node.deb \ && dpkg -i node.deb \ @@ -28,7 +27,8 @@ RUN git clone -b master https://github.com/frappe/bench.git bench-repo USER root RUN pip install -e bench-repo \ && npm install -g yarn \ - && chown -R frappe:frappe /home/frappe/* - + && chown -R frappe:frappe /home/frappe/* \ + && rm -rf /var/lib/apt/lists/* + USER frappe WORKDIR /home/frappe/frappe-bench diff --git a/README.md b/README.md index 6308622c..a3d01a7e 100644 --- a/README.md +++ b/README.md @@ -84,7 +84,7 @@ Express dependency between services, which has two effects: #### 2. Build the container and install bench * Clone this repo and change your working directory to frappe_docker - + git clone --depth 1 https://github.com/frappe/frappe_docker.git cd frappe_docker @@ -94,7 +94,7 @@ Express dependency between services, which has two effects: It creates a user, frappe inside the frappe container, whose working directory is /home/frappe. It also clones the bench-repo from [here](https://github.com/frappe/bench) - docker-compose up -d + ./dbench setup docker Note: Please do not remove the bench-repo directory the above commands will create @@ -102,29 +102,25 @@ Express dependency between services, which has two effects: #### Basic Usage ##### Make sure your current directory is frappe_docker -1. First time setup - +1. First time setup + ./dbench init -2. Command to start all the containers +2. Command to be executed everytime after starting your containers - docker-compose start + ./dbench setup hosts -3. Command to be executed everytime after starting your containers +3. Command to enter your container - ./dbench -s + ./dbench -4. Command to enter your container - - docker exec -it frappe bash - -5. All bench commands can also be directly run from the host machine by using dbench. For instance ```bench start``` can be executed by running ```./dbench -c start```. Just preface the option with ./dbench -c. For more information on dbench run the command ```./dbench -h```. +4. All bench commands can also be directly run from the host machine by using dbench. For instance ```bench start``` can be executed by running ```./dbench start```. Just preface the option with **`./dbench`**. For more information on dbench run the command ```./dbench -h```. For more info on how to build this docker container refer to this [Wiki](https://github.com/frappe/frappe_docker/wiki/Hitchhiker's-guide-to-building-this-frappe_docker-image) To login to Frappe / ERPNext, open your browser and go to `[your-external-ip]:8000`, probably `localhost:8000` -The default username is "Administrator" and password is what you set when you created the new site. The default admin password is set in common_site_config.json, and is set to 'admin' in this docker image. +The default username is "Administrator" and password is what you set when you created the new site. The default admin password is set in common_site_config.json, and is set to 'admin' in this docker image. ## Built With diff --git a/dbench b/dbench index fe835bf5..76da4e19 100755 --- a/dbench +++ b/dbench @@ -1,57 +1,52 @@ #!/bin/bash -display_usage() { - echo "$(basename "$0") [-h] [-c \"\"]" - echo '' - echo 'where:' - echo ' -h show this help text' - echo ' -c execute a command inside docker using docker exec' - echo ' -s adds site-names to /etc/hosts file in the container to facilitate multisite access' - echo ' init initializes frappe-bench adds a new-site bench-manager.local and installs the bench_manager app - app onto it' -} - if [[ $# -eq 0 ]]; then - docker exec -it frappe bash - -elif [ $1 == 'init' ] -then - docker exec -i -u root frappe bash -c "cd /home/frappe && chown -R frappe:frappe ./*" - docker exec -it frappe bash -c "cd .. && bench init frappe-bench --ignore-exist --skip-redis-config-generation && cd frappe-bench" - docker exec -it frappe bash -c "mv Procfile_docker Procfile && mv sites/common_site_config_docker.json sites/common_site_config.json" - docker exec -it -u root frappe bash -c "apt-get install -y vim sudo && usermod -aG sudo frappe && printf '# User rules for frappe\nfrappe ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers.d/frappe" - docker exec -it frappe bash -c "bench set-mariadb-host mariadb" - docker exec -it frappe bash -c "bench new-site site1.local" - docker exec -it frappe bash -c "bench get-app erpnext" - docker exec -it frappe bash -c "bench --site site1.local install-app erpnext" - + docker exec -it frappe bash +elif [ "$1" == 'init' ]; then + docker exec -itu root frappe bash -c "cd /home/frappe && chown -R frappe:frappe ./*" + docker exec -i frappe bash -c "cd .. && bench init $2 --ignore-exist --skip-redis-config-generation" + docker exec -i frappe bash -c "mv Procfile_docker Procfile && mv sites/common_site_config_docker.json sites/common_site_config.json && bench set-mariadb-host mariadb" +elif [ "$1" == 'setup' ]; then + if [ "$2" == 'docker' ]; then + if [ "$3" == '--swarm-mode' ]; then + echo "Docker swarm mode is not currently supported" + else + docker-compose up -d + fi + elif [ "$2" == 'hosts' ]; then + a=$(cd frappe-bench && ls sites/*/site_config.json | grep -o '/.\+/') + a="${a//$'\n'/ }" + a=$(echo $a | tr -d / ) + result="127.0.0.1 ${a}" + echo $result | sudo tee -a /etc/hosts + docker exec -iu root frappe bash -c "echo ${result} | tee --append /etc/hosts" + docker exec -itu root frappe bash -c "printf '# User rules for frappe\nfrappe ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers.d/frappe" + fi +elif [ "$1" == '-c' ]; then + shift + user=$1 + shift + docker exec -iu "$user" frappe bash -c "$@" +elif [ "$1" == '-h' ]; then + echo "$0 [-h] | [ -c frappe | root ] [ ]" + echo "" + echo "$0 extends the Frappe Bench tool, and is used like it. However, it extends the tool in a few places." + echo "Usage:" + echo " $0" + echo " Launches you into an interactive shell in the container as user frappe" + echo " $0 init bench-folder-name" + echo " Runs \"bench init\" along with some other commands" + echo " $0 setup docker" + echo " Starts and builds the docker containers using \"docker-compose up -d\"" + echo " $0 setup hosts" + echo " Adds all sites to the hosts file, run with sudo" + echo " $0 -c frappe | root " + echo " Runs a command in the container, as the selected user" + echo " $0 -h" + echo " Shows this help message" + echo " $0 " + echo " Runs a command in bench, i.e. $0 new-site site1.local = bench new-site site1.local" else - while getopts ':hsc:' option; do - case "$option" in - h) - display_usage - exit - ;; - c) - docker exec -it frappe bash -c "bench $OPTARG" - ;; - s) - a=$(cd frappe-bench && ls sites/*/site_config.json | grep -o '/.\+/') - a="${a//$'\n'/ }" - a=$(echo $a | tr -d / ) - result="127.0.0.1 ${a}" - echo $result - docker exec -u root -i frappe bash -c "echo ${result} | tee --append /etc/hosts" - docker exec -itu root frappe bash -c "printf '# User rules for frappe\nfrappe ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers.d/frappe" - ;; - \?) - echo "Invalid option: -$OPTARG" >&2 - exit 1 - ;; - :) - echo "Option -$OPTARG requires an argument." >&2 - exit 1 - ;; - esac - done -fi + IFS=" " + docker exec -it frappe bash -c "bench $*" +fi \ No newline at end of file From 6fc3bfbdcf7fed0f92b46345f4075215885d7ad7 Mon Sep 17 00:00:00 2001 From: Chinmay Pai Date: Sat, 13 Oct 2018 17:20:04 +0000 Subject: [PATCH 3/9] dbench: fix init issues (#55) ./dbench init would lead to 'missing argument: PATH' issue (#54), and could not find Procfile_docker and site-config. Signed-off-by: Chinmay Pai --- dbench | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dbench b/dbench index 76da4e19..446064fb 100755 --- a/dbench +++ b/dbench @@ -4,7 +4,7 @@ if [[ $# -eq 0 ]]; then docker exec -it frappe bash elif [ "$1" == 'init' ]; then docker exec -itu root frappe bash -c "cd /home/frappe && chown -R frappe:frappe ./*" - docker exec -i frappe bash -c "cd .. && bench init $2 --ignore-exist --skip-redis-config-generation" + docker exec -i frappe bash -c "cd .. && bench init frappe-bench --ignore-exist --skip-redis-config-generation && cd frappe-bench" docker exec -i frappe bash -c "mv Procfile_docker Procfile && mv sites/common_site_config_docker.json sites/common_site_config.json && bench set-mariadb-host mariadb" elif [ "$1" == 'setup' ]; then if [ "$2" == 'docker' ]; then @@ -49,4 +49,4 @@ elif [ "$1" == '-h' ]; then else IFS=" " docker exec -it frappe bash -c "bench $*" -fi \ No newline at end of file +fi From c79ac28179cd541177e3eeb2b55c4c140988c707 Mon Sep 17 00:00:00 2001 From: chabad360 Date: Fri, 19 Oct 2018 18:51:12 +0000 Subject: [PATCH 4/9] bench setup anything-else should work now --- dbench | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/dbench b/dbench index 446064fb..0eb66e5c 100755 --- a/dbench +++ b/dbench @@ -6,14 +6,13 @@ elif [ "$1" == 'init' ]; then docker exec -itu root frappe bash -c "cd /home/frappe && chown -R frappe:frappe ./*" docker exec -i frappe bash -c "cd .. && bench init frappe-bench --ignore-exist --skip-redis-config-generation && cd frappe-bench" docker exec -i frappe bash -c "mv Procfile_docker Procfile && mv sites/common_site_config_docker.json sites/common_site_config.json && bench set-mariadb-host mariadb" -elif [ "$1" == 'setup' ]; then - if [ "$2" == 'docker' ]; then +elif [ "$1" == 'setup' ] && [ "$2" == 'docker' ]; then if [ "$3" == '--swarm-mode' ]; then echo "Docker swarm mode is not currently supported" else docker-compose up -d fi - elif [ "$2" == 'hosts' ]; then +elif [ "$1" == 'setup' ] && [ "$2" == 'hosts' ]; then a=$(cd frappe-bench && ls sites/*/site_config.json | grep -o '/.\+/') a="${a//$'\n'/ }" a=$(echo $a | tr -d / ) @@ -21,7 +20,6 @@ elif [ "$1" == 'setup' ]; then echo $result | sudo tee -a /etc/hosts docker exec -iu root frappe bash -c "echo ${result} | tee --append /etc/hosts" docker exec -itu root frappe bash -c "printf '# User rules for frappe\nfrappe ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers.d/frappe" - fi elif [ "$1" == '-c' ]; then shift user=$1 From 86d138e8e3a54e68242a4a1f9b0a8fd7f3419b44 Mon Sep 17 00:00:00 2001 From: chabad360 Date: Sat, 20 Oct 2018 00:54:21 -0400 Subject: [PATCH 5/9] bench setup anything-else should work now (#56) --- dbench | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/dbench b/dbench index 446064fb..0eb66e5c 100755 --- a/dbench +++ b/dbench @@ -6,14 +6,13 @@ elif [ "$1" == 'init' ]; then docker exec -itu root frappe bash -c "cd /home/frappe && chown -R frappe:frappe ./*" docker exec -i frappe bash -c "cd .. && bench init frappe-bench --ignore-exist --skip-redis-config-generation && cd frappe-bench" docker exec -i frappe bash -c "mv Procfile_docker Procfile && mv sites/common_site_config_docker.json sites/common_site_config.json && bench set-mariadb-host mariadb" -elif [ "$1" == 'setup' ]; then - if [ "$2" == 'docker' ]; then +elif [ "$1" == 'setup' ] && [ "$2" == 'docker' ]; then if [ "$3" == '--swarm-mode' ]; then echo "Docker swarm mode is not currently supported" else docker-compose up -d fi - elif [ "$2" == 'hosts' ]; then +elif [ "$1" == 'setup' ] && [ "$2" == 'hosts' ]; then a=$(cd frappe-bench && ls sites/*/site_config.json | grep -o '/.\+/') a="${a//$'\n'/ }" a=$(echo $a | tr -d / ) @@ -21,7 +20,6 @@ elif [ "$1" == 'setup' ]; then echo $result | sudo tee -a /etc/hosts docker exec -iu root frappe bash -c "echo ${result} | tee --append /etc/hosts" docker exec -itu root frappe bash -c "printf '# User rules for frappe\nfrappe ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers.d/frappe" - fi elif [ "$1" == '-c' ]; then shift user=$1 From 687ef7cecc4faaed13c02c4bf6644e4bbd6139b6 Mon Sep 17 00:00:00 2001 From: William Moreno Date: Mon, 22 Oct 2018 01:11:59 -0600 Subject: [PATCH 6/9] Clean cache to get a smaller image (#57) Please include this commit to decrease the size of the docker image, the "rm -rf /var/lib/apt/lists/*" it is not usefull if it is not used in the same stage of the apt-get install RUN, similar with pip cache. References: - https://linux.die.net/man/8/apt-get - https://stackoverflow.com/questions/9510474/removing-pips-cache - https://semaphoreci.com/blog/2016/12/13/lightweight-docker-images-in-5-steps.html By making a contribution to this project, I certify that: (a) The contribution was created in whole or in part by me and I have the right to submit it under the open source license indicated in the file; (b) I understand and agree that this project and the contribution are public and that a record of the contribution (including all personal information I submit with it, including my sign-off) is maintained indefinitely and may be redistributed consistent with this project or the open source license(s) involved. Signed-off-by: William Moreno Reyes --- Dockerfile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index d653bc99..f37a1eb0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,8 +11,9 @@ ENV LANG C.UTF-8 RUN apt-get update && apt-get install -y iputils-ping git build-essential python-setuptools python-dev libffi-dev libssl-dev libjpeg8-dev \ redis-tools redis-server software-properties-common libxrender1 libxext6 xfonts-75dpi xfonts-base zlib1g-dev libfreetype6-dev \ liblcms2-dev libwebp-dev python-tk apt-transport-https libsasl2-dev libldap2-dev libtiff5-dev tcl8.6-dev tk8.6-dev \ - wget libmysqlclient-dev mariadb-client mariadb-common curl rlwrap redis-tools nano wkhtmltopdf python-pip vim sudo -RUN pip install --upgrade setuptools pip + wget libmysqlclient-dev mariadb-client mariadb-common curl rlwrap redis-tools nano wkhtmltopdf python-pip vim sudo && apt-get clean \ + && rm -rf /var/lib/apt/lists/* +RUN pip install --upgrade setuptools pip && rm -rf ~/.cache/pip RUN useradd -ms /bin/bash -G sudo frappe && printf '# User rules for frappe\nfrappe ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers.d/frappe #nodejs @@ -25,10 +26,9 @@ WORKDIR /home/frappe RUN git clone -b master https://github.com/frappe/bench.git bench-repo USER root -RUN pip install -e bench-repo \ +RUN pip install -e bench-repo && rm -rf ~/.cache/pip \ && npm install -g yarn \ - && chown -R frappe:frappe /home/frappe/* \ - && rm -rf /var/lib/apt/lists/* + && chown -R frappe:frappe /home/frappe/* USER frappe WORKDIR /home/frappe/frappe-bench From ea70e8669bd9588a3ee3bcbb873f984e4cc1b015 Mon Sep 17 00:00:00 2001 From: Mendel Greenberg Date: Fri, 18 Jan 2019 07:45:44 -0500 Subject: [PATCH 7/9] removed adding site names to host (its pointless) --- Dockerfile | 1 + dbench | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index f37a1eb0..3eca918a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,6 +29,7 @@ USER root RUN pip install -e bench-repo && rm -rf ~/.cache/pip \ && npm install -g yarn \ && chown -R frappe:frappe /home/frappe/* +RUN printf '# User rules for frappe\nfrappe ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers.d/frappe USER frappe WORKDIR /home/frappe/frappe-bench diff --git a/dbench b/dbench index 0eb66e5c..aaaae858 100755 --- a/dbench +++ b/dbench @@ -17,9 +17,7 @@ elif [ "$1" == 'setup' ] && [ "$2" == 'hosts' ]; then a="${a//$'\n'/ }" a=$(echo $a | tr -d / ) result="127.0.0.1 ${a}" - echo $result | sudo tee -a /etc/hosts docker exec -iu root frappe bash -c "echo ${result} | tee --append /etc/hosts" - docker exec -itu root frappe bash -c "printf '# User rules for frappe\nfrappe ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers.d/frappe" elif [ "$1" == '-c' ]; then shift user=$1 From 574349d16c952feb9a390fa5557794a9814150ef Mon Sep 17 00:00:00 2001 From: Mendel Greenberg Date: Fri, 18 Jan 2019 15:53:53 -0500 Subject: [PATCH 8/9] moved redis configuration folder into conf/ --- .../redis-conf}/pids/redis_cache.pid | 0 .../redis-conf}/pids/redis_queue.pid | 0 .../redis-conf}/pids/redis_socketio.pid | 0 .../redis-conf}/redis_cache.conf | 0 .../redis-conf}/redis_queue.conf | 0 .../redis-conf}/redis_socketio.conf | 0 docker-compose.yml | 18 +++++++++++------- 7 files changed, 11 insertions(+), 7 deletions(-) rename {redis-conf => conf/redis-conf}/pids/redis_cache.pid (100%) rename {redis-conf => conf/redis-conf}/pids/redis_queue.pid (100%) rename {redis-conf => conf/redis-conf}/pids/redis_socketio.pid (100%) rename {redis-conf => conf/redis-conf}/redis_cache.conf (100%) rename {redis-conf => conf/redis-conf}/redis_queue.conf (100%) rename {redis-conf => conf/redis-conf}/redis_socketio.conf (100%) diff --git a/redis-conf/pids/redis_cache.pid b/conf/redis-conf/pids/redis_cache.pid similarity index 100% rename from redis-conf/pids/redis_cache.pid rename to conf/redis-conf/pids/redis_cache.pid diff --git a/redis-conf/pids/redis_queue.pid b/conf/redis-conf/pids/redis_queue.pid similarity index 100% rename from redis-conf/pids/redis_queue.pid rename to conf/redis-conf/pids/redis_queue.pid diff --git a/redis-conf/pids/redis_socketio.pid b/conf/redis-conf/pids/redis_socketio.pid similarity index 100% rename from redis-conf/pids/redis_socketio.pid rename to conf/redis-conf/pids/redis_socketio.pid diff --git a/redis-conf/redis_cache.conf b/conf/redis-conf/redis_cache.conf similarity index 100% rename from redis-conf/redis_cache.conf rename to conf/redis-conf/redis_cache.conf diff --git a/redis-conf/redis_queue.conf b/conf/redis-conf/redis_queue.conf similarity index 100% rename from redis-conf/redis_queue.conf rename to conf/redis-conf/redis_queue.conf diff --git a/redis-conf/redis_socketio.conf b/conf/redis-conf/redis_socketio.conf similarity index 100% rename from redis-conf/redis_socketio.conf rename to conf/redis-conf/redis_socketio.conf diff --git a/docker-compose.yml b/docker-compose.yml index 42abf6bb..92286cde 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,22 +1,26 @@ -version: '2' +version: '3.3' services: mariadb: image: mariadb + environment: - MYSQL_ROOT_PASSWORD=123 - MYSQL_USER=root + volumes: - ./conf/mariadb-conf.d:/etc/mysql/conf.d - /var/lib/mysql + ports: - "3307:3306" #mariadb-port + container_name: mariadb redis-cache: image: redis:alpine volumes: - - ./redis-conf:/etc/conf.d + - ./conf/redis-conf:/etc/conf.d command: ["redis-server","/etc/conf.d/redis_cache.conf"] @@ -26,7 +30,7 @@ services: image: redis:alpine volumes: - - ./redis-conf:/etc/conf.d + - ./conf/redis-conf:/etc/conf.d command: ["redis-server","/etc/conf.d/redis_queue.conf"] @@ -36,7 +40,7 @@ services: image: redis:alpine volumes: - - ./redis-conf:/etc/conf.d + - ./conf/redis-conf:/etc/conf.d command: ["redis-server","/etc/conf.d/redis_socketio.conf"] @@ -46,9 +50,9 @@ services: frappe: volumes: - ./frappe-bench:/home/frappe/frappe-bench - - ./redis-conf/redis_cache.conf:/home/frappe/frappe-bench/config/redis_cache.conf - - ./redis-conf/redis_queue.conf:/home/frappe/frappe-bench/config/redis_queue.conf - - ./redis-conf/redis_socketio.conf:/home/frappe/frappe-bench/config/redis_socketio.conf + - ./conf/redis-conf/redis_cache.conf:/home/frappe/frappe-bench/config/redis_cache.conf + - ./conf/redis-conf/redis_queue.conf:/home/frappe/frappe-bench/config/redis_queue.conf + - ./conf/redis-conf/redis_socketio.conf:/home/frappe/frappe-bench/config/redis_socketio.conf build: . ports: - "8000:8000" #webserver_port From da76847b939a7e7ab60e06f5fe67a9cbcecff12e Mon Sep 17 00:00:00 2001 From: Mendel Greenberg Date: Fri, 18 Jan 2019 16:07:18 -0500 Subject: [PATCH 9/9] added a docker down feature to dbench and changed some of the docs --- .travis.yml | 2 +- Dockerfile | 1 - dbench | 12 ++++++++---- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index cda2ba5d..9bbe3de6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,7 @@ install: - ./dbench setup docker - ./dbench init frappe-bench - ./dbench new-site site1.local - - sudo ./dbench setup hosts + - ./dbench setup hosts - pip install --upgrade virtualenv - virtualenv -p python3 testenv - source testenv/bin/activate diff --git a/Dockerfile b/Dockerfile index 3eca918a..f37a1eb0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,7 +29,6 @@ USER root RUN pip install -e bench-repo && rm -rf ~/.cache/pip \ && npm install -g yarn \ && chown -R frappe:frappe /home/frappe/* -RUN printf '# User rules for frappe\nfrappe ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers.d/frappe USER frappe WORKDIR /home/frappe/frappe-bench diff --git a/dbench b/dbench index aaaae858..bb283dca 100755 --- a/dbench +++ b/dbench @@ -9,6 +9,10 @@ elif [ "$1" == 'init' ]; then elif [ "$1" == 'setup' ] && [ "$2" == 'docker' ]; then if [ "$3" == '--swarm-mode' ]; then echo "Docker swarm mode is not currently supported" + elif [ "$3" == 'down' ]; then + docker-compose down + elif [ "$3" == 'stop' ]; then + docker-compose stop else docker-compose up -d fi @@ -22,7 +26,7 @@ elif [ "$1" == '-c' ]; then shift user=$1 shift - docker exec -iu "$user" frappe bash -c "$@" + docker exec -iu $user frappe bash -c "$@" elif [ "$1" == '-h' ]; then echo "$0 [-h] | [ -c frappe | root ] [ ]" echo "" @@ -30,12 +34,12 @@ elif [ "$1" == '-h' ]; then echo "Usage:" echo " $0" echo " Launches you into an interactive shell in the container as user frappe" - echo " $0 init bench-folder-name" + echo " $0 init [ bench-folder-name ]" echo " Runs \"bench init\" along with some other commands" - echo " $0 setup docker" + echo " $0 setup docker [ stop | down ]" echo " Starts and builds the docker containers using \"docker-compose up -d\"" echo " $0 setup hosts" - echo " Adds all sites to the hosts file, run with sudo" + echo " Adds all sites to the containers hosts file" echo " $0 -c frappe | root " echo " Runs a command in the container, as the selected user" echo " $0 -h"