From d73397165f0887fc100c007db2b2d70b06c4bb7c Mon Sep 17 00:00:00 2001 From: chabad360 Date: Fri, 5 Oct 2018 04:12:53 +0000 Subject: [PATCH 01/38] testing replacement for dbench --- .travis.yml | 9 +++------ bench | 12 ++++++++++++ 2 files changed, 15 insertions(+), 6 deletions(-) create mode 100644 bench diff --git a/.travis.yml b/.travis.yml index bf15e5f7..88fd07c7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,13 +8,10 @@ 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" + - ./bench init frappe-bench + - ./bench new-site site1.local + - ./bench -c "echo 127.0.0.1 site1.local >> /etc/hosts" - sudo su -c 'echo 127.0.0.1 site1.local >> /etc/hosts' - pip install --upgrade virtualenv - virtualenv -p python3 testenv diff --git a/bench b/bench new file mode 100644 index 00000000..9df8ab9f --- /dev/null +++ b/bench @@ -0,0 +1,12 @@ +#!/bin/bash + +if [ "$1" == 'init' ]; then + docker exec -it frappe bash -c "bench init frappe-bench --ignore-exist --skip-redis-config-generation && mv Procfile_docker Procfile && mv sites/common_site_config_docker.json sites/common_site_config.json && bench set-mariadb-host mariadb" +elif [[ $# -eq 0 ]]; then + docker exec -it frappe bash +elif [ "$1" == '-c' ]; then + shift + docker exec -it root frappe bash -c "$@" +else + docker exec -it frappe bash -c "bench $@" +fi \ No newline at end of file From 19021a820b5a8553382958cad7df27e2b50e2d07 Mon Sep 17 00:00:00 2001 From: chabad360 Date: Fri, 5 Oct 2018 04:23:19 +0000 Subject: [PATCH 02/38] fixed perm issue and added docker control --- bench | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/bench b/bench index 9df8ab9f..a78d7614 100644 --- a/bench +++ b/bench @@ -1,12 +1,19 @@ #!/bin/bash if [ "$1" == 'init' ]; then + docker exec -it root frappe bash -c "cd /home/frappe && chown -R frappe:frappe ./*" docker exec -it frappe bash -c "bench init frappe-bench --ignore-exist --skip-redis-config-generation && mv Procfile_docker Procfile && mv sites/common_site_config_docker.json sites/common_site_config.json && bench set-mariadb-host mariadb" -elif [[ $# -eq 0 ]]; then - docker exec -it frappe bash +elif [ "$1" == 'setup' && "$2" == 'docker' ]; then + if [ "$3" == 'swarm' ]; then + echo "Docker swarm mode is not currently supported" + else + docker-compose up -d + fi elif [ "$1" == '-c' ]; then shift docker exec -it root frappe bash -c "$@" +elif [[ $# -eq 0 ]]; then + docker exec -it frappe bash else docker exec -it frappe bash -c "bench $@" fi \ No newline at end of file From 93cd0d6ac7bf10222a24d2a5d20e08a801e6c97c Mon Sep 17 00:00:00 2001 From: chabad360 Date: Fri, 5 Oct 2018 04:30:13 +0000 Subject: [PATCH 03/38] fixes and tests fixed travis test, and perm issue --- .travis.yml | 5 +++-- bench | 38 ++++++++++++++++++++------------------ 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/.travis.yml b/.travis.yml index 88fd07c7..5f746e38 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,10 +8,11 @@ services: - docker install: - - docker-compose up -d + - chmod ugo+x ./bench + - ./bench setup docker - ./bench init frappe-bench - ./bench new-site site1.local - - ./bench -c "echo 127.0.0.1 site1.local >> /etc/hosts" + - ./bench -c root "echo 127.0.0.1 site1.local >> /etc/hosts" - sudo su -c 'echo 127.0.0.1 site1.local >> /etc/hosts' - pip install --upgrade virtualenv - virtualenv -p python3 testenv diff --git a/bench b/bench index a78d7614..1681ff64 100644 --- a/bench +++ b/bench @@ -1,19 +1,21 @@ -#!/bin/bash - -if [ "$1" == 'init' ]; then - docker exec -it root frappe bash -c "cd /home/frappe && chown -R frappe:frappe ./*" - docker exec -it frappe bash -c "bench init frappe-bench --ignore-exist --skip-redis-config-generation && mv Procfile_docker Procfile && mv sites/common_site_config_docker.json sites/common_site_config.json && bench set-mariadb-host mariadb" -elif [ "$1" == 'setup' && "$2" == 'docker' ]; then - if [ "$3" == 'swarm' ]; then - echo "Docker swarm mode is not currently supported" - else - docker-compose up -d - fi -elif [ "$1" == '-c' ]; then - shift - docker exec -it root frappe bash -c "$@" -elif [[ $# -eq 0 ]]; then - docker exec -it frappe bash -else - docker exec -it frappe bash -c "bench $@" +#!/bin/bash + +if [[ $# -eq 0 ]]; then + docker exec -it frappe bash +elif [ "$1" == 'init' ]; then + docker exec -it root frappe bash -c "cd /home/frappe && chown -R frappe:frappe ./*" + docker exec -it frappe bash -c "bench init frappe-bench --ignore-exist --skip-redis-config-generation && mv Procfile_docker Procfile && mv sites/common_site_config_docker.json sites/common_site_config.json && bench set-mariadb-host mariadb" +elif [ "$1" == 'setup' ] && [ "$2" == 'docker' ]; then + if [ "$3" == 'swarm' ]; then + echo "Docker swarm mode is not currently supported" + else + docker-compose up -d + fi +elif [ "$1" == '-c' ]; then + shift + user=$1 + shift + docker exec -it -u "$user" frappe bash -c "$@" +else + docker exec -it frappe bash -c bench "$@" fi \ No newline at end of file From 81cb5f3e9d8872a577d62c770ae19249cf3b89dd Mon Sep 17 00:00:00 2001 From: chabad360 Date: Fri, 5 Oct 2018 05:00:14 +0000 Subject: [PATCH 04/38] auto add permissions --- bench | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 bench diff --git a/bench b/bench old mode 100644 new mode 100755 From 309f6810b4cb03c9d1a522ffe7fb23dd2dc808e1 Mon Sep 17 00:00:00 2001 From: chabad360 Date: Fri, 5 Oct 2018 05:10:22 +0000 Subject: [PATCH 05/38] hopefully should fix the args issue --- bench | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/bench b/bench index 1681ff64..b0184fc5 100755 --- a/bench +++ b/bench @@ -3,10 +3,11 @@ if [[ $# -eq 0 ]]; then docker exec -it frappe bash elif [ "$1" == 'init' ]; then - docker exec -it root frappe bash -c "cd /home/frappe && chown -R frappe:frappe ./*" - docker exec -it frappe bash -c "bench init frappe-bench --ignore-exist --skip-redis-config-generation && mv Procfile_docker Procfile && mv sites/common_site_config_docker.json sites/common_site_config.json && bench set-mariadb-host mariadb" + 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" + 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' ] && [ "$2" == 'docker' ]; then - if [ "$3" == 'swarm' ]; then + if [ "$3" == '--swarm-mode' ]; then echo "Docker swarm mode is not currently supported" else docker-compose up -d @@ -15,7 +16,8 @@ elif [ "$1" == '-c' ]; then shift user=$1 shift - docker exec -it -u "$user" frappe bash -c "$@" + docker exec -i -u "$user" frappe bash -c "$@" else - docker exec -it frappe bash -c bench "$@" + IFS=" " + docker exec -i frappe bash -c "bench $*" fi \ No newline at end of file From 7cc8bc0820fcbdf6d70e8997e46e1d96544c50fc Mon Sep 17 00:00:00 2001 From: chabad360 Date: Thu, 4 Oct 2018 18:59:18 -0700 Subject: [PATCH 06/38] Condensed Dockerfile Updated to latest node, and uses python-pip, also condensed a lot the Dockerfile. --- Dockerfile | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0d9bd63e..7c44696b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,39 +5,31 @@ FROM ubuntu:16.04 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 \ + && apt-get install -y redis-tools redis-server software-properties-common libxrender1 libxext6 xfonts-75dpi xfonts-base \ + && 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 wget \ + && apt-get install -y 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 +WORKDIR /home/frappe/frappe-bench From b04151ec0019799a7954b385abe465bbad4112ac Mon Sep 17 00:00:00 2001 From: chabad360 Date: Thu, 4 Oct 2018 18:59:57 -0700 Subject: [PATCH 07/38] Removed extra line --- Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 7c44696b..c6718b25 100644 --- a/Dockerfile +++ b/Dockerfile @@ -32,4 +32,3 @@ RUN pip install -e bench-repo \ USER frappe WORKDIR /home/frappe/frappe-bench -WORKDIR /home/frappe/frappe-bench From 35ca60899cf74a9529257dfcabcc2194fce69145 Mon Sep 17 00:00:00 2001 From: chabad360 Date: Fri, 5 Oct 2018 02:55:43 +0000 Subject: [PATCH 08/38] Removed MAINTAINER in favor of LABEL --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index c6718b25..965df7a0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ #bench Dockerfile FROM ubuntu:16.04 -MAINTAINER frappé +LABEL MAINTAINER frappé USER root RUN useradd -ms /bin/bash frappe From ed7ba75cd02db2b359143fd566556c14a7c4737b Mon Sep 17 00:00:00 2001 From: chabad360 Date: Fri, 5 Oct 2018 11:45:06 -0700 Subject: [PATCH 09/38] all installs are in one apt command --- Dockerfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 965df7a0..eaf29640 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,9 +8,9 @@ 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 \ - && apt-get install -y redis-tools redis-server software-properties-common libxrender1 libxext6 xfonts-75dpi xfonts-base \ - && 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 wget \ - && apt-get install -y libmysqlclient-dev mariadb-client mariadb-common curl rlwrap redis-tools nano wkhtmltopdf python-pip + 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 @@ -29,6 +29,6 @@ USER root RUN pip install -e bench-repo \ && npm install -g yarn \ && chown -R frappe:frappe /home/frappe/* - + USER frappe WORKDIR /home/frappe/frappe-bench From aeb741a4a3332b82f90225cb87dd9b12d6d1a443 Mon Sep 17 00:00:00 2001 From: chabad360 Date: Fri, 5 Oct 2018 19:31:09 +0000 Subject: [PATCH 10/38] Switch bench to dbench, added -s feature of dbench to bench. updated Docker file with sudo and vim, and setup travis to run with said changes --- .travis.yml | 5 ++-- Dockerfile | 12 ++++---- bench | 23 --------------- dbench | 83 +++++++++++++++++++---------------------------------- 4 files changed, 38 insertions(+), 85 deletions(-) delete mode 100755 bench diff --git a/.travis.yml b/.travis.yml index 5f746e38..1623cef8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,7 @@ language: python python: - "2.7" env: - - DOCKER_COMPOSE_VERSION: 1.8.0 + - DOCKER_COMPOSE_VERSION: 1.22.0 services: - docker @@ -12,8 +12,7 @@ install: - ./bench setup docker - ./bench init frappe-bench - ./bench new-site site1.local - - ./bench -c root "echo 127.0.0.1 site1.local >> /etc/hosts" - - sudo su -c 'echo 127.0.0.1 site1.local >> /etc/hosts' + - ./bench setup hosts' - pip install --upgrade virtualenv - virtualenv -p python3 testenv - source testenv/bin/activate diff --git a/Dockerfile b/Dockerfile index eaf29640..2dfdf5f9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,13 +5,13 @@ 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 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 # Generate locale C.UTF-8 for mariadb and general locale data ENV LANG C.UTF-8 @@ -29,6 +29,6 @@ USER root RUN pip install -e bench-repo \ && npm install -g yarn \ && chown -R frappe:frappe /home/frappe/* - + USER frappe WORKDIR /home/frappe/frappe-bench diff --git a/bench b/bench deleted file mode 100755 index b0184fc5..00000000 --- a/bench +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash - -if [[ $# -eq 0 ]]; then - docker exec -it frappe bash -elif [ "$1" == 'init' ]; then - 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" - 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' ] && [ "$2" == 'docker' ]; then - if [ "$3" == '--swarm-mode' ]; then - echo "Docker swarm mode is not currently supported" - else - docker-compose up -d - fi -elif [ "$1" == '-c' ]; then - shift - user=$1 - shift - docker exec -i -u "$user" frappe bash -c "$@" -else - IFS=" " - docker exec -i frappe bash -c "bench $*" -fi \ No newline at end of file diff --git a/dbench b/dbench index fe835bf5..2433cc73 100755 --- a/dbench +++ b/dbench @@ -1,57 +1,34 @@ + #!/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 -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" + 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}" + sudo echo $result >> /etc/hosts + 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" + fi +elif [ "$1" == '-c' ]; then + shift + user=$1 + shift + docker exec -i -u "$user" frappe bash -c "$@" 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 -i frappe bash -c "bench $*" +fi \ No newline at end of file From 05fda942201f8be3a97d58b94b12f38d5c907687 Mon Sep 17 00:00:00 2001 From: chabad360 Date: Fri, 5 Oct 2018 11:50:11 -0700 Subject: [PATCH 11/38] dockerfile: clean up (#52) * Condensed Dockerfile Updated to latest node, and uses python-pip, also condensed a lot the Dockerfile. --- Dockerfile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2dfdf5f9..eaf29640 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,13 +5,13 @@ 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 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 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 -RUN useradd -ms /bin/bash -G sudo frappe && printf '# User rules for frappe\nfrappe ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers.d/frappe # Generate locale C.UTF-8 for mariadb and general locale data ENV LANG C.UTF-8 @@ -29,6 +29,6 @@ USER root RUN pip install -e bench-repo \ && npm install -g yarn \ && chown -R frappe:frappe /home/frappe/* - + USER frappe WORKDIR /home/frappe/frappe-bench From f7f108f8f88244f3751b01a14037c34e4f65611b Mon Sep 17 00:00:00 2001 From: chabad360 Date: Fri, 5 Oct 2018 19:57:59 +0000 Subject: [PATCH 12/38] fixed travis, and cleaned up dbench a little --- .travis.yml | 10 +++++----- Dockerfile | 6 +++--- dbench | 9 ++++----- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1623cef8..7997266a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,11 +8,11 @@ services: - docker install: - - chmod ugo+x ./bench - - ./bench setup docker - - ./bench init frappe-bench - - ./bench new-site site1.local - - ./bench setup hosts' + - chmod ugo+x ./dbench + - ./dbench setup docker + - ./dbench init frappe-bench + - ./dbench new-site site1.local + - ./dbench setup hosts' - pip install --upgrade virtualenv - virtualenv -p python3 testenv - source testenv/bin/activate diff --git a/Dockerfile b/Dockerfile index eaf29640..9afcab01 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,6 @@ 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 \ @@ -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/dbench b/dbench index 2433cc73..7ed7e387 100755 --- a/dbench +++ b/dbench @@ -1,10 +1,9 @@ - #!/bin/bash if [[ $# -eq 0 ]]; then docker exec -it frappe bash elif [ "$1" == 'init' ]; then - docker exec -it -u root frappe bash -c "cd /home/frappe && chown -R frappe:frappe ./*" + 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" 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 @@ -20,15 +19,15 @@ elif [ "$1" == 'setup' ]; then a=$(echo $a | tr -d / ) result="127.0.0.1 ${a}" sudo echo $result >> /etc/hosts - docker exec -u root -i frappe bash -c "echo ${result} | tee --append /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 -i -u "$user" frappe bash -c "$@" + docker exec -iu "$user" frappe bash -c "$@" else IFS=" " - docker exec -i frappe bash -c "bench $*" + docker exec -it frappe bash -c "bench $*" fi \ No newline at end of file From d101c6447b8302f49e6fe67ee904b12c1fff696c Mon Sep 17 00:00:00 2001 From: chabad360 Date: Fri, 5 Oct 2018 20:03:06 +0000 Subject: [PATCH 13/38] Oops... --- Dockerfile | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9afcab01..d653bc99 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,16 +5,16 @@ FROM ubuntu:16.04 LABEL MAINTAINER frappé USER root -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 +28,7 @@ USER root RUN pip install -e bench-repo \ && npm install -g yarn \ && chown -R frappe:frappe /home/frappe/* \ - && && rm -rf /var/lib/apt/lists/* + && rm -rf /var/lib/apt/lists/* USER frappe WORKDIR /home/frappe/frappe-bench From 9424efb63ed7db7d02a39b866ea749f6c486da52 Mon Sep 17 00:00:00 2001 From: chabad360 Date: Fri, 5 Oct 2018 20:11:11 +0000 Subject: [PATCH 14/38] oops, but only for travis, this runs fine --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 7997266a..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 - - ./dbench setup hosts' + - ./dbench setup hosts - pip install --upgrade virtualenv - virtualenv -p python3 testenv - source testenv/bin/activate From 0618f89c5cc9fd60f475f7dc00e7f122ca064885 Mon Sep 17 00:00:00 2001 From: chabad360 Date: Fri, 5 Oct 2018 21:35:19 +0000 Subject: [PATCH 15/38] Travis! --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 9bbe3de6..cda2ba5d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,7 @@ install: - ./dbench setup docker - ./dbench init frappe-bench - ./dbench new-site site1.local - - ./dbench setup hosts + - sudo ./dbench setup hosts - pip install --upgrade virtualenv - virtualenv -p python3 testenv - source testenv/bin/activate From ac6756c30a38130959932ef6df85a6367e154461 Mon Sep 17 00:00:00 2001 From: chabad360 Date: Fri, 5 Oct 2018 22:05:26 +0000 Subject: [PATCH 16/38] added help to dbench, and updated readme --- README.md | 24 ++++++++++-------------- dbench | 21 +++++++++++++++++++-- 2 files changed, 29 insertions(+), 16 deletions(-) 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 7ed7e387..225a25e3 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 frappe-bench --ignore-exist --skip-redis-config-generation" + 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 @@ -18,7 +18,7 @@ elif [ "$1" == 'setup' ]; then a="${a//$'\n'/ }" a=$(echo $a | tr -d / ) result="127.0.0.1 ${a}" - sudo echo $result >> /etc/hosts + 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 @@ -27,6 +27,23 @@ elif [ "$1" == '-c' ]; then user=$1 shift docker exec -iu "$user" frappe bash -c "$@" +elif [ "$1" == '-h' ]; then + echo "$0 [-h] | [ -c frappe | root ] [ command to send to bench ]" + 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 docker 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 [ command to send to bench ]" + echo " Runs a command in bench, i.e. $0 new-site site1.local = bench new-site site1.local" else IFS=" " docker exec -it frappe bash -c "bench $*" From 36ea7c5d706985b535eddb76c23dbcb6f4a41114 Mon Sep 17 00:00:00 2001 From: chabad360 Date: Fri, 5 Oct 2018 22:12:48 +0000 Subject: [PATCH 17/38] changes some of the wording of the help message --- dbench | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/dbench b/dbench index 225a25e3..76da4e19 100755 --- a/dbench +++ b/dbench @@ -28,21 +28,23 @@ elif [ "$1" == '-c' ]; then shift docker exec -iu "$user" frappe bash -c "$@" elif [ "$1" == '-h' ]; then - echo "$0 [-h] | [ -c frappe | root ] [ command to send to bench ]" + 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 " $0 init bench-folder-name" echo " Runs \"bench init\" along with some other commands" echo " $0 setup docker" - echo " starts docker using \"docker-compose up -d\"" + 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 hosts file, run with sudo" echo " $0 -c frappe | root " echo " Runs a command in the container, as the selected user" - echo " $0 [ command to send to bench ]" + 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 IFS=" " From 9f34d06a4b7253e9a4bc39b28a82d4d855655e60 Mon Sep 17 00:00:00 2001 From: Chinmay Pai Date: Sat, 13 Oct 2018 17:20:04 +0000 Subject: [PATCH 18/38] 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 cc277c00cd4ed0f96b69ebcdbbbc6184aca50747 Mon Sep 17 00:00:00 2001 From: chabad360 Date: Fri, 19 Oct 2018 18:51:12 +0000 Subject: [PATCH 19/38] 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 a2e942496e65218fe504793859fe8ca341656471 Mon Sep 17 00:00:00 2001 From: William Moreno Date: Mon, 22 Oct 2018 01:11:59 -0600 Subject: [PATCH 20/38] 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 293229e46306bc23f08779644ac1468e78582f22 Mon Sep 17 00:00:00 2001 From: Mendel Greenberg Date: Fri, 18 Jan 2019 07:45:44 -0500 Subject: [PATCH 21/38] 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 a8d4fe1bb9587c108ba9e05cb1c34c4636fca533 Mon Sep 17 00:00:00 2001 From: Mendel Greenberg Date: Fri, 18 Jan 2019 15:53:53 -0500 Subject: [PATCH 22/38] 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 802686518c907240642a453da8862601cfe3175b Mon Sep 17 00:00:00 2001 From: Mendel Greenberg Date: Fri, 18 Jan 2019 16:07:18 -0500 Subject: [PATCH 23/38] 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" From 26eb48b087160269d45256843d44afa314eab6b5 Mon Sep 17 00:00:00 2001 From: Mendel Greenberg Date: Sat, 19 Jan 2019 19:50:13 -0500 Subject: [PATCH 24/38] Changed the readme significantly Please enter the commit message for your changes. Lines starting --- README.md | 137 ++++++++++++++---------------------------------------- 1 file changed, 36 insertions(+), 101 deletions(-) diff --git a/README.md b/README.md index a3d01a7e..74653801 100644 --- a/README.md +++ b/README.md @@ -1,130 +1,65 @@ -# frappe_docker +# Frappe on Docker + [![Build Status](https://travis-ci.org/frappe/frappe_docker.svg?branch=master)](https://travis-ci.org/frappe/frappe_docker) -- [Docker](https://docker.com/) is an open source project to pack, ship and run any Linux application in a lighter weight, faster container than a traditional virtual machine. - -- Docker makes it much easier to deploy [frappe](https://github.com/frappe/frappe) on your servers. - -- This container uses [bench](https://github.com/frappe/bench) to install frappe. +This is a repo designed to aide setting up frappe/ERPNext on docker. ## Getting Started -These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system. +These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. Unfortunetly, this container is not curently suited for a production enviorment. -### Prerequisites - -[Docker](https://www.docker.com/) - -[Docker Compose](https://docs.docker.com/compose/overview/) - -### Container Configuration - -#### ports: - -``` -ports: - - "3307:3307" mariadb-port - - "8000:8000" webserver-port - - "11000:11000" redis-cache - - "12000:12000" redis-queue - - "13000:13000" redis-socketio - - "9000:9000" socketio-port - - "6787:6787" file-watcher-port -``` - -Expose port 3307 inside the container on port 3307 on ALL local host interfaces. In order to bind to only one interface, you may specify the host's IP address as `([:[host_port]])|():[/udp]` as defined in the [docker port binding documentation](http://docs.docker.com/userguide/dockerlinks/). The port 3307 of the mariadb container and port 8000 of the frappe container is exposed to the host machine and other containers. - -#### volumes: - -``` -volumes: - - ./frappe-bench:/home/frappe/frappe-bench - - ./conf/mariadb-conf.d:/etc/mysql/conf.d - - ./redis-conf/redis_socketio.conf:/etc/conf.d/redis.conf - - ./redis-conf/redis_queue.conf:/etc/conf.d/redis.conf - - ./redis-conf/redis_cache.conf:/etc/conf.d/redis.conf -``` -Exposes a directory inside the host to the container. - -#### links: - -``` -links: - - redis-cache - - redis-queue - - redis-socketio - - mariadb -``` - -Links allow you to define extra aliases by which a service is reachable from another service. - -#### depends_on: - -``` -depends_on: - - mariadb - - redis-cache - - redis-queue - - redis-socketio -``` -Express dependency between services, which has two effects: - -1. docker-compose up will start services in dependency order. In the following example, mariadb and redis will be started before frappe. - -2. docker-compose up SERVICE will automatically include SERVICE’s dependencies. In the following example, docker-compose up docker_frappe will also create and start mariadb and redis. - -### Installation - -#### 1. Installation Pre-requisites +### 1. Installation Pre-requisites - Install [Docker](https://docs.docker.com/engine/installation) Community Edition -- Install [Docker Compose](https://docs.docker.com/compose/install/) (only for Linux users). Docker for Mac, Docker for Windows, and Docker Toolbox include Docker Compose +- Install [Docker Compose](https://docs.docker.com/compose/install/) (only for Linux users. Docker for Mac, Docker for Windows, and Docker Toolbox already include Docker Compose). -#### 2. Build the container and install bench +### 2. Build the container and initialize the bench -* Clone this repo and change your working directory to frappe_docker +1. 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 + ```bash + git clone https://github.com/frappe/frappe_docker.git + cd frappe_docker + ``` -* Build the container and install bench inside the container. +2. Build and start the container, and initialize the bench - 1.Build the 5 linked containers frappe, mariadb, redis-cache, redis-queue and redis-socketio using this command. Make sure your current working directory is frappe_docker which contains the docker-compose.yml and Dockerfile. - 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) + ```bash + ./dbench setup docker + ./dbench init + ``` - ./dbench setup docker + Note: This will take a while, as docker will now build the container. - Note: Please do not remove the bench-repo directory the above commands will create +3. Add a new site and start frappe + ```bash + ./dbench new-site site1.local + ./dbench setup hosts + ./dbench start + ``` +4. To use frappe: Open your browser to `localhost:8000`. + Username: `Administrator` Password: `admin` +### Basic Usage* -#### Basic Usage -##### Make sure your current directory is frappe_docker -1. First time setup +- `./dbench`: Launches you into an interactive shell in the container as user frappe - ./dbench init +- `./dbench setup docker [ stop | down ]`: Starts and builds the docker containers using `docker-compose up -d` -2. Command to be executed everytime after starting your containers +- `./dbench setup hosts`: Adds all sites to the containers hosts file. + Do this after you've added a new site to avoid errors. - ./dbench setup hosts +- `./dbench -c frappe | root `: Runs a command in the container, as the selected user -3. Command to enter your container +- `./dbench -h`: Shows this help message - ./dbench +- `./dbench `: Runs a command in bench, (Running `./dbench new-site site1.local` will run in the conatiner as `bench new-site site1.local`) -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```. +*Always make sure that your current directory is the root directory of the repo (i.e. `frappe_docker/`) -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. - -## Built With - -* [Docker](https://www.docker.com/) +For more info on building this docker container refer to this [Wiki](https://github.com/frappe/frappe_docker/wiki/Hitchhiker's-guide-to-building-this-frappe_docker-image) ## Contributing From 8a4e2d02d4ce8d0c3739aefeae4de89ca9e7924b Mon Sep 17 00:00:00 2001 From: Mendel Greenberg Date: Sat, 19 Jan 2019 19:50:32 -0500 Subject: [PATCH 25/38] changed test.py to avoid naming errors --- test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test.py b/test.py index e29fa851..c127ad74 100644 --- a/test.py +++ b/test.py @@ -13,7 +13,7 @@ def print_out(val,delay): elif val == 2: try: global r - r = requests.get("http://site1.local:8000") + r = requests.get("http://localhost:8000") print(r) except requests.exceptions.ConnectionError as e: print(e) From 1ae03914ab656d18d5e040f455d775431a4a40bf Mon Sep 17 00:00:00 2001 From: Mendel Greenberg Date: Sun, 20 Jan 2019 07:02:09 -0500 Subject: [PATCH 26/38] moving some things around for less lines --- Dockerfile | 6 +++--- dbench | 4 +--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index f37a1eb0..65ac2edf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,12 +23,12 @@ RUN curl https://deb.nodesource.com/node_10.x/pool/main/n/nodejs/nodejs_10.10.0- USER frappe WORKDIR /home/frappe -RUN git clone -b master https://github.com/frappe/bench.git bench-repo +RUN chown -R frappe:frappe /home/frappe \ + && git clone -b master https://github.com/frappe/bench.git bench-repo USER root RUN pip install -e bench-repo && rm -rf ~/.cache/pip \ - && npm install -g yarn \ - && chown -R frappe:frappe /home/frappe/* + && npm install -g yarn USER frappe WORKDIR /home/frappe/frappe-bench diff --git a/dbench b/dbench index bb283dca..25cc8814 100755 --- a/dbench +++ b/dbench @@ -3,7 +3,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 -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' ] && [ "$2" == 'docker' ]; then @@ -34,8 +34,6 @@ 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 " Runs \"bench init\" along with some other commands" echo " $0 setup docker [ stop | down ]" echo " Starts and builds the docker containers using \"docker-compose up -d\"" echo " $0 setup hosts" From 7da37607d44ab4f1501ca7dd6e58b4163a4ec32e Mon Sep 17 00:00:00 2001 From: Mendel Greenberg Date: Sun, 20 Jan 2019 07:30:35 -0500 Subject: [PATCH 27/38] some more slight name changes --- .../pids/redis_cache.pid | 0 .../pids/redis_queue.pid | 0 .../pids/redis_socketio.pid | 0 conf/{redis-conf => redis-conf.d}/redis_cache.conf | 0 conf/{redis-conf => redis-conf.d}/redis_queue.conf | 0 .../{redis-conf => redis-conf.d}/redis_socketio.conf | 0 docker-compose.yml | 12 ++++++------ 7 files changed, 6 insertions(+), 6 deletions(-) rename conf/{redis-conf => redis-conf.d}/pids/redis_cache.pid (100%) rename conf/{redis-conf => redis-conf.d}/pids/redis_queue.pid (100%) rename conf/{redis-conf => redis-conf.d}/pids/redis_socketio.pid (100%) rename conf/{redis-conf => redis-conf.d}/redis_cache.conf (100%) rename conf/{redis-conf => redis-conf.d}/redis_queue.conf (100%) rename conf/{redis-conf => redis-conf.d}/redis_socketio.conf (100%) diff --git a/conf/redis-conf/pids/redis_cache.pid b/conf/redis-conf.d/pids/redis_cache.pid similarity index 100% rename from conf/redis-conf/pids/redis_cache.pid rename to conf/redis-conf.d/pids/redis_cache.pid diff --git a/conf/redis-conf/pids/redis_queue.pid b/conf/redis-conf.d/pids/redis_queue.pid similarity index 100% rename from conf/redis-conf/pids/redis_queue.pid rename to conf/redis-conf.d/pids/redis_queue.pid diff --git a/conf/redis-conf/pids/redis_socketio.pid b/conf/redis-conf.d/pids/redis_socketio.pid similarity index 100% rename from conf/redis-conf/pids/redis_socketio.pid rename to conf/redis-conf.d/pids/redis_socketio.pid diff --git a/conf/redis-conf/redis_cache.conf b/conf/redis-conf.d/redis_cache.conf similarity index 100% rename from conf/redis-conf/redis_cache.conf rename to conf/redis-conf.d/redis_cache.conf diff --git a/conf/redis-conf/redis_queue.conf b/conf/redis-conf.d/redis_queue.conf similarity index 100% rename from conf/redis-conf/redis_queue.conf rename to conf/redis-conf.d/redis_queue.conf diff --git a/conf/redis-conf/redis_socketio.conf b/conf/redis-conf.d/redis_socketio.conf similarity index 100% rename from conf/redis-conf/redis_socketio.conf rename to conf/redis-conf.d/redis_socketio.conf diff --git a/docker-compose.yml b/docker-compose.yml index 92286cde..c6e3cade 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -20,7 +20,7 @@ services: image: redis:alpine volumes: - - ./conf/redis-conf:/etc/conf.d + - ./conf/redis-conf.d:/etc/conf.d command: ["redis-server","/etc/conf.d/redis_cache.conf"] @@ -30,7 +30,7 @@ services: image: redis:alpine volumes: - - ./conf/redis-conf:/etc/conf.d + - ./conf/redis-conf.d:/etc/conf.d command: ["redis-server","/etc/conf.d/redis_queue.conf"] @@ -40,7 +40,7 @@ services: image: redis:alpine volumes: - - ./conf/redis-conf:/etc/conf.d + - ./conf/redis-conf.d:/etc/conf.d command: ["redis-server","/etc/conf.d/redis_socketio.conf"] @@ -50,9 +50,9 @@ services: frappe: volumes: - ./frappe-bench:/home/frappe/frappe-bench - - ./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 + - ./conf/redis-conf.d/redis_cache.conf:/home/frappe/frappe-bench/config/redis_cache.conf + - ./conf/redis-conf.d/redis_queue.conf:/home/frappe/frappe-bench/config/redis_queue.conf + - ./conf/redis-conf.d/redis_socketio.conf:/home/frappe/frappe-bench/config/redis_socketio.conf build: . ports: - "8000:8000" #webserver_port From a191f74c14f0871429373e9dea8a61bca270042f Mon Sep 17 00:00:00 2001 From: Mendel Greenberg Date: Wed, 23 Jan 2019 07:23:08 -0500 Subject: [PATCH 28/38] added a .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..4d67604d --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.code-workspace From a7f564e222d414d65319f80bd90c7e3e87caf837 Mon Sep 17 00:00:00 2001 From: Mendel Greenberg Date: Thu, 24 Jan 2019 06:10:42 -0500 Subject: [PATCH 29/38] added the frappe folder again --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 65ac2edf..fcd268a9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -31,4 +31,5 @@ RUN pip install -e bench-repo && rm -rf ~/.cache/pip \ && npm install -g yarn USER frappe +ADD ./frappe-bench /home/frappe/frappe-bench WORKDIR /home/frappe/frappe-bench From cf3c4dc1733ccee1276d1ce8536428346c593f55 Mon Sep 17 00:00:00 2001 From: Mendel Greenberg Date: Thu, 24 Jan 2019 06:33:24 -0500 Subject: [PATCH 30/38] added a .dockerignore and fixed the dockerfile up a bit --- .dockerignore | 7 +++++++ Dockerfile | 18 ++++++++---------- 2 files changed, 15 insertions(+), 10 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..37f67d5a --- /dev/null +++ b/.dockerignore @@ -0,0 +1,7 @@ +# frappe_docker .dockerignore file + +conf/* +.travis.yml +test.py +dbench +docker-*.yml \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index fcd268a9..32e044d5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,18 +1,16 @@ - -#bench Dockerfile +# Frappe Bench Dockerfile FROM ubuntu:16.04 -LABEL MAINTAINER frappé +LABEL author=frappé -USER root # 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 && apt-get clean \ - && rm -rf /var/lib/apt/lists/* +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 \ + && 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 @@ -31,5 +29,5 @@ RUN pip install -e bench-repo && rm -rf ~/.cache/pip \ && npm install -g yarn USER frappe -ADD ./frappe-bench /home/frappe/frappe-bench +ADD --chown=frappe:frappe ./frappe-bench /home/frappe/frappe-bench WORKDIR /home/frappe/frappe-bench From b68380c52069cc4964d65f9e0f6184beebc80fd8 Mon Sep 17 00:00:00 2001 From: chabad360 Date: Fri, 25 Jan 2019 11:28:06 -0500 Subject: [PATCH 31/38] Updating travis' docker and compose This is the commit message #3: --- .travis.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 9bbe3de6..18e18efb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,11 +2,21 @@ language: python python: - "2.7" env: - - DOCKER_COMPOSE_VERSION: 1.22.0 + - DOCKER_COMPOSE_VERSION: 1.23.1 services: - docker +before_install: + - curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - + - sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" + - sudo apt-get update + - sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce + - sudo rm /usr/local/bin/docker-compose + - curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose + - chmod +x docker-compose + - sudo mv docker-compose /usr/local/bin + install: - chmod ugo+x ./dbench - ./dbench setup docker From ea8fa56654fbc79b21f7b0e6b789e34b0acfdd57 Mon Sep 17 00:00:00 2001 From: chabad360 Date: Fri, 25 Jan 2019 17:53:04 +0000 Subject: [PATCH 32/38] bringing chown in dbench back --- dbench | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbench b/dbench index 25cc8814..a3d6a3f2 100755 --- a/dbench +++ b/dbench @@ -3,7 +3,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 -itu root frappe bash -c "chown -R frappe:frappe /home/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' ] && [ "$2" == 'docker' ]; then From 33b8dfea70ae4d2a3fca4229774209ecea9d4a03 Mon Sep 17 00:00:00 2001 From: Mendel Greenberg Date: Sun, 27 Jan 2019 07:14:18 -0500 Subject: [PATCH 33/38] some refractoring --- Dockerfile | 14 ++++++++------ dbench | 40 ++++++++++++++++++++++++---------------- 2 files changed, 32 insertions(+), 22 deletions(-) diff --git a/Dockerfile b/Dockerfile index 32e044d5..c10cec5f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,10 +6,11 @@ LABEL author=frappé # 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 \ +# Install all neccesary packages +RUN apt-get update && apt-get install -y --no-install-recommends iputils-ping git build-essential python-setuptools \ + libssl-dev libjpeg8-dev redis-tools software-properties-common libxrender1 libxext6 xfonts-75dpi xfonts-base \ + python-dev libffi-dev libfreetype6-dev liblcms2-dev libwebp-dev python-tk libsasl2-dev libldap2-dev libtiff5-dev \ + tk8.6-dev wget libmysqlclient-dev mariadb-client mariadb-common curl rlwrap wkhtmltopdf python-pip 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 @@ -25,8 +26,9 @@ RUN chown -R frappe:frappe /home/frappe \ && git clone -b master https://github.com/frappe/bench.git bench-repo USER root -RUN pip install -e bench-repo && rm -rf ~/.cache/pip \ - && npm install -g yarn +# Install bench +RUN pip install -e git+https://github.com/frappe/bench.git#egg=bench \ + && rm -rf ~/.cache/pip USER frappe ADD --chown=frappe:frappe ./frappe-bench /home/frappe/frappe-bench diff --git a/dbench b/dbench index a3d6a3f2..b0fb1971 100755 --- a/dbench +++ b/dbench @@ -1,33 +1,41 @@ #!/bin/bash +function run () { + user=$1 + shift + docker exec -itu "${user}" frappe bash -c "$@" +} + if [[ $# -eq 0 ]]; then docker exec -it frappe bash -elif [ "$1" == 'init' ]; then - docker exec -itu root frappe bash -c "chown -R frappe:frappe /home/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' ] && [ "$2" == 'docker' ]; then - if [ "$3" == '--swarm-mode' ]; then +elif [[ "$1" == 'init' ]]; then + run root "chown -R frappe:frappe /home/frappe" + run frappe "cd .. && bench init frappe-bench --ignore-exist --skip-redis-config-generation && cd frappe-bench" + run frappe "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" - elif [ "$3" == 'down' ]; then + elif [[ "$3" == 'down' ]]; then docker-compose down - elif [ "$3" == 'stop' ]; then + elif [[ "$3" == 'stop' ]]; then docker-compose stop else docker-compose up -d fi -elif [ "$1" == 'setup' ] && [ "$2" == 'hosts' ]; then - a=$(cd frappe-bench && ls sites/*/site_config.json | grep -o '/.\+/') + elif [[ "$2" == 'hosts' ]]; then + a=$(cd ~/frappe-bench && ls sites/*/site_config.json | grep -o '/.\+/') a="${a//$'\n'/ }" - a=$(echo $a | tr -d / ) + a=$(echo "$a" | tr -d / ) result="127.0.0.1 ${a}" - docker exec -iu root frappe bash -c "echo ${result} | tee --append /etc/hosts" -elif [ "$1" == '-c' ]; then + run root "echo ${result} | tee --append /etc/hosts" + fi +elif [[ "$1" == '-c' ]]; then shift user=$1 shift - docker exec -iu $user frappe bash -c "$@" -elif [ "$1" == '-h' ]; then + run "$user" "$@" +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." @@ -46,5 +54,5 @@ elif [ "$1" == '-h' ]; then echo " Runs a command in bench, i.e. $0 new-site site1.local = bench new-site site1.local" else IFS=" " - docker exec -it frappe bash -c "bench $*" + run frappe "bench $*" fi From 8493739787599a4583fccb5ff8e6597e96751038 Mon Sep 17 00:00:00 2001 From: Mendel Greenberg Date: Sun, 10 Feb 2019 12:03:51 -0500 Subject: [PATCH 34/38] implementing codacy sugestions --- Dockerfile | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index c10cec5f..c3f179ed 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,10 +7,10 @@ LABEL author=frappé ENV LANG C.UTF-8 # Install all neccesary packages -RUN apt-get update && apt-get install -y --no-install-recommends iputils-ping git build-essential python-setuptools \ - libssl-dev libjpeg8-dev redis-tools software-properties-common libxrender1 libxext6 xfonts-75dpi xfonts-base \ - python-dev libffi-dev libfreetype6-dev liblcms2-dev libwebp-dev python-tk libsasl2-dev libldap2-dev libtiff5-dev \ - tk8.6-dev wget libmysqlclient-dev mariadb-client mariadb-common curl rlwrap wkhtmltopdf python-pip sudo \ +RUN apt-get update && apt-get install -y --no-install-recommends 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 \ && 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 @@ -31,5 +31,6 @@ RUN pip install -e git+https://github.com/frappe/bench.git#egg=bench \ && rm -rf ~/.cache/pip USER frappe -ADD --chown=frappe:frappe ./frappe-bench /home/frappe/frappe-bench +# Add some bench files +COPY --chown=frappe:frappe ./frappe-bench /home/frappe/frappe-bench WORKDIR /home/frappe/frappe-bench From 98bdef566966ab722099c474deb8eca0187cd030 Mon Sep 17 00:00:00 2001 From: Mendel Greenberg Date: Thu, 14 Feb 2019 22:55:29 -0500 Subject: [PATCH 35/38] moving some things around --- Dockerfile | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index c3f179ed..761ca018 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,27 +10,35 @@ ENV LANG C.UTF-8 RUN apt-get update && apt-get install -y --no-install-recommends 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 \ + tk8.6-dev wget libmysqlclient-dev mariadb-client mariadb-common curl rlwrap redis-tools wkhtmltopdf python-pip 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 +# Install Node.js and yarn 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 + && dpkg -i node.deb \ + && rm node.deb \ + && npm install -g yarn + +# Add frappe user and setup sudo +RUN useradd -ms /bin/bash -G sudo frappe \ + && printf '# Sudo rules for frappe\nfrappe ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers.d/frappe USER frappe WORKDIR /home/frappe -RUN chown -R frappe:frappe /home/frappe \ - && git clone -b master https://github.com/frappe/bench.git bench-repo +# Add some bench files +COPY --chown=frappe:frappe ./frappe-bench /home/frappe/frappe-bench USER root # Install bench -RUN pip install -e git+https://github.com/frappe/bench.git#egg=bench \ +RUN pip install -e git+https://github.com/frappe/bench.git \ && rm -rf ~/.cache/pip USER frappe -# Add some bench files -COPY --chown=frappe:frappe ./frappe-bench /home/frappe/frappe-bench WORKDIR /home/frappe/frappe-bench + +EXPOSE 8000 +EXPOSE 9000 +EXPOSE 6787 + +VOLUME [ "/home/frappe/frappe-bench" ] \ No newline at end of file From dd8da9a869cf84ea99d571c7dd3bfcc0be6850b5 Mon Sep 17 00:00:00 2001 From: Mendel Greenberg Date: Sun, 17 Feb 2019 22:23:46 -0500 Subject: [PATCH 36/38] Updating dbench in some areas --- dbench | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbench b/dbench index b0fb1971..cbed7707 100755 --- a/dbench +++ b/dbench @@ -24,7 +24,7 @@ elif [[ "$1" == 'setup' ]]; then docker-compose up -d fi elif [[ "$2" == 'hosts' ]]; then - a=$(cd ~/frappe-bench && ls sites/*/site_config.json | grep -o '/.\+/') + a=$(run frappe "ls sites/*/site_config.json | grep -o '/.\+/'") \ a="${a//$'\n'/ }" a=$(echo "$a" | tr -d / ) result="127.0.0.1 ${a}" From e13b7121af7abfd3fba8f9210329c866908ee527 Mon Sep 17 00:00:00 2001 From: Mendel Greenberg Date: Mon, 25 Feb 2019 23:04:09 -0500 Subject: [PATCH 37/38] some random changes and fixes --- Dockerfile | 4 ++-- conf/mariadb-conf.d/my.cnf | 9 +++++++++ conf/mariadb-conf.d/mysql.cnf | 2 -- conf/mariadb-conf.d/mysqld_safe_syslog.cnf | 4 ---- conf/mariadb-conf.d/mysqldump.cnf | 5 ----- conf/redis-conf.d/pids/redis_cache.pid | 1 - conf/redis-conf.d/pids/redis_queue.pid | 1 - conf/redis-conf.d/pids/redis_socketio.pid | 1 - docker-compose.yml | 2 +- 9 files changed, 12 insertions(+), 17 deletions(-) delete mode 100644 conf/mariadb-conf.d/mysql.cnf delete mode 100644 conf/mariadb-conf.d/mysqld_safe_syslog.cnf delete mode 100644 conf/mariadb-conf.d/mysqldump.cnf delete mode 100644 conf/redis-conf.d/pids/redis_cache.pid delete mode 100644 conf/redis-conf.d/pids/redis_queue.pid delete mode 100644 conf/redis-conf.d/pids/redis_socketio.pid diff --git a/Dockerfile b/Dockerfile index 761ca018..3b12962f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ FROM ubuntu:16.04 LABEL author=frappé -# Generate locale C.UTF-8 for mariadb and general locale data +# Set locale C.UTF-8 for mariadb and general locale data ENV LANG C.UTF-8 # Install all neccesary packages @@ -31,7 +31,7 @@ COPY --chown=frappe:frappe ./frappe-bench /home/frappe/frappe-bench USER root # Install bench -RUN pip install -e git+https://github.com/frappe/bench.git \ +RUN pip install -e git+https://github.com/frappe/bench.git#egg=bench \ && rm -rf ~/.cache/pip USER frappe diff --git a/conf/mariadb-conf.d/my.cnf b/conf/mariadb-conf.d/my.cnf index 7864c7e6..5b99beba 100644 --- a/conf/mariadb-conf.d/my.cnf +++ b/conf/mariadb-conf.d/my.cnf @@ -27,3 +27,12 @@ collation-server = utf8mb4_unicode_ci [mysql] default-character-set = utf8mb4 + +[mysqld_safe] +skip_log_error +syslog + +[mysqldump] +quick +quote-names +max_allowed_packet = 16M diff --git a/conf/mariadb-conf.d/mysql.cnf b/conf/mariadb-conf.d/mysql.cnf deleted file mode 100644 index b4a7402c..00000000 --- a/conf/mariadb-conf.d/mysql.cnf +++ /dev/null @@ -1,2 +0,0 @@ -[mysql] - diff --git a/conf/mariadb-conf.d/mysqld_safe_syslog.cnf b/conf/mariadb-conf.d/mysqld_safe_syslog.cnf deleted file mode 100644 index c09bd0ed..00000000 --- a/conf/mariadb-conf.d/mysqld_safe_syslog.cnf +++ /dev/null @@ -1,4 +0,0 @@ -[mysqld_safe] -skip_log_error -syslog - diff --git a/conf/mariadb-conf.d/mysqldump.cnf b/conf/mariadb-conf.d/mysqldump.cnf deleted file mode 100644 index d9d88acd..00000000 --- a/conf/mariadb-conf.d/mysqldump.cnf +++ /dev/null @@ -1,5 +0,0 @@ -[mysqldump] -quick -quote-names -max_allowed_packet = 16M - diff --git a/conf/redis-conf.d/pids/redis_cache.pid b/conf/redis-conf.d/pids/redis_cache.pid deleted file mode 100644 index 209e3ef4..00000000 --- a/conf/redis-conf.d/pids/redis_cache.pid +++ /dev/null @@ -1 +0,0 @@ -20 diff --git a/conf/redis-conf.d/pids/redis_queue.pid b/conf/redis-conf.d/pids/redis_queue.pid deleted file mode 100644 index a45fd52c..00000000 --- a/conf/redis-conf.d/pids/redis_queue.pid +++ /dev/null @@ -1 +0,0 @@ -24 diff --git a/conf/redis-conf.d/pids/redis_socketio.pid b/conf/redis-conf.d/pids/redis_socketio.pid deleted file mode 100644 index f04c001f..00000000 --- a/conf/redis-conf.d/pids/redis_socketio.pid +++ /dev/null @@ -1 +0,0 @@ -29 diff --git a/docker-compose.yml b/docker-compose.yml index c6e3cade..5968882b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,4 @@ -version: '3.3' +version: '3.7' services: mariadb: image: mariadb From 545dbaf88544fc37b392e5857b3ded9703dea741 Mon Sep 17 00:00:00 2001 From: Mendel Greenberg Date: Tue, 26 Feb 2019 00:22:27 -0500 Subject: [PATCH 38/38] dockerfile refactoring --- Dockerfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3b12962f..e5fc5dee 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,10 +7,10 @@ LABEL author=frappé ENV LANG C.UTF-8 # Install all neccesary packages -RUN apt-get update && apt-get install -y --no-install-recommends 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 wkhtmltopdf python-pip sudo \ +RUN apt-get update && apt-get install -y --no-install-recommends iputils-ping git build-essential \ + libffi-dev libssl-dev libjpeg8-dev redis-tools software-properties-common libxext6 xfonts-75dpi xfonts-base \ + python-dev libfreetype6-dev liblcms2-dev libwebp-dev python-tk libsasl2-dev libldap2-dev libtiff5-dev \ + python-setuptools tk8.6-dev wget libmysqlclient-dev mariadb-client curl rlwrap wkhtmltopdf python-pip sudo \ && apt-get clean && rm -rf /var/lib/apt/lists/* RUN pip install --upgrade setuptools pip && rm -rf ~/.cache/pip