mirror of
https://github.com/frappe/frappe_docker.git
synced 2026-06-17 13:55:08 +00:00
some refractoring
This commit is contained in:
parent
ea8fa56654
commit
33b8dfea70
2 changed files with 32 additions and 22 deletions
14
Dockerfile
14
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
|
||||
|
|
|
|||
40
dbench
40
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 <command to run> ] [ <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."
|
||||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue