mirror of
https://github.com/frappe/frappe_docker.git
synced 2024-12-23 18:48:58 +00:00
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.
This commit is contained in:
parent
e079c479f5
commit
2b1334d5a5
15
.travis.yml
15
.travis.yml
@ -2,20 +2,17 @@ language: python
|
|||||||
python:
|
python:
|
||||||
- "2.7"
|
- "2.7"
|
||||||
env:
|
env:
|
||||||
- DOCKER_COMPOSE_VERSION: 1.8.0
|
- DOCKER_COMPOSE_VERSION: 1.22.0
|
||||||
|
|
||||||
services:
|
services:
|
||||||
- docker
|
- docker
|
||||||
|
|
||||||
install:
|
install:
|
||||||
- docker-compose build
|
- chmod ugo+x ./dbench
|
||||||
- docker-compose up -d
|
- ./dbench setup docker
|
||||||
- docker exec -it -u root frappe bash -c "cd /home/frappe && chown -R frappe:frappe ./*"
|
- ./dbench init frappe-bench
|
||||||
- docker exec -i frappe bash -c "cd .. && bench init frappe-bench --ignore-exist --skip-redis-config-generation && cd frappe-bench"
|
- ./dbench new-site site1.local
|
||||||
- docker exec -i frappe bash -c "mv Procfile_docker Procfile && mv sites/common_site_config_docker.json sites/common_site_config.json"
|
- sudo ./dbench setup hosts
|
||||||
- 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'
|
|
||||||
- pip install --upgrade virtualenv
|
- pip install --upgrade virtualenv
|
||||||
- virtualenv -p python3 testenv
|
- virtualenv -p python3 testenv
|
||||||
- source testenv/bin/activate
|
- source testenv/bin/activate
|
||||||
|
18
Dockerfile
18
Dockerfile
@ -5,17 +5,16 @@ FROM ubuntu:16.04
|
|||||||
LABEL MAINTAINER frappé
|
LABEL MAINTAINER frappé
|
||||||
|
|
||||||
USER root
|
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
|
# Generate locale C.UTF-8 for mariadb and general locale data
|
||||||
ENV LANG C.UTF-8
|
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
|
#nodejs
|
||||||
RUN curl https://deb.nodesource.com/node_10.x/pool/main/n/nodejs/nodejs_10.10.0-1nodesource1_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 \
|
&& dpkg -i node.deb \
|
||||||
@ -28,7 +27,8 @@ RUN git clone -b master https://github.com/frappe/bench.git bench-repo
|
|||||||
USER root
|
USER root
|
||||||
RUN pip install -e bench-repo \
|
RUN pip install -e bench-repo \
|
||||||
&& npm install -g yarn \
|
&& npm install -g yarn \
|
||||||
&& chown -R frappe:frappe /home/frappe/*
|
&& chown -R frappe:frappe /home/frappe/* \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
USER frappe
|
USER frappe
|
||||||
WORKDIR /home/frappe/frappe-bench
|
WORKDIR /home/frappe/frappe-bench
|
||||||
|
16
README.md
16
README.md
@ -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
|
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)
|
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
|
Note: Please do not remove the bench-repo directory the above commands will create
|
||||||
|
|
||||||
@ -106,19 +106,15 @@ Express dependency between services, which has two effects:
|
|||||||
|
|
||||||
./dbench init
|
./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
|
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```.
|
||||||
|
|
||||||
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 <b>./dbench -c</b>. 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)
|
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)
|
||||||
|
|
||||||
|
89
dbench
89
dbench
@ -1,57 +1,52 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
display_usage() {
|
|
||||||
echo "$(basename "$0") [-h] [-c \"<command to be executed inside container>\"]"
|
|
||||||
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
|
if [[ $# -eq 0 ]]; then
|
||||||
docker exec -it frappe bash
|
docker exec -it frappe bash
|
||||||
|
elif [ "$1" == 'init' ]; then
|
||||||
elif [ $1 == 'init' ]
|
docker exec -itu root frappe bash -c "cd /home/frappe && chown -R frappe:frappe ./*"
|
||||||
then
|
docker exec -i frappe bash -c "cd .. && bench init $2 --ignore-exist --skip-redis-config-generation"
|
||||||
docker exec -i -u root frappe bash -c "cd /home/frappe && chown -R frappe:frappe ./*"
|
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"
|
||||||
docker exec -it frappe bash -c "cd .. && bench init frappe-bench --ignore-exist --skip-redis-config-generation && cd frappe-bench"
|
elif [ "$1" == 'setup' ]; then
|
||||||
docker exec -it frappe bash -c "mv Procfile_docker Procfile && mv sites/common_site_config_docker.json sites/common_site_config.json"
|
if [ "$2" == 'docker' ]; then
|
||||||
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"
|
if [ "$3" == '--swarm-mode' ]; then
|
||||||
docker exec -it frappe bash -c "bench set-mariadb-host mariadb"
|
echo "Docker swarm mode is not currently supported"
|
||||||
docker exec -it frappe bash -c "bench new-site site1.local"
|
else
|
||||||
docker exec -it frappe bash -c "bench get-app erpnext"
|
docker-compose up -d
|
||||||
docker exec -it frappe bash -c "bench --site site1.local install-app erpnext"
|
fi
|
||||||
|
elif [ "$2" == 'hosts' ]; then
|
||||||
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=$(cd frappe-bench && ls sites/*/site_config.json | grep -o '/.\+/')
|
||||||
a="${a//$'\n'/ }"
|
a="${a//$'\n'/ }"
|
||||||
a=$(echo $a | tr -d / )
|
a=$(echo $a | tr -d / )
|
||||||
result="127.0.0.1 ${a}"
|
result="127.0.0.1 ${a}"
|
||||||
echo $result
|
echo $result | sudo tee -a /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"
|
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
|
||||||
echo "Invalid option: -$OPTARG" >&2
|
shift
|
||||||
exit 1
|
user=$1
|
||||||
;;
|
shift
|
||||||
:)
|
docker exec -iu "$user" frappe bash -c "$@"
|
||||||
echo "Option -$OPTARG requires an argument." >&2
|
elif [ "$1" == '-h' ]; then
|
||||||
exit 1
|
echo "$0 [-h] | [ -c frappe | root <command to run> ] [ <command to send to bench> ]"
|
||||||
;;
|
echo ""
|
||||||
esac
|
echo "$0 extends the Frappe Bench tool, and is used like it. However, it extends the tool in a few places."
|
||||||
done
|
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 <command to run>"
|
||||||
|
echo " Runs a command in the container, as the selected user"
|
||||||
|
echo " $0 -h"
|
||||||
|
echo " Shows this help message"
|
||||||
|
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 $*"
|
||||||
fi
|
fi
|
Loading…
Reference in New Issue
Block a user