mirror of
https://github.com/frappe/frappe_docker.git
synced 2026-06-20 23:05:09 +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
|
# 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 \
|
# Install all neccesary packages
|
||||||
libjpeg8-dev redis-tools redis-server software-properties-common libxrender1 libxext6 xfonts-75dpi xfonts-base zlib1g-dev \
|
RUN apt-get update && apt-get install -y --no-install-recommends iputils-ping git build-essential python-setuptools \
|
||||||
libfreetype6-dev liblcms2-dev libwebp-dev python-tk apt-transport-https libsasl2-dev libldap2-dev libtiff5-dev tcl8.6-dev \
|
libssl-dev libjpeg8-dev redis-tools software-properties-common libxrender1 libxext6 xfonts-75dpi xfonts-base \
|
||||||
tk8.6-dev wget libmysqlclient-dev mariadb-client mariadb-common curl rlwrap redis-tools nano wkhtmltopdf python-pip vim sudo \
|
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/*
|
&& apt-get clean && rm -rf /var/lib/apt/lists/*
|
||||||
RUN pip install --upgrade setuptools pip && rm -rf ~/.cache/pip
|
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
|
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
|
&& git clone -b master https://github.com/frappe/bench.git bench-repo
|
||||||
|
|
||||||
USER root
|
USER root
|
||||||
RUN pip install -e bench-repo && rm -rf ~/.cache/pip \
|
# Install bench
|
||||||
&& npm install -g yarn
|
RUN pip install -e git+https://github.com/frappe/bench.git#egg=bench \
|
||||||
|
&& rm -rf ~/.cache/pip
|
||||||
|
|
||||||
USER frappe
|
USER frappe
|
||||||
ADD --chown=frappe:frappe ./frappe-bench /home/frappe/frappe-bench
|
ADD --chown=frappe:frappe ./frappe-bench /home/frappe/frappe-bench
|
||||||
|
|
|
||||||
40
dbench
40
dbench
|
|
@ -1,33 +1,41 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
function run () {
|
||||||
|
user=$1
|
||||||
|
shift
|
||||||
|
docker exec -itu "${user}" frappe bash -c "$@"
|
||||||
|
}
|
||||||
|
|
||||||
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' ]]; then
|
||||||
docker exec -itu root frappe bash -c "chown -R frappe:frappe /home/frappe"
|
run root "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"
|
run frappe "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"
|
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' ] && [ "$2" == 'docker' ]; then
|
elif [[ "$1" == 'setup' ]]; then
|
||||||
if [ "$3" == '--swarm-mode' ]; then
|
if [[ "$2" == 'docker' ]]; then
|
||||||
|
if [[ "$3" == '--swarm-mode' ]]; then
|
||||||
echo "Docker swarm mode is not currently supported"
|
echo "Docker swarm mode is not currently supported"
|
||||||
elif [ "$3" == 'down' ]; then
|
elif [[ "$3" == 'down' ]]; then
|
||||||
docker-compose down
|
docker-compose down
|
||||||
elif [ "$3" == 'stop' ]; then
|
elif [[ "$3" == 'stop' ]]; then
|
||||||
docker-compose stop
|
docker-compose stop
|
||||||
else
|
else
|
||||||
docker-compose up -d
|
docker-compose up -d
|
||||||
fi
|
fi
|
||||||
elif [ "$1" == 'setup' ] && [ "$2" == 'hosts' ]; then
|
elif [[ "$2" == 'hosts' ]]; then
|
||||||
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}"
|
||||||
docker exec -iu root frappe bash -c "echo ${result} | tee --append /etc/hosts"
|
run root "echo ${result} | tee --append /etc/hosts"
|
||||||
elif [ "$1" == '-c' ]; then
|
fi
|
||||||
|
elif [[ "$1" == '-c' ]]; then
|
||||||
shift
|
shift
|
||||||
user=$1
|
user=$1
|
||||||
shift
|
shift
|
||||||
docker exec -iu $user frappe bash -c "$@"
|
run "$user" "$@"
|
||||||
elif [ "$1" == '-h' ]; then
|
elif [[ "$1" == '-h' ]]; then
|
||||||
echo "$0 [-h] | [ -c frappe | root <command to run> ] [ <command to send to bench> ]"
|
echo "$0 [-h] | [ -c frappe | root <command to run> ] [ <command to send to bench> ]"
|
||||||
echo ""
|
echo ""
|
||||||
echo "$0 extends the Frappe Bench tool, and is used like it. However, it extends the tool in a few places."
|
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"
|
echo " Runs a command in bench, i.e. $0 new-site site1.local = bench new-site site1.local"
|
||||||
else
|
else
|
||||||
IFS=" "
|
IFS=" "
|
||||||
docker exec -it frappe bash -c "bench $*"
|
run frappe "bench $*"
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue