From d4d695275511c8f49a837ec1cd1e2a76400b4ba1 Mon Sep 17 00:00:00 2001 From: vishalseshagiri Date: Thu, 20 Jul 2017 11:48:19 +0000 Subject: [PATCH] Added setup-frappe.sh as a file to the docker-frappe container, Added start-frappe.sh as a script file to start the frappe container once all the containers are up and running, Added redis and mariadb as links to the frappe container, made changes to the docker-compose and Dockerfile, issue: could'nt control startup order of containers (goal for future dev), Run docker-compose up -d to start all the containers --- Dockerfile | 32 ++++++++++---------------------- code/bash_run_container.sh | 3 --- docker-compose.yml | 12 ++++++------ setup-frappe.sh | 20 +++++++------------- start-frappe.sh | 2 ++ 5 files changed, 25 insertions(+), 44 deletions(-) delete mode 100755 code/bash_run_container.sh mode change 100755 => 100644 setup-frappe.sh create mode 100755 start-frappe.sh diff --git a/Dockerfile b/Dockerfile index 08bdb117..ebf2f0df 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,6 +6,7 @@ MAINTAINER Vishal Seshagiri 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 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 @@ -18,6 +19,7 @@ RUN apt-get install -y rlwrap RUN apt-get install redis-server RUN apt-get install -y nano + #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 \ @@ -33,27 +35,13 @@ USER root RUN pip install -e bench-repo RUN apt-get install -y libmysqlclient-dev mariadb-client mariadb-common -#Scripts to be added to docker file -#USER frappe -#RUN bench init frappe-bench && cd frappe-bench +USER frappe +RUN bench init frappe-bench && cd frappe-bench -#USER root -#RUN cd /home/frappe -#RUN ls -l -# frappe-bench apps sites -# - -# On the host machine run -# docker ps - to get the id of mariadb container -# docker inspect -# get the IP address of the mariadb container which looks similar to this - -# In the docker frappe container run -# bench set-mariadb-host 172.20.0.2 - - -#RUN bench new-site site1 -#RUN bench get-app erpnext https://github.com/frappe/erpnext -#RUN bench --site site1 install-app erpnext -#RUN bench start +USER root +ADD setup-frappe.sh /home/frappe/frappe-bench +RUN chmod +x /home/frappe/frappe-bench/setup-frappe.sh +RUN chown -R frappe:frappe /home/frappe/frappe-bench/setup-frappe.sh +USER frappe +RUN getent hosts mariadb | awk '{ print $1 }' diff --git a/code/bash_run_container.sh b/code/bash_run_container.sh deleted file mode 100755 index 88b85561..00000000 --- a/code/bash_run_container.sh +++ /dev/null @@ -1,3 +0,0 @@ -chown -R frappe:frappe /home/frappe/code/bash_for_container.sh -chmod +x /home/frappe/code/bash_for_container.sh -su frappe diff --git a/docker-compose.yml b/docker-compose.yml index 6c1beb47..ccfbd2f9 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -19,13 +19,13 @@ services: - "8000:5000" stdin_open: true tty: true - #links: - # - redis - # - mariadb - network_mode: "host" + links: + - redis + - mariadb + #network_mode: "host" depends_on: - - "mariadb" - - "redis" + - mariadb + - redis volumes: - ./code:/home/frappe/code diff --git a/setup-frappe.sh b/setup-frappe.sh old mode 100755 new mode 100644 index 0901c316..6b843d2f --- a/setup-frappe.sh +++ b/setup-frappe.sh @@ -1,13 +1,7 @@ -docker-compose up -d -db_id=`docker ps | grep "mariadb" | awk '{print $1}'` -db_ip=`docker inspect --format '{{ .NetworkSettings.Networks.docker_default.IPAddress }}' $db_id` -app_id=`docker ps | grep docker_frappe | awk {'print $1'}` -app_ip=`docker inspect --format '{{ .NetworkSettings.Networks.docker_default.IPAddress }}' $app_id` -echo 'cd ../' >> ./bash_for_container.sh -echo 'bench init frappe-bench && cd frappe-bench' >> ./bash_for_container.sh -echo 'bench set-mariadb-host '$db_ip >> ./bash_for_container.sh -echo 'bench new-site site1' >> bash_for_container.sh -echo 'bench --site site1 install-app erpnext' >> bash_for_container.sh -echo 'bench start' >> bash_for_container.sh -docker cp bash_for_container.sh $app_id:/home/frappe/code -docker exec -it $app_id bash -c 'cd /home/frappe/code; exec "${SHELL:-sh}"' +db_ip=`getent hosts mariadb | awk '{ print $1 }'` +bench set-mariadb-host $db_ip +bench new-site site1 +bench get-app erpnext https://github.com/frappe/erpnext +bench --site site1 install-app erpnext +bench start + diff --git a/start-frappe.sh b/start-frappe.sh new file mode 100755 index 00000000..8ada2172 --- /dev/null +++ b/start-frappe.sh @@ -0,0 +1,2 @@ +app_id=`docker ps | grep docker_frappe | awk {'print $1'}` +docker exec -it $app_id bash -c 'cd frappe-bench; exec "${SHELL:-sh}"'