From c21d26fa36b2dffc14f1c045c004c1bf25eb068f Mon Sep 17 00:00:00 2001 From: "Chinmay D. Pai" Date: Mon, 2 Mar 2020 23:47:13 +0530 Subject: [PATCH 01/65] chore: remove redundant docker-compose Signed-off-by: Chinmay D. Pai --- docker-compose.yml | 80 --------------- frappe-installer | 250 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 250 insertions(+), 80 deletions(-) delete mode 100644 docker-compose.yml create mode 100755 frappe-installer diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index a24d2283..00000000 --- a/docker-compose.yml +++ /dev/null @@ -1,80 +0,0 @@ -version: '3.7' -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: - - ./conf/redis-conf.d:/etc/conf.d - - command: ["redis-server","/etc/conf.d/redis_cache.conf"] - - container_name: redis-cache - - redis-queue: - image: redis:alpine - - - volumes: - - ./conf/redis-conf.d:/etc/conf.d - - command: ["redis-server","/etc/conf.d/redis_queue.conf"] - - container_name: redis-queue - - redis-socketio: - image: redis:alpine - - volumes: - - ./conf/redis-conf.d:/etc/conf.d - - command: ["redis-server","/etc/conf.d/redis_socketio.conf"] - - container_name: redis-socketio - - - frappe: - build: . - - volumes: - - ./frappe-bench:/home/frappe/frappe-bench - - ./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 - - ports: - - "8000:8000" # Webserver Port - - "9000:9000" # Socketio Port - - "6787:6787" # File Watcher Port - - stdin_open: true - tty: true - - links: - - redis-cache - - redis-queue - - redis-socketio - - mariadb - - depends_on: - - mariadb - - redis-cache - - redis-queue - - redis-socketio - - container_name: frappe diff --git a/frappe-installer b/frappe-installer new file mode 100755 index 00000000..13436afd --- /dev/null +++ b/frappe-installer @@ -0,0 +1,250 @@ +#!/usr/bin/env bash + +set -euo pipefail +IFS=$'\n\t' + +[ -z "$DEBUG" ] & [ "${DEBUG}" == 1 ] && set -o xtrace + + +__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +cd "$__dir" + +env_url="https://raw.githubusercontent.com/frappe/frappe_docker/master/installation/env-example" +docker_nginx_url="https://github.com/evertramos/docker-compose-letsencrypt-nginx-proxy-companion" +frappe_docker_url="https://github.com/frappe/frappe_docker" +env_file="$__dir/.env" + + +check_root() { + if [[ $EUID -ne 0 ]]; then + echo "This script must be run as root. Login as root or use sudo." 1>&2 + exit 1 + fi +} + +check_git() { + if [ ! -x "$(command -v git)" ]; then + echo "Git is not installed. Please install git before continuing." + exit 1 + fi +} + +check_docker() { + if [ ! -x "$(command -v docker)" ]; then + read -rp "No docker installation found. Press Enter to install docker or ctrl+c to exit." + curl -fsSL https://get.docker.com | sh + fi + if [ ! -x "$(command -v docker)" ]; then + echo "Docker installation failed. Exiting." + exit 1 + fi +} + +check_env() { + if [ ! -f "$env_file" ]; then + echo "No environment file found. This file is required for setting up Frappe/ERPNext Docker." + echo "Would you like to fetch the default environment file?" + echo "(NOTE: You will be prompted to set it up later)" + read -rp "Press Enter to fetch the configuration file, or create a .env file and re-run the script." + curl -fsSL "$env_url" -o "$env_file" + fi +} + +clone_repository() { + echo "Cloning Repository: $1" + git clone "$2" +} + +get_config() { + if [ -n "$2" ]; then + config_file="$2" + else + config_file="$env_file" + fi + line=$(grep -E "^$=" "$config_file") + line_result=$(echo "$line" | awk -F"=" '{print $2}') +} + +get_install_version() { + echo "Choose a version you would like to setup [current: $1]:" + echo "1. develop (edge)" + echo "2. version-12" + echo "3. version-11" + echo "Please enter your choice [1-3]: " + select choice in "1" "2" "3"; do + case $choice in + 1 ) version="edge" ;; + 2 ) version="version-12" ;; + 3 ) version="version-11" ;; + esac + done +} + +prompt_config() { + # inspired by discourse_docker + get_config "VERSION" + local install_version=$line_result + get_config "MYSQL_ROOT_PASSWORD" + local mysql_password=$line_result + get_config "SITES" + local sites=$line_result + get_config "LETSENCRYPT_EMAIL" + local letsencrypt_email=$line_result + + echo "Would you like to setup networking for docker? [y/n]" + echo "This is required if you wish to access the instance from other machines." + select choice in "y" "n"; do + case $choice in + y ) setup_networking=1 ;; + n ) setup_networking=0 + setup_letsencrypt=0 ;; + esac + done + if [ -n "$letsencrypt_email" ] & [ "$setup_networking" -ne "0" ]; then + echo "Would you like to setup LetsEncrypt? [y/n]" + select choice in "y" "n"; do + case $choice in + y ) setup_letsencrypt=1 + echo "Please ensure that all the required domains point to this IP address." + read -rp "Enter an Email Address to setup LetsEncrypt with: " letsencrypt_email ;; + n ) setup_letsencrypt=0 + echo "Skipping LetsEncrypt Setup." ;; + esac + done + fi + + local new_value="" + local config_state="n" + + echo + + get_install_version "$install_version" + install_version="$version" + + while [ "$config_state" = "n" ]; do + if [ -n "$mysql_password" ]; then + read -srp "Enter MySQL Password [$mysql_password]: " new_value + if [ -n "$new_value" ]; then + mysql_password="$new_value" + fi + fi + + if [ -n "$sites" ]; then + read -rp "Enter sitename to setup [$sites]: " new_value + if [ -n "$new_value" ]; then + sites="$new_value" + fi + fi + + if [ "$setup_letsencrypt" -ne "0" ]; then + read -rp "Enter email address for LetsEncrypt [$letsencrypt_email]: " new_value + if [ -n "$new_value" ]; then + letsencrypt_email=$new_value + fi + fi + + echo "Current Configuration:" + echo "Version: $([ "$install_version" = "edge" ] && echo "develop" || echo "$install_version")" + echo "MySQL Root Password: $mysql_password" + echo "Sites: $sites" + + if [ "$setup_letsencrypt" -ne "0" ]; then + echo "LetsEncrypt Email Address: $letsencrypt_email" + fi + + echo + echo "Does this configuration look okay?" + read -rp "Press Enter to continue, 'n' to try again, or ctrl+c to exit: " config_state + done + + echo "Saving the current configuration file to $env_file" + + cat << EOF > "$env_file" +VERSION=$install_version +MYSQL_ROOT_PASSWORD=$mysql_password +SITES=$sites +$([ "$setup_letsencrypt" -ne "0" ] && echo "LETSENCRYPT_EMAIL=$letsencrypt_email") +EOF + setup_configuration=$(<"$env_file") +} + +setup_user() { + echo "The rest of the setup requires a user account." + echo "You may use an existing account, or set up a new one right away." + read -rp "Enter username: " username + if grep -E "^$username" /etc/passwd > /dev/null; then + echo "User $username already exists." + else + read -rsp "Enter password: " password + password="$(perl -e 'print crypt($ARGV[0], "password")' "$password")" + if useradd -m -p "$password" "$username" -s "$(command -v bash)"; then + echo "User $username has been added to the system." + else + echo "Failed to add user to the system." + echo "Please add a user manually and re-run the script." + exit 1 + fi + fi + + if ! getent group docker > /dev/null 2>&1 ; then + echo "Creating group: docker" + groupadd docker + fi + echo "Adding user $username to group: docker" + usermod -aG docker "$username" + newgrp docker +} + +install() { + if [ "$setup_letsencrypt" -ne "0" ] & [ "$setup_networking" -ne "0" ]; then + echo "Setting up NGINX Proxy for LetsEncrypt" + clone_repository "Docker Compose LetsEncrypt NGINX Proxy Companion" "$docker_nginx_url" + cd "$(basename "$docker_nginx_url")" + if [ -f .env.sample ]; then + cp .env.sample env + fi + ./start.sh > /dev/null 2>&1 + cd "$(eval echo ~"$username")" + fi + + echo "Setting up Frappe/ERPNext" + clone_repository "Frappe/ERPNext Docker" "$frappe_docker_url" + cd "$(basename "$frappe_docker_url")" + echo "$setup_configuration" > .env + echo "Enter a name for the project." + read -rp "This project name will be used to setup the docker instance: [erpnext_docker]" project_name + if [ -z "$project_name" ]; then + echo "Setting the project name to erpnext_docker" + project_name="erpnext_docker" + fi + + docker-compose \ + --project-name "$project_name" \ + --project-directory . up -d \ + -f installation/docker-compose-frappe.yml \ + -f installation/docker-compose-erpnext.yml \ + -f installation/docker-compose-common.yml \ + "$( (( setup_networking == 1 )) && printf %s '-f installation/docker-compose-networks.yml' )" + + get_config "SITES" "$(pwd)/.env" + local sites=$line_result + + docker exec \ + -e "SITE_NAME=$sites" \ + -e "INSTALL_ERPNEXT=1" \ + -it "$project_name"_erpnext-python_1 docker-entrypoint.sh new + + echo "Installation Complete!" +} + +check_root +check_git +check_docker +check_env + +prompt_config +setup_user + +su - "$username" << EOF +install +EOF From 84d53bfcba001b5f772c391e92c7059d1c843d4c Mon Sep 17 00:00:00 2001 From: chabad360 Date: Tue, 3 Mar 2020 05:03:13 +0000 Subject: [PATCH 02/65] convert edge build to travis.sh --- .travis.yml | 36 ++++++++----------------- travis.sh | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+), 25 deletions(-) create mode 100755 travis.sh diff --git a/.travis.yml b/.travis.yml index 8158bb93..18c0d604 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,7 @@ before_install: - if [[ $BUILD == "development" ]];then sudo apt-get update && sudo apt-get -y install docker-compose; fi + - chmod u+x ./travis.sh after_success: - docker --version @@ -22,43 +23,28 @@ matrix: - name: "Build Frappe python environment (edge)" if: branch = develop AND type != pull_request script: - - docker build -t frappe-worker -f build/frappe-worker/Dockerfile . - - docker tag frappe-worker frappe/frappe-worker:edge - - docker tag frappe-worker frappe/frappe-worker:develop - - docker push frappe/frappe-worker:edge - - docker push frappe/frappe-worker:develop + - ./travis.sh --worker --tag edge --name frappe + - ./travis.sh --worker --tag develop --name frappe --tag-only - name: "Build Frappe nginx + static assets (edge)" if: branch = develop AND type != pull_request script: - - docker build -t frappe-assets -f build/frappe-assets/Dockerfile . - - docker tag frappe-assets frappe/frappe-assets:edge - - docker tag frappe-assets frappe/frappe-assets:develop - - docker push frappe/frappe-assets:edge - - docker push frappe/frappe-assets:develop + - ./travis.sh --assets --tag edge --name frappe + - ./travis.sh --assets --tag develop --name frappe --tag-only - name: "Build ERPNext python environment (edge)" if: branch = develop AND type != pull_request script: - - docker build -t erpnext-worker -f build/erpnext-worker/Dockerfile . - - docker tag erpnext-worker frappe/erpnext-worker:edge - - docker tag erpnext-worker frappe/erpnext-worker:develop - - docker push frappe/erpnext-worker:edge - - docker push frappe/erpnext-worker:develop + - ./travis.sh --worker --tag edge --name erpnext + - ./travis.sh --worker --tag develop --name erpnext --tag-only - name: "Build ERPNext nginx + static assets (edge)" if: branch = develop AND type != pull_request script: - - docker build -t erpnext-assets -f build/erpnext-assets/Dockerfile . - - docker tag erpnext-assets frappe/erpnext-assets:edge - - docker tag erpnext-assets frappe/erpnext-assets:develop - - docker push frappe/erpnext-assets:edge - - docker push frappe/erpnext-assets:develop + - ./travis.sh --assets --tag edge --name erpnext + - ./travis.sh --assets --tag develop --name erpnext --tag-only - name: "Build Frappe socketio service (edge)" if: branch = develop AND type != pull_request script: - - docker build -t frappe-socketio -f build/frappe-socketio/Dockerfile . - - docker tag frappe-socketio frappe/frappe-socketio:edge - - docker tag frappe-socketio frappe/frappe-socketio:develop - - docker push frappe/frappe-socketio:edge - - docker push frappe/frappe-socketio:develop + - ./travis.sh --socketio --tag edge --name frappe + - ./travis.sh --socketio --tag develop --name frappe --tag-only - name: "Build Frappe python environment (v12)" if: branch = master AND type != pull_request script: diff --git a/travis.sh b/travis.sh new file mode 100755 index 00000000..dc813fbf --- /dev/null +++ b/travis.sh @@ -0,0 +1,75 @@ +#!/bin/bash + +################# travis.sh ################# +# This script takes care of the common steps +# found in the Travis CI builds. + +POSITIONAL=() +while [[ $# -gt 0 ]]; do + key="$1" + + case $key in + -t|--tag) + TAG="$2" + shift + shift + ;; + -w|--worker) + WORKER=1 + shift + ;; + -a|--assets) + ASSETS=1 + shift + ;; + -s|--socketio) + SOCKETIO=1 + shift + ;; + -n|--name) + NAME="$2" + shift + shift + ;; + -o|--tag-only) + TAGONLY=1 + shift + ;; + *) # unknown option + POSITIONAL+=("$1") # save it in an array for later + shift # past argument + ;; + esac +done + +function tagAndPush() { + echo "Tagging ${1} as \"${2}\" and pushing" + docker tag ${1} frappe/${1}:${2} + docker push frappe/${1}:${2} +} + +function build () { + echo "Building ${1} ${3} image" + docker build -t ${1}-${3} -f build/${1}-worker/Dockerfile . + tagAndPush "${1}-${3}" ${2} +} + +if [[ $WORKER ]]; then + if [[ $TAGONLY ]]; then + tagAndPush "${NAME}-worker" ${TAG} + else + build $NAME $TAG worker + fi +elif [[ $ASSETS ]]; then + if [[ $TAGONLY ]]; then + tagAndPush "${NAME}-assets" ${TAG} + else + build $NAME $TAG assets + fi +elif [[ $SOCKETIO ]]; then + if [[ $TAGONLY ]]; then + tagAndPush "${NAME}-socketio" ${TAG} + else + build $NAME $TAG socketio + fi +fi \ No newline at end of file From ca715e3e5cde352435a29c3b5da1a95e37ad3568 Mon Sep 17 00:00:00 2001 From: chabad360 Date: Tue, 3 Mar 2020 05:27:18 +0000 Subject: [PATCH 03/65] add versioning support to travis.sh --- .travis.yml | 140 +++++++++++----------------------------------------- travis.sh | 36 ++++++++++---- 2 files changed, 56 insertions(+), 120 deletions(-) diff --git a/.travis.yml b/.travis.yml index 18c0d604..64d829bd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -48,140 +48,60 @@ matrix: - name: "Build Frappe python environment (v12)" if: branch = master AND type != pull_request script: - - git clone https://github.com/frappe/frappe --branch version-12 - - cd frappe - - git fetch --tags - - export VERSION=$(git tag --list --sort=-version:refname "v12*" | sed -n 1p | sed -e 's#.*@\(\)#\1#') - - cd .. - - docker build -t frappe/frappe-worker:$VERSION -f build/frappe-worker/v12.Dockerfile . - - docker tag frappe/frappe-worker:$VERSION frappe/frappe-worker:version-12 - - docker tag frappe/frappe-worker:$VERSION frappe/frappe-worker:v12 - - docker push frappe/frappe-worker:$VERSION - - docker push frappe/frappe-worker:version-12 - - docker push frappe/frappe-worker:v12 + - ./travis.sh --worker --git-branch 12 --name frappe + - ./travis.sh --worker --tag v12 --name frappe --tag-only + - ./travis.sh --worker --tag version-12 --name frappe --tag-only - name: "Build Frappe nginx + static assets (v12)" if: branch = master AND type != pull_request script: - - git clone https://github.com/frappe/frappe --branch version-12 - - cd frappe - - git fetch --tags - - export VERSION=$(git tag --list --sort=-version:refname "v12*" | sed -n 1p | sed -e 's#.*@\(\)#\1#') - - cd .. - - docker build -t frappe/frappe-assets:$VERSION -f build/frappe-assets/v12.Dockerfile . - - docker tag frappe/frappe-assets:$VERSION frappe/frappe-assets:version-12 - - docker tag frappe/frappe-assets:$VERSION frappe/frappe-assets:v12 - - docker push frappe/frappe-assets:$VERSION - - docker push frappe/frappe-assets:version-12 - - docker push frappe/frappe-assets:v12 + - ./travis.sh --assets --git-branch 12 --name frappe + - ./travis.sh --assets --tag v12 --name frappe --tag-only + - ./travis.sh --assets --tag version-12 --name frappe --tag-only - name: "Build ERPNext python environment (v12)" if: branch = master AND type != pull_request script: - - git clone https://github.com/frappe/erpnext --branch version-12 - - cd erpnext - - git fetch --tags - - export VERSION=$(git tag --list --sort=-version:refname "v12*" | sed -n 1p | sed -e 's#.*@\(\)#\1#') - - cd .. - - docker build -t frappe/erpnext-worker:$VERSION -f build/erpnext-worker/v12.Dockerfile . - - docker tag frappe/erpnext-worker:$VERSION frappe/erpnext-worker:version-12 - - docker tag frappe/erpnext-worker:$VERSION frappe/erpnext-worker:v12 - - docker push frappe/erpnext-worker:$VERSION - - docker push frappe/erpnext-worker:version-12 - - docker push frappe/erpnext-worker:v12 + - ./travis.sh --worker --git-branch 12 --name erpnext + - ./travis.sh --worker --tag v12 --name erpnext --tag-only + - ./travis.sh --worker --tag version-12 --name erpnext --tag-only - name: "Build ERPNext nginx + static assets (v12)" if: branch = master AND type != pull_request script: - - git clone https://github.com/frappe/erpnext --branch version-12 - - cd erpnext - - git fetch --tags - - export VERSION=$(git tag --list --sort=-version:refname "v12*" | sed -n 1p | sed -e 's#.*@\(\)#\1#') - - cd .. - - docker build -t frappe/erpnext-assets:$VERSION -f build/erpnext-assets/v12.Dockerfile . - - docker tag frappe/erpnext-assets:$VERSION frappe/erpnext-assets:version-12 - - docker tag frappe/erpnext-assets:$VERSION frappe/erpnext-assets:v12 - - docker push frappe/erpnext-assets:$VERSION - - docker push frappe/erpnext-assets:version-12 - - docker push frappe/erpnext-assets:v12 + - ./travis.sh --assets --git-branch 12 --name erpnext + - ./travis.sh --assets --tag v12 --name erpnext --tag-only + - ./travis.sh --assets --tag version-12 --name erpnext --tag-only - name: "Build Frappe socketio service (v12)" if: branch = master AND type != pull_request script: - - git clone https://github.com/frappe/frappe --branch version-12 - - cd frappe - - git fetch --tags - - export VERSION=$(git tag --list --sort=-version:refname "v12*" | sed -n 1p | sed -e 's#.*@\(\)#\1#') - - cd .. - - docker build -t frappe/frappe-socketio:$VERSION -f build/frappe-socketio/v12.Dockerfile . - - docker tag frappe/frappe-socketio:$VERSION frappe/frappe-socketio:version-12 - - docker tag frappe/frappe-socketio:$VERSION frappe/frappe-socketio:v12 - - docker push frappe/frappe-socketio:$VERSION - - docker push frappe/frappe-socketio:version-12 - - docker push frappe/frappe-socketio:v12 + - ./travis.sh --socketio --git-branch 12 --name frappe + - ./travis.sh --socketio --tag v12 --name frappe --tag-only + - ./travis.sh --socketio --tag version-12 --name frappe --tag-only - name: "Build Frappe python environment (v11)" if: branch = master AND type != pull_request script: - - git clone https://github.com/frappe/frappe --branch version-11 - - cd frappe - - git fetch --tags - - export VERSION=$(git tag --list --sort=-version:refname "v11*" | sed -n 1p | sed -e 's#.*@\(\)#\1#') - - cd .. - - docker build -t frappe/frappe-worker:$VERSION -f build/frappe-worker/v11.Dockerfile . - - docker tag frappe/frappe-worker:$VERSION frappe/frappe-worker:version-11 - - docker tag frappe/frappe-worker:$VERSION frappe/frappe-worker:v11 - - docker push frappe/frappe-worker:$VERSION - - docker push frappe/frappe-worker:version-11 - - docker push frappe/frappe-worker:v11 + - ./travis.sh --worker --git-branch 11 --name frappe + - ./travis.sh --worker --tag v11 --name frappe --tag-only + - ./travis.sh --worker --tag version-11 --name frappe --tag-only - name: "Build Frappe nginx + static assets (v11)" if: branch = master AND type != pull_request script: - - git clone https://github.com/frappe/frappe --branch version-11 - - cd frappe - - git fetch --tags - - export VERSION=$(git tag --list --sort=-version:refname "v11*" | sed -n 1p | sed -e 's#.*@\(\)#\1#') - - cd .. - - docker build -t frappe/frappe-assets:$VERSION -f build/frappe-assets/v11.Dockerfile . - - docker tag frappe/frappe-assets:$VERSION frappe/frappe-assets:version-11 - - docker tag frappe/frappe-assets:$VERSION frappe/frappe-assets:v11 - - docker push frappe/frappe-assets:$VERSION - - docker push frappe/frappe-assets:version-11 - - docker push frappe/frappe-assets:v11 + - ./travis.sh --assets --git-branch 11 --name frappe + - ./travis.sh --assets --tag v11 --name frappe --tag-only + - ./travis.sh --assets --tag version-11 --name frappe --tag-only - name: "Build ERPNext python environment (v11)" if: branch = master AND type != pull_request script: - - git clone https://github.com/frappe/erpnext --branch version-11 - - cd erpnext - - git fetch --tags - - export VERSION=$(git tag --list --sort=-version:refname "v11*" | sed -n 1p | sed -e 's#.*@\(\)#\1#') - - cd .. - - docker build -t frappe/erpnext-worker:$VERSION -f build/erpnext-worker/v11.Dockerfile . - - docker tag frappe/erpnext-worker:$VERSION frappe/erpnext-worker:version-11 - - docker tag frappe/erpnext-worker:$VERSION frappe/erpnext-worker:v11 - - docker push frappe/erpnext-worker:$VERSION - - docker push frappe/erpnext-worker:version-11 - - docker push frappe/erpnext-worker:v11 + - ./travis.sh --worker --git-branch 11 --name erpnext + - ./travis.sh --worker --tag v11 --name erpnext --tag-only + - ./travis.sh --worker --tag version-11 --name erpnext --tag-only - name: "Build ERPNext nginx + static assets (v11)" if: branch = master AND type != pull_request script: - - git clone https://github.com/frappe/erpnext --branch version-11 - - cd erpnext - - git fetch --tags - - export VERSION=$(git tag --list --sort=-version:refname "v11*" | sed -n 1p | sed -e 's#.*@\(\)#\1#') - - cd .. - - docker build -t frappe/erpnext-assets:$VERSION -f build/erpnext-assets/v11.Dockerfile . - - docker tag frappe/erpnext-assets:$VERSION frappe/erpnext-assets:version-11 - - docker tag frappe/erpnext-assets:$VERSION frappe/erpnext-assets:v11 - - docker push frappe/erpnext-assets:$VERSION - - docker push frappe/erpnext-assets:version-11 - - docker push frappe/erpnext-assets:v11 + - ./travis.sh --assets --git-branch 11 --name erpnext + - ./travis.sh --assets --tag v11 --name erpnext --tag-only + - ./travis.sh --assets --tag version-11 --name erpnext --tag-only - name: "Build Frappe socketio service (v11)" if: branch = master AND type != pull_request script: - - git clone https://github.com/frappe/frappe --branch version-11 - - cd frappe - - git fetch --tags - - export VERSION=$(git tag --list --sort=-version:refname "v11*" | sed -n 1p | sed -e 's#.*@\(\)#\1#') - - cd .. - - docker build -t frappe/frappe-socketio:$VERSION -f build/frappe-socketio/v11.Dockerfile . - - docker tag frappe/frappe-socketio:$VERSION frappe/frappe-socketio:version-11 - - docker tag frappe/frappe-socketio:$VERSION frappe/frappe-socketio:v11 - - docker push frappe/frappe-socketio:$VERSION - - docker push frappe/frappe-socketio:version-11 - - docker push frappe/frappe-socketio:v11 + - ./travis.sh --socketio --git-branch 11 --name erpnext + - ./travis.sh --socketio --tag v11 --name erpnext --tag-only + - ./travis.sh --socketio --tag version-11 --name erpnext --tag-only diff --git a/travis.sh b/travis.sh index dc813fbf..e375abec 100755 --- a/travis.sh +++ b/travis.sh @@ -4,7 +4,6 @@ # This script takes care of the common steps # found in the Travis CI builds. -POSITIONAL=() while [[ $# -gt 0 ]]; do key="$1" @@ -35,13 +34,24 @@ while [[ $# -gt 0 ]]; do TAGONLY=1 shift ;; - *) # unknown option - POSITIONAL+=("$1") # save it in an array for later - shift # past argument + -g|--git-branch) + BRANCH="$2" + shift + shift ;; esac done +function gitVersion() { + echo "Pulling ${1} v${2}" + git clone https://github.com/frappe/${1} --branch version-${2} + cd ${1} + git fetch --tags + TAG=$(git tag --list --sort=-version:refname "v${2}*" | sed -n 1p | sed -e 's#.*@\(\)#\1#') + cd .. + DOCKERFILE="v${2}.Dockerfile" +} + function tagAndPush() { echo "Tagging ${1} as \"${2}\" and pushing" docker tag ${1} frappe/${1}:${2} @@ -49,27 +59,33 @@ function tagAndPush() { } function build () { - echo "Building ${1} ${3} image" - docker build -t ${1}-${3} -f build/${1}-worker/Dockerfile . + echo "Building ${1} ${3} image using ${4}" + docker build -t ${1}-${3} -f build/${1}-${3}/${4:-Dockerfile} . tagAndPush "${1}-${3}" ${2} } +if [[ $BRANCH ]]; then + gitVersion $NAME $BRANCH +fi + +DOCKERFILE=${DOCKERFILE:-Dockerfile} + if [[ $WORKER ]]; then if [[ $TAGONLY ]]; then - tagAndPush "${NAME}-worker" ${TAG} + tagAndPush "${NAME}-worker" ${TAG} else - build $NAME $TAG worker + build $NAME $TAG worker ${DOCKERFILE} fi elif [[ $ASSETS ]]; then if [[ $TAGONLY ]]; then tagAndPush "${NAME}-assets" ${TAG} else - build $NAME $TAG assets + build $NAME $TAG assets ${DOCKERFILE} fi elif [[ $SOCKETIO ]]; then if [[ $TAGONLY ]]; then tagAndPush "${NAME}-socketio" ${TAG} else - build $NAME $TAG socketio + build $NAME $TAG socketio ${DOCKERFILE} fi fi \ No newline at end of file From 37eabd9018c7d7bad5c2535be816a10f415e4f58 Mon Sep 17 00:00:00 2001 From: chabad360 Date: Tue, 3 Mar 2020 05:56:14 +0000 Subject: [PATCH 04/65] add a help file and alphabetize --- travis.sh | 119 ++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 89 insertions(+), 30 deletions(-) diff --git a/travis.sh b/travis.sh index e375abec..58943b87 100755 --- a/travis.sh +++ b/travis.sh @@ -1,13 +1,61 @@ #!/bin/bash -################# travis.sh ################# +################# ./travis.sh ################# # This script takes care of the common steps -# found in the Travis CI builds. +# found in the frappe_docker Travis CI builds. +# +# Usage: [-a | -s | -w | -h] [-n ] [-t | -g ] [-o] +# +# Argumets: +# +# -a | --assets (exclusive): Build the nginx + static assets image +# -s | --socketio (exclusive): Build the frappe-socketio image +# -w | --worker (exclusive): Build the python environment image +# -h | --help (exclusive): Print this page +# +# -n | --service : Name of the service to build: "erpnext" or "frappe" +# Note: --socketio does not respect this argument +# Note: This will build an image with the name "$SERVICE-assets" (i.e. "erpnext-worker", "frappe-assets", etc.) +# +# -t | --tag (exclusive): The image tag (i.e. erpnext-worker:$TAG ) +# -g | --git-version (exclusive): The version number of --service (i.e. "11", "12", etc.) +# Note: This must be a number, not a string! +# +# -o | --tag-only: Only tag an image and push it. +# +# + while [[ $# -gt 0 ]]; do key="$1" case $key in + -a|--assets) + ASSETS=1 + shift + ;; + -g|--git-version) + version="$2" + shift + shift + ;; + -h|--help) + HELP=1 + shift + ;; + -n|--service) + SERVICE="$2" + shift + shift + ;; + -o|--tag-only) + TAGONLY=1 + shift + ;; + -s|--socketio) + SOCKETIO=1 + shift + ;; -t|--tag) TAG="$2" shift @@ -17,31 +65,37 @@ while [[ $# -gt 0 ]]; do WORKER=1 shift ;; - -a|--assets) - ASSETS=1 - shift - ;; - -s|--socketio) - SOCKETIO=1 - shift - ;; - -n|--name) - NAME="$2" + *) + HELP=1 shift - shift - ;; - -o|--tag-only) - TAGONLY=1 - shift - ;; - -g|--git-branch) - BRANCH="$2" - shift - shift ;; esac done +function help() { + echo "################ $0 #################" + echo " This script takes care of the common steps found in the frappe_docker Travis CI builds." + echo "" + echo " Usage: [-a | -s | -w | -h] [-n ] [-t | -g ] [-o]" + echo "" + echo " Argumets:" + echo "" + echo " -a | --assets (exclusive): Build the nginx + static assets image" + echo " -s | --socketio (exclusive): Build the frappe-socketio image" + echo " -w | --worker (exclusive): Build the python environment image" + echo " -h | --help (exclusive): Print this page" + echo "" + echo " -n | --service : Name of the service to build: \"erpnext\" or \"frappe\"" + echo " Note: --socketio does not respect this argument" + echo " Note: This will build an image with the name \"\$SERVICE-assets\" (i.e. \"erpnext-worker\", \"frappe-assets\", etc.)" + echo "" + echo " -t | --tag (exclusive): The image tag (i.e. erpnext-worker:\$TAG)" + echo " -g | --git-version (exclusive): The version number of --service (i.e. \"11\", \"12\", etc.)" + echo " Note: This must be a number, not a string!" + echo "" + echo " -o | --tag-only: Only tag an image and push it." +} + function gitVersion() { echo "Pulling ${1} v${2}" git clone https://github.com/frappe/${1} --branch version-${2} @@ -64,28 +118,33 @@ function build () { tagAndPush "${1}-${3}" ${2} } -if [[ $BRANCH ]]; then - gitVersion $NAME $BRANCH +if [[ HELP ]]; then + help + exit 1 +fi + +if [[ $VERSION ]]; then + gitVersion $SERVICE $VERSION fi DOCKERFILE=${DOCKERFILE:-Dockerfile} if [[ $WORKER ]]; then if [[ $TAGONLY ]]; then - tagAndPush "${NAME}-worker" ${TAG} + tagAndPush "${SERVICE}-worker" ${TAG} else - build $NAME $TAG worker ${DOCKERFILE} + build $SERVICE $TAG worker ${DOCKERFILE} fi elif [[ $ASSETS ]]; then if [[ $TAGONLY ]]; then - tagAndPush "${NAME}-assets" ${TAG} + tagAndPush "${SERVICE}-assets" ${TAG} else - build $NAME $TAG assets ${DOCKERFILE} + build $SERVICE $TAG assets ${DOCKERFILE} fi elif [[ $SOCKETIO ]]; then if [[ $TAGONLY ]]; then - tagAndPush "${NAME}-socketio" ${TAG} + tagAndPush "frappe-socketio" ${TAG} else - build $NAME $TAG socketio ${DOCKERFILE} + build frappe $TAG socketio ${DOCKERFILE} fi fi \ No newline at end of file From 77aca4d3cc627dff3f536cebbfc9c309072c4621 Mon Sep 17 00:00:00 2001 From: chabad360 Date: Tue, 3 Mar 2020 06:04:17 +0000 Subject: [PATCH 05/65] organize travis.yml a bit --- .travis.yml | 112 ++++++++++++++++++++++++++-------------------------- 1 file changed, 57 insertions(+), 55 deletions(-) diff --git a/.travis.yml b/.travis.yml index 64d829bd..0440e032 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,85 +23,87 @@ matrix: - name: "Build Frappe python environment (edge)" if: branch = develop AND type != pull_request script: - - ./travis.sh --worker --tag edge --name frappe - - ./travis.sh --worker --tag develop --name frappe --tag-only + - ./travis.sh --worker --service frappe --tag edge + - ./travis.sh --worker --service frappe --tag develop --tag-only - name: "Build Frappe nginx + static assets (edge)" if: branch = develop AND type != pull_request script: - - ./travis.sh --assets --tag edge --name frappe - - ./travis.sh --assets --tag develop --name frappe --tag-only + - ./travis.sh --assets --service frappe --tag edge + - ./travis.sh --assets --service frappe --tag develop--tag-only - name: "Build ERPNext python environment (edge)" if: branch = develop AND type != pull_request script: - - ./travis.sh --worker --tag edge --name erpnext - - ./travis.sh --worker --tag develop --name erpnext --tag-only + - ./travis.sh --worker --service erpnext --tag edge + - ./travis.sh --worker --service erpnext --tag develop --tag-only - name: "Build ERPNext nginx + static assets (edge)" if: branch = develop AND type != pull_request script: - - ./travis.sh --assets --tag edge --name erpnext - - ./travis.sh --assets --tag develop --name erpnext --tag-only + - ./travis.sh --assets --service erpnext --tag edge + - ./travis.sh --assets --service erpnext --tag develop --tag-only - name: "Build Frappe socketio service (edge)" if: branch = develop AND type != pull_request script: - - ./travis.sh --socketio --tag edge --name frappe - - ./travis.sh --socketio --tag develop --name frappe --tag-only + - ./travis.sh --socketio --service frappe --tag edge + - ./travis.sh --socketio --service frappe --tag develop --tag-only - name: "Build Frappe python environment (v12)" if: branch = master AND type != pull_request script: - - ./travis.sh --worker --git-branch 12 --name frappe - - ./travis.sh --worker --tag v12 --name frappe --tag-only - - ./travis.sh --worker --tag version-12 --name frappe --tag-only + - ./travis.sh --worker --service frappe --git-branch 12 + - ./travis.sh --worker --service frappe --tag v12 --tag-only + - ./travis.sh --worker --service frappe --tag version-12 --tag-only - name: "Build Frappe nginx + static assets (v12)" if: branch = master AND type != pull_request script: - - ./travis.sh --assets --git-branch 12 --name frappe - - ./travis.sh --assets --tag v12 --name frappe --tag-only - - ./travis.sh --assets --tag version-12 --name frappe --tag-only + - ./travis.sh --assets --service frappe --git-branch 12 + - ./travis.sh --assets --service frappe --tag v12 --tag-only + - ./travis.sh --assets --service frappe --tag version-12 --tag-only - name: "Build ERPNext python environment (v12)" if: branch = master AND type != pull_request script: - - ./travis.sh --worker --git-branch 12 --name erpnext - - ./travis.sh --worker --tag v12 --name erpnext --tag-only - - ./travis.sh --worker --tag version-12 --name erpnext --tag-only + - ./travis.sh --worker --service erpnext --git-branch 12 + - ./travis.sh --worker --service erpnext --tag v12 --tag-only + - ./travis.sh --worker --service erpnext --tag version-12 --tag-only - name: "Build ERPNext nginx + static assets (v12)" if: branch = master AND type != pull_request script: - - ./travis.sh --assets --git-branch 12 --name erpnext - - ./travis.sh --assets --tag v12 --name erpnext --tag-only - - ./travis.sh --assets --tag version-12 --name erpnext --tag-only - - name: "Build Frappe socketio service (v12)" - if: branch = master AND type != pull_request - script: - - ./travis.sh --socketio --git-branch 12 --name frappe - - ./travis.sh --socketio --tag v12 --name frappe --tag-only - - ./travis.sh --socketio --tag version-12 --name frappe --tag-only - - name: "Build Frappe python environment (v11)" - if: branch = master AND type != pull_request - script: - - ./travis.sh --worker --git-branch 11 --name frappe - - ./travis.sh --worker --tag v11 --name frappe --tag-only - - ./travis.sh --worker --tag version-11 --name frappe --tag-only - - name: "Build Frappe nginx + static assets (v11)" - if: branch = master AND type != pull_request - script: - - ./travis.sh --assets --git-branch 11 --name frappe - - ./travis.sh --assets --tag v11 --name frappe --tag-only - - ./travis.sh --assets --tag version-11 --name frappe --tag-only - - name: "Build ERPNext python environment (v11)" - if: branch = master AND type != pull_request - script: - - ./travis.sh --worker --git-branch 11 --name erpnext - - ./travis.sh --worker --tag v11 --name erpnext --tag-only - - ./travis.sh --worker --tag version-11 --name erpnext --tag-only - - name: "Build ERPNext nginx + static assets (v11)" - if: branch = master AND type != pull_request - script: - - ./travis.sh --assets --git-branch 11 --name erpnext - - ./travis.sh --assets --tag v11 --name erpnext --tag-only - - ./travis.sh --assets --tag version-11 --name erpnext --tag-only + - ./travis.sh --assets --service erpnext--git-branch 12 + - ./travis.sh --assets --service erpnext --tag v12 --tag-only + - ./travis.sh --assets --service erpnext --tag version-12 --tag-only - name: "Build Frappe socketio service (v11)" if: branch = master AND type != pull_request script: - - ./travis.sh --socketio --git-branch 11 --name erpnext - - ./travis.sh --socketio --tag v11 --name erpnext --tag-only - - ./travis.sh --socketio --tag version-11 --name erpnext --tag-only + - ./travis.sh --socketio --service frappe --git-branch 11 + - ./travis.sh --socketio --service frappe --tag v11 --tag-only + - ./travis.sh --socketio --service frappe --tag version-11 --tag-only + - name: "Build Frappe python environment (v11)" + if: branch = master AND type != pull_request + script: + - ./travis.sh --worker --service frappe --git-branch 11 + - ./travis.sh --worker --service frappe --tag v11 --tag-only + - ./travis.sh --worker --service frappe --tag version-11 --tag-only + - name: "Build Frappe nginx + static assets (v11)" + if: branch = master AND type != pull_request + script: + - ./travis.sh --assets --service frappe --git-branch 11 + - ./travis.sh --assets --service frappe --tag v11 --tag-only + - ./travis.sh --assets --service frappe --tag version-11 --tag-only + - name: "Build ERPNext python environment (v11)" + if: branch = master AND type != pull_request + script: + - ./travis.sh --worker --service erpnext --git-branch 11 + - ./travis.sh --worker --service erpnext --tag v11 --tag-only + - ./travis.sh --worker --service erpnext --tag version-11 --tag-only + - name: "Build ERPNext nginx + static assets (v11)" + if: branch = master AND type != pull_request + script: + - ./travis.sh --assets --service erpnext--git-branch 11 + - ./travis.sh --assets --service erpnext --tag v11 --tag-only + - ./travis.sh --assets --service erpnext --tag version-11 --tag-only + - name: "Build Frappe socketio service (v11)" + if: branch = master AND type != pull_request + script: + - ./travis.sh --socketio --service frappe --git-branch 11 + - ./travis.sh --socketio --service frappe --tag v11 --tag-only + - ./travis.sh --socketio --service frappe --tag version-11 --tag-only + + \ No newline at end of file From 6f7a9b92ac382a7588f8e72beb94014e59967d62 Mon Sep 17 00:00:00 2001 From: Davide Bortolami Date: Tue, 3 Mar 2020 23:40:11 +0000 Subject: [PATCH 06/65] Refactor renaming erpnext-assets and frappe-assets to erpnext-nginx and frappe-nginx --- .travis.yml | 68 +++++++++---------- .../Dockerfile | 2 +- .../docker-entrypoint.sh | 0 .../v11.Dockerfile | 2 +- .../v12.Dockerfile | 2 +- .../Dockerfile | 2 +- .../docker-entrypoint.sh | 0 .../v11.Dockerfile | 2 +- .../v12.Dockerfile | 2 +- installation/docker-compose-erpnext.yml | 4 +- installation/docker-compose-frappe.yml | 4 +- 11 files changed, 44 insertions(+), 44 deletions(-) rename build/{erpnext-assets => erpnext-nginx}/Dockerfile (96%) rename build/{erpnext-assets => erpnext-nginx}/docker-entrypoint.sh (100%) rename build/{erpnext-assets => erpnext-nginx}/v11.Dockerfile (96%) rename build/{erpnext-assets => erpnext-nginx}/v12.Dockerfile (96%) rename build/{frappe-assets => frappe-nginx}/Dockerfile (96%) rename build/{frappe-assets => frappe-nginx}/docker-entrypoint.sh (100%) rename build/{frappe-assets => frappe-nginx}/v11.Dockerfile (96%) rename build/{frappe-assets => frappe-nginx}/v12.Dockerfile (96%) diff --git a/.travis.yml b/.travis.yml index 8158bb93..9aed1347 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,11 +30,11 @@ matrix: - name: "Build Frappe nginx + static assets (edge)" if: branch = develop AND type != pull_request script: - - docker build -t frappe-assets -f build/frappe-assets/Dockerfile . - - docker tag frappe-assets frappe/frappe-assets:edge - - docker tag frappe-assets frappe/frappe-assets:develop - - docker push frappe/frappe-assets:edge - - docker push frappe/frappe-assets:develop + - docker build -t frappe-nginx -f build/frappe-nginx/Dockerfile . + - docker tag frappe-nginx frappe/frappe-nginx:edge + - docker tag frappe-nginx frappe/frappe-nginx:develop + - docker push frappe/frappe-nginx:edge + - docker push frappe/frappe-nginx:develop - name: "Build ERPNext python environment (edge)" if: branch = develop AND type != pull_request script: @@ -46,11 +46,11 @@ matrix: - name: "Build ERPNext nginx + static assets (edge)" if: branch = develop AND type != pull_request script: - - docker build -t erpnext-assets -f build/erpnext-assets/Dockerfile . - - docker tag erpnext-assets frappe/erpnext-assets:edge - - docker tag erpnext-assets frappe/erpnext-assets:develop - - docker push frappe/erpnext-assets:edge - - docker push frappe/erpnext-assets:develop + - docker build -t erpnext-nginx -f build/erpnext-nginx/Dockerfile . + - docker tag erpnext-nginx frappe/erpnext-nginx:edge + - docker tag erpnext-nginx frappe/erpnext-nginx:develop + - docker push frappe/erpnext-nginx:edge + - docker push frappe/erpnext-nginx:develop - name: "Build Frappe socketio service (edge)" if: branch = develop AND type != pull_request script: @@ -81,12 +81,12 @@ matrix: - git fetch --tags - export VERSION=$(git tag --list --sort=-version:refname "v12*" | sed -n 1p | sed -e 's#.*@\(\)#\1#') - cd .. - - docker build -t frappe/frappe-assets:$VERSION -f build/frappe-assets/v12.Dockerfile . - - docker tag frappe/frappe-assets:$VERSION frappe/frappe-assets:version-12 - - docker tag frappe/frappe-assets:$VERSION frappe/frappe-assets:v12 - - docker push frappe/frappe-assets:$VERSION - - docker push frappe/frappe-assets:version-12 - - docker push frappe/frappe-assets:v12 + - docker build -t frappe/frappe-nginx:$VERSION -f build/frappe-nginx/v12.Dockerfile . + - docker tag frappe/frappe-nginx:$VERSION frappe/frappe-nginx:version-12 + - docker tag frappe/frappe-nginx:$VERSION frappe/frappe-nginx:v12 + - docker push frappe/frappe-nginx:$VERSION + - docker push frappe/frappe-nginx:version-12 + - docker push frappe/frappe-nginx:v12 - name: "Build ERPNext python environment (v12)" if: branch = master AND type != pull_request script: @@ -109,12 +109,12 @@ matrix: - git fetch --tags - export VERSION=$(git tag --list --sort=-version:refname "v12*" | sed -n 1p | sed -e 's#.*@\(\)#\1#') - cd .. - - docker build -t frappe/erpnext-assets:$VERSION -f build/erpnext-assets/v12.Dockerfile . - - docker tag frappe/erpnext-assets:$VERSION frappe/erpnext-assets:version-12 - - docker tag frappe/erpnext-assets:$VERSION frappe/erpnext-assets:v12 - - docker push frappe/erpnext-assets:$VERSION - - docker push frappe/erpnext-assets:version-12 - - docker push frappe/erpnext-assets:v12 + - docker build -t frappe/erpnext-nginx:$VERSION -f build/erpnext-nginx/v12.Dockerfile . + - docker tag frappe/erpnext-nginx:$VERSION frappe/erpnext-nginx:version-12 + - docker tag frappe/erpnext-nginx:$VERSION frappe/erpnext-nginx:v12 + - docker push frappe/erpnext-nginx:$VERSION + - docker push frappe/erpnext-nginx:version-12 + - docker push frappe/erpnext-nginx:v12 - name: "Build Frappe socketio service (v12)" if: branch = master AND type != pull_request script: @@ -151,12 +151,12 @@ matrix: - git fetch --tags - export VERSION=$(git tag --list --sort=-version:refname "v11*" | sed -n 1p | sed -e 's#.*@\(\)#\1#') - cd .. - - docker build -t frappe/frappe-assets:$VERSION -f build/frappe-assets/v11.Dockerfile . - - docker tag frappe/frappe-assets:$VERSION frappe/frappe-assets:version-11 - - docker tag frappe/frappe-assets:$VERSION frappe/frappe-assets:v11 - - docker push frappe/frappe-assets:$VERSION - - docker push frappe/frappe-assets:version-11 - - docker push frappe/frappe-assets:v11 + - docker build -t frappe/frappe-nginx:$VERSION -f build/frappe-nginx/v11.Dockerfile . + - docker tag frappe/frappe-nginx:$VERSION frappe/frappe-nginx:version-11 + - docker tag frappe/frappe-nginx:$VERSION frappe/frappe-nginx:v11 + - docker push frappe/frappe-nginx:$VERSION + - docker push frappe/frappe-nginx:version-11 + - docker push frappe/frappe-nginx:v11 - name: "Build ERPNext python environment (v11)" if: branch = master AND type != pull_request script: @@ -179,12 +179,12 @@ matrix: - git fetch --tags - export VERSION=$(git tag --list --sort=-version:refname "v11*" | sed -n 1p | sed -e 's#.*@\(\)#\1#') - cd .. - - docker build -t frappe/erpnext-assets:$VERSION -f build/erpnext-assets/v11.Dockerfile . - - docker tag frappe/erpnext-assets:$VERSION frappe/erpnext-assets:version-11 - - docker tag frappe/erpnext-assets:$VERSION frappe/erpnext-assets:v11 - - docker push frappe/erpnext-assets:$VERSION - - docker push frappe/erpnext-assets:version-11 - - docker push frappe/erpnext-assets:v11 + - docker build -t frappe/erpnext-nginx:$VERSION -f build/erpnext-nginx/v11.Dockerfile . + - docker tag frappe/erpnext-nginx:$VERSION frappe/erpnext-nginx:version-11 + - docker tag frappe/erpnext-nginx:$VERSION frappe/erpnext-nginx:v11 + - docker push frappe/erpnext-nginx:$VERSION + - docker push frappe/erpnext-nginx:version-11 + - docker push frappe/erpnext-nginx:v11 - name: "Build Frappe socketio service (v11)" if: branch = master AND type != pull_request script: diff --git a/build/erpnext-assets/Dockerfile b/build/erpnext-nginx/Dockerfile similarity index 96% rename from build/erpnext-assets/Dockerfile rename to build/erpnext-nginx/Dockerfile index 7fcb2b20..967a8c04 100644 --- a/build/erpnext-assets/Dockerfile +++ b/build/erpnext-nginx/Dockerfile @@ -30,7 +30,7 @@ FROM nginx:latest COPY --from=0 /home/frappe/frappe-bench/sites /var/www/html/ COPY --from=0 /var/www/error_pages /var/www/ COPY build/common/nginx-default.conf.template /etc/nginx/conf.d/default.conf.template -COPY build/erpnext-assets/docker-entrypoint.sh / +COPY build/erpnext-nginx/docker-entrypoint.sh / RUN apt-get update && apt-get install -y rsync && apt-get clean diff --git a/build/erpnext-assets/docker-entrypoint.sh b/build/erpnext-nginx/docker-entrypoint.sh similarity index 100% rename from build/erpnext-assets/docker-entrypoint.sh rename to build/erpnext-nginx/docker-entrypoint.sh diff --git a/build/erpnext-assets/v11.Dockerfile b/build/erpnext-nginx/v11.Dockerfile similarity index 96% rename from build/erpnext-assets/v11.Dockerfile rename to build/erpnext-nginx/v11.Dockerfile index 6db3b415..5d737448 100644 --- a/build/erpnext-assets/v11.Dockerfile +++ b/build/erpnext-nginx/v11.Dockerfile @@ -30,7 +30,7 @@ FROM nginx:latest COPY --from=0 /home/frappe/frappe-bench/sites /var/www/html/ COPY --from=0 /var/www/error_pages /var/www/ COPY build/common/nginx-default.conf.template /etc/nginx/conf.d/default.conf.template -COPY build/erpnext-assets/docker-entrypoint.sh / +COPY build/erpnext-nginx/docker-entrypoint.sh / RUN apt-get update && apt-get install -y rsync && apt-get clean diff --git a/build/erpnext-assets/v12.Dockerfile b/build/erpnext-nginx/v12.Dockerfile similarity index 96% rename from build/erpnext-assets/v12.Dockerfile rename to build/erpnext-nginx/v12.Dockerfile index 9b13bb13..16b2c1fe 100644 --- a/build/erpnext-assets/v12.Dockerfile +++ b/build/erpnext-nginx/v12.Dockerfile @@ -30,7 +30,7 @@ FROM nginx:latest COPY --from=0 /home/frappe/frappe-bench/sites /var/www/html/ COPY --from=0 /var/www/error_pages /var/www/ COPY build/common/nginx-default.conf.template /etc/nginx/conf.d/default.conf.template -COPY build/erpnext-assets/docker-entrypoint.sh / +COPY build/erpnext-nginx/docker-entrypoint.sh / RUN apt-get update && apt-get install -y rsync && apt-get clean diff --git a/build/frappe-assets/Dockerfile b/build/frappe-nginx/Dockerfile similarity index 96% rename from build/frappe-assets/Dockerfile rename to build/frappe-nginx/Dockerfile index 762e74d1..03b40883 100644 --- a/build/frappe-assets/Dockerfile +++ b/build/frappe-nginx/Dockerfile @@ -27,7 +27,7 @@ FROM nginx:latest COPY --from=0 /home/frappe/frappe-bench/sites /var/www/html/ COPY --from=0 /var/www/error_pages /var/www/ COPY build/common/nginx-default.conf.template /etc/nginx/conf.d/default.conf.template -COPY build/frappe-assets/docker-entrypoint.sh / +COPY build/frappe-nginx/docker-entrypoint.sh / RUN apt-get update && apt-get install -y rsync && apt-get clean diff --git a/build/frappe-assets/docker-entrypoint.sh b/build/frappe-nginx/docker-entrypoint.sh similarity index 100% rename from build/frappe-assets/docker-entrypoint.sh rename to build/frappe-nginx/docker-entrypoint.sh diff --git a/build/frappe-assets/v11.Dockerfile b/build/frappe-nginx/v11.Dockerfile similarity index 96% rename from build/frappe-assets/v11.Dockerfile rename to build/frappe-nginx/v11.Dockerfile index 225243d2..cfeb2c3d 100644 --- a/build/frappe-assets/v11.Dockerfile +++ b/build/frappe-nginx/v11.Dockerfile @@ -27,7 +27,7 @@ FROM nginx:latest COPY --from=0 /home/frappe/frappe-bench/sites /var/www/html/ COPY --from=0 /var/www/error_pages /var/www/ COPY build/common/nginx-default.conf.template /etc/nginx/conf.d/default.conf.template -COPY build/frappe-assets/docker-entrypoint.sh / +COPY build/frappe-nginx/docker-entrypoint.sh / RUN apt-get update && apt-get install -y rsync && apt-get clean diff --git a/build/frappe-assets/v12.Dockerfile b/build/frappe-nginx/v12.Dockerfile similarity index 96% rename from build/frappe-assets/v12.Dockerfile rename to build/frappe-nginx/v12.Dockerfile index cbbac49b..4994ad28 100644 --- a/build/frappe-assets/v12.Dockerfile +++ b/build/frappe-nginx/v12.Dockerfile @@ -27,7 +27,7 @@ FROM nginx:latest COPY --from=0 /home/frappe/frappe-bench/sites /var/www/html/ COPY --from=0 /var/www/error_pages /var/www/ COPY build/common/nginx-default.conf.template /etc/nginx/conf.d/default.conf.template -COPY build/frappe-assets/docker-entrypoint.sh / +COPY build/frappe-nginx/docker-entrypoint.sh / RUN apt-get update && apt-get install -y rsync && apt-get clean diff --git a/installation/docker-compose-erpnext.yml b/installation/docker-compose-erpnext.yml index 93b7c6a1..f932a512 100644 --- a/installation/docker-compose-erpnext.yml +++ b/installation/docker-compose-erpnext.yml @@ -1,8 +1,8 @@ version: '3' services: - erpnext-assets: - image: frappe/erpnext-assets:${VERSION} + erpnext-nginx: + image: frappe/erpnext-nginx:${VERSION} restart: on-failure environment: - FRAPPE_PY=erpnext-python diff --git a/installation/docker-compose-frappe.yml b/installation/docker-compose-frappe.yml index 869fb73c..df1e7c43 100644 --- a/installation/docker-compose-frappe.yml +++ b/installation/docker-compose-frappe.yml @@ -1,8 +1,8 @@ version: '3' services: - frappe-assets: - image: frappe/frappe-assets:${VERSION} + frappe-nginx: + image: frappe/frappe-nginx:${VERSION} restart: on-failure environment: - FRAPPE_PY=frappe-python From 8c008730653474b4729590a2e1c3e7c2cf0ea8f2 Mon Sep 17 00:00:00 2001 From: chabad360 Date: Wed, 4 Mar 2020 02:15:59 +0000 Subject: [PATCH 07/65] swap out travis.sh for python and be compat with #100 --- .travis.yml | 82 ++++++++++++++-------------- travis.py | 66 +++++++++++++++++++++++ travis.sh | 150 ---------------------------------------------------- 3 files changed, 107 insertions(+), 191 deletions(-) create mode 100755 travis.py delete mode 100755 travis.sh diff --git a/.travis.yml b/.travis.yml index 0440e032..a01d8898 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,7 @@ before_install: - if [[ $BUILD == "development" ]];then sudo apt-get update && sudo apt-get -y install docker-compose; fi - - chmod u+x ./travis.sh + - chmod u+x ./travis.py after_success: - docker --version @@ -23,87 +23,87 @@ matrix: - name: "Build Frappe python environment (edge)" if: branch = develop AND type != pull_request script: - - ./travis.sh --worker --service frappe --tag edge - - ./travis.sh --worker --service frappe --tag develop --tag-only + - ./travis.py frappe --worker --tag edge + - ./travis.py frappe --worker --tag develop --tag-only - name: "Build Frappe nginx + static assets (edge)" if: branch = develop AND type != pull_request script: - - ./travis.sh --assets --service frappe --tag edge - - ./travis.sh --assets --service frappe --tag develop--tag-only + - ./travis.py frappe --nginx --tag edge + - ./travis.py frappe --nginx --tag develop--tag-only - name: "Build ERPNext python environment (edge)" if: branch = develop AND type != pull_request script: - - ./travis.sh --worker --service erpnext --tag edge - - ./travis.sh --worker --service erpnext --tag develop --tag-only + - ./travis.py erpnext --worker --tag edge + - ./travis.py erpnext --worker --tag develop --tag-only - name: "Build ERPNext nginx + static assets (edge)" if: branch = develop AND type != pull_request script: - - ./travis.sh --assets --service erpnext --tag edge - - ./travis.sh --assets --service erpnext --tag develop --tag-only + - ./travis.py erpnext --nginx --tag edge + - ./travis.py erpnext --nginx --tag develop --tag-only - name: "Build Frappe socketio service (edge)" if: branch = develop AND type != pull_request script: - - ./travis.sh --socketio --service frappe --tag edge - - ./travis.sh --socketio --service frappe --tag develop --tag-only + - ./travis.py frappe --socketio --tag edge + - ./travis.py frappe --socketio --tag develop --tag-only - name: "Build Frappe python environment (v12)" if: branch = master AND type != pull_request script: - - ./travis.sh --worker --service frappe --git-branch 12 - - ./travis.sh --worker --service frappe --tag v12 --tag-only - - ./travis.sh --worker --service frappe --tag version-12 --tag-only + - ./travis.py frappe --worker --git-branch 12 + - ./travis.py frappe --worker --tag v12 --tag-only + - ./travis.py frappe --worker --tag version-12 --tag-only - name: "Build Frappe nginx + static assets (v12)" if: branch = master AND type != pull_request script: - - ./travis.sh --assets --service frappe --git-branch 12 - - ./travis.sh --assets --service frappe --tag v12 --tag-only - - ./travis.sh --assets --service frappe --tag version-12 --tag-only + - ./travis.py frappe --nginx --git-branch 12 + - ./travis.py frappe --nginx --tag v12 --tag-only + - ./travis.py frappe --nginx --tag version-12 --tag-only - name: "Build ERPNext python environment (v12)" if: branch = master AND type != pull_request script: - - ./travis.sh --worker --service erpnext --git-branch 12 - - ./travis.sh --worker --service erpnext --tag v12 --tag-only - - ./travis.sh --worker --service erpnext --tag version-12 --tag-only + - ./travis.py erpnext --worker --git-branch 12 + - ./travis.py erpnext --worker --tag v12 --tag-only + - ./travis.py erpnext --worker --tag version-12 --tag-only - name: "Build ERPNext nginx + static assets (v12)" if: branch = master AND type != pull_request script: - - ./travis.sh --assets --service erpnext--git-branch 12 - - ./travis.sh --assets --service erpnext --tag v12 --tag-only - - ./travis.sh --assets --service erpnext --tag version-12 --tag-only + - ./travis.py erpnext --nginx --git-branch 12 + - ./travis.py erpnext --nginx --tag v12 --tag-only + - ./travis.py erpnext --nginx --tag version-12 --tag-only - name: "Build Frappe socketio service (v11)" if: branch = master AND type != pull_request script: - - ./travis.sh --socketio --service frappe --git-branch 11 - - ./travis.sh --socketio --service frappe --tag v11 --tag-only - - ./travis.sh --socketio --service frappe --tag version-11 --tag-only + - ./travis.py frappe --socketio --git-branch 11 + - ./travis.py frappe --socketio --tag v11 --tag-only + - ./travis.py frappe --socketio --tag version-11 --tag-only - name: "Build Frappe python environment (v11)" if: branch = master AND type != pull_request script: - - ./travis.sh --worker --service frappe --git-branch 11 - - ./travis.sh --worker --service frappe --tag v11 --tag-only - - ./travis.sh --worker --service frappe --tag version-11 --tag-only + - ./travis.py frappe --worker --git-branch 11 + - ./travis.py frappe --worker --tag v11 --tag-only + - ./travis.py frappe --worker --tag version-11 --tag-only - name: "Build Frappe nginx + static assets (v11)" if: branch = master AND type != pull_request script: - - ./travis.sh --assets --service frappe --git-branch 11 - - ./travis.sh --assets --service frappe --tag v11 --tag-only - - ./travis.sh --assets --service frappe --tag version-11 --tag-only + - ./travis.py erpnext frappe --nginx --git-branch 11 + - ./travis.py erpnext frappe --nginx --tag v11 --tag-only + - ./travis.py erpnext frappe --nginx --tag version-11 --tag-only - name: "Build ERPNext python environment (v11)" if: branch = master AND type != pull_request script: - - ./travis.sh --worker --service erpnext --git-branch 11 - - ./travis.sh --worker --service erpnext --tag v11 --tag-only - - ./travis.sh --worker --service erpnext --tag version-11 --tag-only + - ./travis.py erpnext --worker --git-branch 11 + - ./travis.py erpnext --worker --tag v11 --tag-only + - ./travis.py erpnext --worker --tag version-11 --tag-only - name: "Build ERPNext nginx + static assets (v11)" if: branch = master AND type != pull_request script: - - ./travis.sh --assets --service erpnext--git-branch 11 - - ./travis.sh --assets --service erpnext --tag v11 --tag-only - - ./travis.sh --assets --service erpnext --tag version-11 --tag-only + - ./travis.py erpnext --nginx --git-branch 11 + - ./travis.py erpnext --nginx --tag v11 --tag-only + - ./travis.py erpnext --nginx --tag version-11 --tag-only - name: "Build Frappe socketio service (v11)" if: branch = master AND type != pull_request script: - - ./travis.sh --socketio --service frappe --git-branch 11 - - ./travis.sh --socketio --service frappe --tag v11 --tag-only - - ./travis.sh --socketio --service frappe --tag version-11 --tag-only + - ./travis.py frappe --socketio --git-branch 11 + - ./travis.py frappe --socketio --tag v11 --tag-only + - ./travis.py frappe --socketio --tag version-11 --tag-only \ No newline at end of file diff --git a/travis.py b/travis.py new file mode 100755 index 00000000..ba4270df --- /dev/null +++ b/travis.py @@ -0,0 +1,66 @@ +#!/bin/env python3 + +import argparse +import subprocess +import os + +parser = argparse.ArgumentParser(description='frappe_docker common CI elements', add_help=True) + +image_type = parser.add_mutually_exclusive_group(required=True) +image_type.add_argument('-a', '--nginx', action='store_const', dest='image_type', const='nginx', help='Build the nginx + static assets image') +image_type.add_argument('-s', '--socketio', action='store_const', dest='image_type', const='socketio', help='Build the frappe-socketio image') +image_type.add_argument('-w', '--worker', action='store_const', dest='image_type', const='worker', help='Build the python environment image') + +parser.add_argument('service', action='store', type=str, help='Name of the service to build: "erpnext" or "frappe"') + +tag_type = parser.add_mutually_exclusive_group(required=True) +tag_type.add_argument('-g', '--git-version', action='store', type=int, dest='version', help='The version number of --service (i.e. "11", "12", etc.)') +tag_type.add_argument('-t', '--tag', action='store', type=str, dest='tag', help='The image tag (i.e. erpnext-worker:$TAG )') + +parser.add_argument('-o', '--tag-only', required=False, action='store_true', dest='tag_only', help='Only tag an image and push it.') + +args = parser.parse_args() + +print('image_type = {!r}'.format(args.image_type)) +print('service = {!r}'.format(args.service)) +print('version = {!r}'.format(args.version)) +print('tag = {!r}'.format(args.tag)) +print('tag_only = {!r}'.format(args.tag_only)) + +def git_version(service, version): + print(f'Pulling {service} v{version}') + subprocess.run(f'git clone https://github.com/frappe/{service} --branch version-{version}', shell=True) + cd = os.getcwd() + os.chdir(os.getcwd() + f'/{service}') + subprocess.run('git fetch --tags', shell=True) + version_tag = subprocess.check_output(f'git tag --list --sort=-version:refname "v{version}*" | sed -n 1p | sed -e \'s#.*@\(\)#\\1#\'', shell=True).strip().decode('ascii') + os.chdir(cd) + return version_tag + +def build(service, tag, image, dockerfile): + print(f'Building {service} {image} image using {dockerfile}') + subprocess.run(f'docker build -t {service}-{image} -f build/{service}-{image}/{dockerfile} .', shell=True) + tag_and_push(f'{service}-{image}', tag) + +def tag_and_push(image_name, tag): + print(f'Tagging {image_name} as "{tag}" and pushing') + subprocess.run(f'docker tag {image_name} frappe/{image_name}:{tag}', shell=True) + subprocess.run(f'docker push frappe/{image_name}:{tag}', shell=True) + +def main(): + global tag + global dockerfile + + if args.version: + tag = git_version(args.service, args.version) + dockerfile = 'v{!r}.Dockerfile'.format(args.version) + else: + tag = args.tag + dockerfile = 'Dockerfile' + + if args.tag_only: + tag_and_push(f'{args.service}-{args.image_type}', tag) + else: + build(args.service, tag, args.image_type, dockerfile) + +main() diff --git a/travis.sh b/travis.sh deleted file mode 100755 index 58943b87..00000000 --- a/travis.sh +++ /dev/null @@ -1,150 +0,0 @@ -#!/bin/bash - -################# ./travis.sh ################# -# This script takes care of the common steps -# found in the frappe_docker Travis CI builds. -# -# Usage: [-a | -s | -w | -h] [-n ] [-t | -g ] [-o] -# -# Argumets: -# -# -a | --assets (exclusive): Build the nginx + static assets image -# -s | --socketio (exclusive): Build the frappe-socketio image -# -w | --worker (exclusive): Build the python environment image -# -h | --help (exclusive): Print this page -# -# -n | --service : Name of the service to build: "erpnext" or "frappe" -# Note: --socketio does not respect this argument -# Note: This will build an image with the name "$SERVICE-assets" (i.e. "erpnext-worker", "frappe-assets", etc.) -# -# -t | --tag (exclusive): The image tag (i.e. erpnext-worker:$TAG ) -# -g | --git-version (exclusive): The version number of --service (i.e. "11", "12", etc.) -# Note: This must be a number, not a string! -# -# -o | --tag-only: Only tag an image and push it. -# -# - - -while [[ $# -gt 0 ]]; do - key="$1" - - case $key in - -a|--assets) - ASSETS=1 - shift - ;; - -g|--git-version) - version="$2" - shift - shift - ;; - -h|--help) - HELP=1 - shift - ;; - -n|--service) - SERVICE="$2" - shift - shift - ;; - -o|--tag-only) - TAGONLY=1 - shift - ;; - -s|--socketio) - SOCKETIO=1 - shift - ;; - -t|--tag) - TAG="$2" - shift - shift - ;; - -w|--worker) - WORKER=1 - shift - ;; - *) - HELP=1 - shift - ;; - esac -done - -function help() { - echo "################ $0 #################" - echo " This script takes care of the common steps found in the frappe_docker Travis CI builds." - echo "" - echo " Usage: [-a | -s | -w | -h] [-n ] [-t | -g ] [-o]" - echo "" - echo " Argumets:" - echo "" - echo " -a | --assets (exclusive): Build the nginx + static assets image" - echo " -s | --socketio (exclusive): Build the frappe-socketio image" - echo " -w | --worker (exclusive): Build the python environment image" - echo " -h | --help (exclusive): Print this page" - echo "" - echo " -n | --service : Name of the service to build: \"erpnext\" or \"frappe\"" - echo " Note: --socketio does not respect this argument" - echo " Note: This will build an image with the name \"\$SERVICE-assets\" (i.e. \"erpnext-worker\", \"frappe-assets\", etc.)" - echo "" - echo " -t | --tag (exclusive): The image tag (i.e. erpnext-worker:\$TAG)" - echo " -g | --git-version (exclusive): The version number of --service (i.e. \"11\", \"12\", etc.)" - echo " Note: This must be a number, not a string!" - echo "" - echo " -o | --tag-only: Only tag an image and push it." -} - -function gitVersion() { - echo "Pulling ${1} v${2}" - git clone https://github.com/frappe/${1} --branch version-${2} - cd ${1} - git fetch --tags - TAG=$(git tag --list --sort=-version:refname "v${2}*" | sed -n 1p | sed -e 's#.*@\(\)#\1#') - cd .. - DOCKERFILE="v${2}.Dockerfile" -} - -function tagAndPush() { - echo "Tagging ${1} as \"${2}\" and pushing" - docker tag ${1} frappe/${1}:${2} - docker push frappe/${1}:${2} -} - -function build () { - echo "Building ${1} ${3} image using ${4}" - docker build -t ${1}-${3} -f build/${1}-${3}/${4:-Dockerfile} . - tagAndPush "${1}-${3}" ${2} -} - -if [[ HELP ]]; then - help - exit 1 -fi - -if [[ $VERSION ]]; then - gitVersion $SERVICE $VERSION -fi - -DOCKERFILE=${DOCKERFILE:-Dockerfile} - -if [[ $WORKER ]]; then - if [[ $TAGONLY ]]; then - tagAndPush "${SERVICE}-worker" ${TAG} - else - build $SERVICE $TAG worker ${DOCKERFILE} - fi -elif [[ $ASSETS ]]; then - if [[ $TAGONLY ]]; then - tagAndPush "${SERVICE}-assets" ${TAG} - else - build $SERVICE $TAG assets ${DOCKERFILE} - fi -elif [[ $SOCKETIO ]]; then - if [[ $TAGONLY ]]; then - tagAndPush "frappe-socketio" ${TAG} - else - build frappe $TAG socketio ${DOCKERFILE} - fi -fi \ No newline at end of file From 34d97848b54df6ba639be269a744aa04dfcd1931 Mon Sep 17 00:00:00 2001 From: chabad360 Date: Wed, 4 Mar 2020 02:22:29 +0000 Subject: [PATCH 08/65] remove some debugging lines --- travis.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/travis.py b/travis.py index ba4270df..0be54695 100755 --- a/travis.py +++ b/travis.py @@ -21,12 +21,6 @@ parser.add_argument('-o', '--tag-only', required=False, action='store_true', des args = parser.parse_args() -print('image_type = {!r}'.format(args.image_type)) -print('service = {!r}'.format(args.service)) -print('version = {!r}'.format(args.version)) -print('tag = {!r}'.format(args.tag)) -print('tag_only = {!r}'.format(args.tag_only)) - def git_version(service, version): print(f'Pulling {service} v{version}') subprocess.run(f'git clone https://github.com/frappe/{service} --branch version-{version}', shell=True) From 177ca58af624daae4bb2385bbbbf819134bc693a Mon Sep 17 00:00:00 2001 From: chabad360 Date: Wed, 4 Mar 2020 02:52:36 +0000 Subject: [PATCH 09/65] add and implement install_app for worker image --- build/common/worker/install_app.sh | 13 +++++++++ build/erpnext-worker/Dockerfile | 45 ++--------------------------- build/erpnext-worker/v11.Dockerfile | 42 ++------------------------- build/erpnext-worker/v12.Dockerfile | 45 ++--------------------------- build/frappe-worker/Dockerfile | 2 ++ build/frappe-worker/v11.Dockerfile | 2 ++ build/frappe-worker/v12.Dockerfile | 2 ++ 7 files changed, 25 insertions(+), 126 deletions(-) create mode 100755 build/common/worker/install_app.sh diff --git a/build/common/worker/install_app.sh b/build/common/worker/install_app.sh new file mode 100755 index 00000000..4717312f --- /dev/null +++ b/build/common/worker/install_app.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +APP_NAME=${1} +APP_REPO=${2} + +cd /home/frappe/frappe-bench/ + +. env/bin/activate + +cd apps + +git clone --depth 1 -o upstream ${APP_REPO} +pip3 install --no-cache-dir -e /home/frappe/frappe-bench/apps/APP_NAME \ No newline at end of file diff --git a/build/erpnext-worker/Dockerfile b/build/erpnext-worker/Dockerfile index 6d145d8c..88af72f6 100644 --- a/build/erpnext-worker/Dockerfile +++ b/build/erpnext-worker/Dockerfile @@ -1,44 +1,3 @@ -FROM bitnami/python:latest-prod +FROM frappe/frappe-worker:develop -RUN useradd -ms /bin/bash frappe -WORKDIR /home/frappe/frappe-bench -RUN install_packages \ - git \ - wkhtmltopdf \ - mariadb-client \ - gettext-base \ - wget \ - # for PDF - libssl-dev \ - fonts-cantarell \ - xfonts-75dpi \ - xfonts-base \ - # For psycopg2 - libpq-dev \ - build-essential - -# Install wkhtmltox correctly -RUN wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.stretch_amd64.deb -RUN dpkg -i wkhtmltox_0.12.5-1.stretch_amd64.deb && rm wkhtmltox_0.12.5-1.stretch_amd64.deb - -RUN mkdir -p apps logs commands - -RUN virtualenv env \ - && . env/bin/activate \ - && cd apps \ - && git clone --depth 1 -o upstream https://github.com/frappe/frappe \ - && git clone --depth 1 -o upstream https://github.com/frappe/erpnext \ - && pip3 install --no-cache-dir -e /home/frappe/frappe-bench/apps/frappe \ - && pip3 install --no-cache-dir -e /home/frappe/frappe-bench/apps/erpnext - -COPY build/common/commands/* /home/frappe/frappe-bench/commands/ -COPY build/common/common_site_config.json.template /opt/frappe/common_site_config.json.template - -# Setup docker-entrypoint -COPY build/common/worker/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh -RUN ln -s /usr/local/bin/docker-entrypoint.sh / # backwards compat - -WORKDIR /home/frappe/frappe-bench/sites - -ENTRYPOINT ["docker-entrypoint.sh"] -CMD ["start"] +RUN install_app erpnext https://github.com/frappe/erpnext \ No newline at end of file diff --git a/build/erpnext-worker/v11.Dockerfile b/build/erpnext-worker/v11.Dockerfile index 81a59b63..9f6c9c2a 100644 --- a/build/erpnext-worker/v11.Dockerfile +++ b/build/erpnext-worker/v11.Dockerfile @@ -1,41 +1,3 @@ -FROM bitnami/python:latest-prod +FROM frappe/frappe-worker:v11 -RUN useradd -ms /bin/bash frappe -WORKDIR /home/frappe/frappe-bench -RUN install_packages \ - git \ - wkhtmltopdf \ - mariadb-client \ - gettext-base \ - wget \ - # for PDF - libssl-dev \ - fonts-cantarell \ - xfonts-75dpi \ - xfonts-base - -# Install wkhtmltox correctly -RUN wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.stretch_amd64.deb -RUN dpkg -i wkhtmltox_0.12.5-1.stretch_amd64.deb && rm wkhtmltox_0.12.5-1.stretch_amd64.deb - -RUN mkdir -p apps logs commands - -RUN virtualenv env \ - && . env/bin/activate \ - && cd apps \ - && git clone --depth 1 -o upstream https://github.com/frappe/frappe --branch version-11 \ - && git clone --depth 1 -o upstream https://github.com/frappe/erpnext --branch version-11 \ - && pip3 install --no-cache-dir -e /home/frappe/frappe-bench/apps/frappe \ - && pip3 install --no-cache-dir -e /home/frappe/frappe-bench/apps/erpnext - -COPY build/common/commands/* /home/frappe/frappe-bench/commands/ -COPY build/common/common_site_config.json.template /opt/frappe/common_site_config.json.template - -# Setup docker-entrypoint -COPY build/common/worker/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh -RUN ln -s /usr/local/bin/docker-entrypoint.sh / # backwards compat - -WORKDIR /home/frappe/frappe-bench/sites - -ENTRYPOINT ["docker-entrypoint.sh"] -CMD ["start"] +RUN install_app erpnext https://github.com/frappe/erpnext \ No newline at end of file diff --git a/build/erpnext-worker/v12.Dockerfile b/build/erpnext-worker/v12.Dockerfile index 3945142a..734e9286 100644 --- a/build/erpnext-worker/v12.Dockerfile +++ b/build/erpnext-worker/v12.Dockerfile @@ -1,44 +1,3 @@ -FROM bitnami/python:latest-prod +FROM frappe/frappe-worker:v12 -RUN useradd -ms /bin/bash frappe -WORKDIR /home/frappe/frappe-bench -RUN install_packages \ - git \ - wkhtmltopdf \ - mariadb-client \ - gettext-base \ - wget \ - # for PDF - libssl-dev \ - fonts-cantarell \ - xfonts-75dpi \ - xfonts-base \ - # For psycopg2 - libpq-dev \ - build-essential - -# Install wkhtmltox correctly -RUN wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.stretch_amd64.deb -RUN dpkg -i wkhtmltox_0.12.5-1.stretch_amd64.deb && rm wkhtmltox_0.12.5-1.stretch_amd64.deb - -RUN mkdir -p apps logs commands - -RUN virtualenv env \ - && . env/bin/activate \ - && cd apps \ - && git clone --depth 1 -o upstream https://github.com/frappe/frappe --branch version-12 \ - && git clone --depth 1 -o upstream https://github.com/frappe/erpnext --branch version-12 \ - && pip3 install --no-cache-dir -e /home/frappe/frappe-bench/apps/frappe \ - && pip3 install --no-cache-dir -e /home/frappe/frappe-bench/apps/erpnext - -COPY build/common/commands/* /home/frappe/frappe-bench/commands/ -COPY build/common/common_site_config.json.template /opt/frappe/common_site_config.json.template - -# Setup docker-entrypoint -COPY build/common/worker/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh -RUN ln -s /usr/local/bin/docker-entrypoint.sh / # backwards compat - -WORKDIR /home/frappe/frappe-bench/sites - -ENTRYPOINT ["docker-entrypoint.sh"] -CMD ["start"] +RUN install_app erpnext https://github.com/frappe/erpnext \ No newline at end of file diff --git a/build/frappe-worker/Dockerfile b/build/frappe-worker/Dockerfile index 41310b0d..40ce9c06 100644 --- a/build/frappe-worker/Dockerfile +++ b/build/frappe-worker/Dockerfile @@ -36,6 +36,8 @@ COPY build/common/common_site_config.json.template /opt/frappe/common_site_confi COPY build/common/worker/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh RUN ln -s /usr/local/bin/docker-entrypoint.sh / # backwards compat +COPY build/common/worker/install_app.sh /usr/local/bin/install_app + WORKDIR /home/frappe/frappe-bench/sites ENTRYPOINT ["docker-entrypoint.sh"] diff --git a/build/frappe-worker/v11.Dockerfile b/build/frappe-worker/v11.Dockerfile index fa2f01c5..335eb7a9 100644 --- a/build/frappe-worker/v11.Dockerfile +++ b/build/frappe-worker/v11.Dockerfile @@ -33,6 +33,8 @@ COPY build/common/common_site_config.json.template /opt/frappe/common_site_confi COPY build/common/worker/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh RUN ln -s /usr/local/bin/docker-entrypoint.sh / # backwards compat +COPY build/common/worker/install_app.sh /usr/local/bin/install_app + WORKDIR /home/frappe/frappe-bench/sites ENTRYPOINT ["docker-entrypoint.sh"] diff --git a/build/frappe-worker/v12.Dockerfile b/build/frappe-worker/v12.Dockerfile index 1eb6d60a..2f10db39 100644 --- a/build/frappe-worker/v12.Dockerfile +++ b/build/frappe-worker/v12.Dockerfile @@ -36,6 +36,8 @@ COPY build/common/common_site_config.json.template /opt/frappe/common_site_confi COPY build/common/worker/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh RUN ln -s /usr/local/bin/docker-entrypoint.sh / # backwards compat +COPY build/common/worker/install_app.sh /usr/local/bin/install_app + WORKDIR /home/frappe/frappe-bench/sites ENTRYPOINT ["docker-entrypoint.sh"] From b610caba7ead17c30f45832547d459b25ff912b9 Mon Sep 17 00:00:00 2001 From: chabad360 Date: Wed, 4 Mar 2020 03:33:23 +0000 Subject: [PATCH 10/65] forgot about branches --- build/common/worker/install_app.sh | 6 +++++- build/erpnext-worker/v11.Dockerfile | 2 +- build/erpnext-worker/v12.Dockerfile | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/build/common/worker/install_app.sh b/build/common/worker/install_app.sh index 4717312f..e3b9b629 100755 --- a/build/common/worker/install_app.sh +++ b/build/common/worker/install_app.sh @@ -2,6 +2,7 @@ APP_NAME=${1} APP_REPO=${2} +APP_BRANCH=${3} cd /home/frappe/frappe-bench/ @@ -9,5 +10,8 @@ cd /home/frappe/frappe-bench/ cd apps -git clone --depth 1 -o upstream ${APP_REPO} +[ "${APP_BRANCH}" ] && \ + BRANCH="-b ${APP_BRANCH}" + +git clone --depth 1 -o upstream ${APP_REPO} ${BRANCH} pip3 install --no-cache-dir -e /home/frappe/frappe-bench/apps/APP_NAME \ No newline at end of file diff --git a/build/erpnext-worker/v11.Dockerfile b/build/erpnext-worker/v11.Dockerfile index 9f6c9c2a..b17c7aaa 100644 --- a/build/erpnext-worker/v11.Dockerfile +++ b/build/erpnext-worker/v11.Dockerfile @@ -1,3 +1,3 @@ FROM frappe/frappe-worker:v11 -RUN install_app erpnext https://github.com/frappe/erpnext \ No newline at end of file +RUN install_app erpnext https://github.com/frappe/erpnext version-11 \ No newline at end of file diff --git a/build/erpnext-worker/v12.Dockerfile b/build/erpnext-worker/v12.Dockerfile index 734e9286..2bade604 100644 --- a/build/erpnext-worker/v12.Dockerfile +++ b/build/erpnext-worker/v12.Dockerfile @@ -1,3 +1,3 @@ FROM frappe/frappe-worker:v12 -RUN install_app erpnext https://github.com/frappe/erpnext \ No newline at end of file +RUN install_app erpnext https://github.com/frappe/erpnext version-12 \ No newline at end of file From f4e24e15a858a0b755aeb20c2c16904f3b08828e Mon Sep 17 00:00:00 2001 From: chabad360 Date: Wed, 4 Mar 2020 03:33:38 +0000 Subject: [PATCH 11/65] create install_app for assets --- build/erpnext-assets/Dockerfile | 38 ++++++---------------------- build/erpnext-assets/install_app.sh | 29 +++++++++++++++++++++ build/erpnext-assets/v11.Dockerfile | 38 ++++++---------------------- build/erpnext-assets/v12.Dockerfile | 39 ++++++----------------------- 4 files changed, 50 insertions(+), 94 deletions(-) create mode 100644 build/erpnext-assets/install_app.sh diff --git a/build/erpnext-assets/Dockerfile b/build/erpnext-assets/Dockerfile index 7fcb2b20..6bec65a0 100644 --- a/build/erpnext-assets/Dockerfile +++ b/build/erpnext-assets/Dockerfile @@ -1,38 +1,14 @@ FROM bitnami/node:12-prod -WORKDIR /home/frappe/frappe-bench -RUN mkdir -p /home/frappe/frappe-bench/sites \ - && echo "frappe\nerpnext" > /home/frappe/frappe-bench/sites/apps.txt +COPY build/erpnext-assets/install_app.sh /install_app -RUN install_packages git python2 +RUN /install_app erpnext https://github.com/frappe/erpnext -RUN mkdir -p apps sites/assets \ - && cd apps \ - && git clone --depth 1 https://github.com/frappe/frappe \ - && git clone --depth 1 https://github.com/frappe/erpnext - -RUN cd /home/frappe/frappe-bench/apps/frappe \ - && yarn \ - && yarn run production \ - && rm -fr node_modules \ - && yarn install --production=true - -RUN git clone --depth 1 https://github.com/frappe/bench /tmp/bench \ - && mkdir -p /var/www/error_pages \ - && cp -r /tmp/bench/bench/config/templates/502.html /var/www/error_pages - -RUN cp -R /home/frappe/frappe-bench/apps/frappe/frappe/public/* /home/frappe/frappe-bench/sites/assets/frappe \ - && cp -R /home/frappe/frappe-bench/apps/frappe/node_modules /home/frappe/frappe-bench/sites/assets/frappe/ \ - && mkdir -p /home/frappe/frappe-bench/sites/assets/erpnext \ - && cp -R /home/frappe/frappe-bench/apps/erpnext/erpnext/public/* /home/frappe/frappe-bench/sites/assets/erpnext - -FROM nginx:latest -COPY --from=0 /home/frappe/frappe-bench/sites /var/www/html/ -COPY --from=0 /var/www/error_pages /var/www/ -COPY build/common/nginx-default.conf.template /etc/nginx/conf.d/default.conf.template -COPY build/erpnext-assets/docker-entrypoint.sh / - -RUN apt-get update && apt-get install -y rsync && apt-get clean +FROM frappe/frappe-assets:develop +RUN cp /home/frappe/frappe-bench/sites/apps.txt /home/frappe/frappe-bench/sites/apps.bak +COPY --from=0 /home/frappe/frappe-bench/sites/ /var/www/html/ +RUN mv /home/frappe/frappe-bench/sites/apps.bak /home/frappe/frappe-bench/sites/apps.txt \ + && echo -n "\nerpnext" >> /home/frappe/frappe-bench/sites/apps.txt VOLUME [ "/assets" ] diff --git a/build/erpnext-assets/install_app.sh b/build/erpnext-assets/install_app.sh new file mode 100644 index 00000000..eefa538a --- /dev/null +++ b/build/erpnext-assets/install_app.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +APP_NAME=${1} +APP_REPO=${2} +APP_BRANCH=${3} + +[ "${APP_BRANCH}" ] && \ + BRANCH="-b ${APP_BRANCH}" + +cd /home/frappe/frappe-bench +mkdir -p /home/frappe/frappe-bench/sites +echo "frappe\n${APP_NAME}" > /home/frappe/frappe-bench/sites/apps.txt + +install_packages git python2 + +mkdir -p apps sites/assets +cd apps +git clone --depth 1 https://github.com/frappe/frappe ${BRANCH} +git clone --depth 1 ${APP_REPO} ${BRANCH} + +cd /home/frappe/frappe-bench/apps/frappe +yarn +yarn production +rm -fr node_modules +yarn install --production=true + +mkdir -p /home/frappe/frappe-bench/sites/assets/${APP_NAME} +cp -R /home/frappe/frappe-bench/apps/${APP_NAME}/${APP_NAME}/public/* /home/frappe/frappe-bench/sites/assets/${APP_NAME} + diff --git a/build/erpnext-assets/v11.Dockerfile b/build/erpnext-assets/v11.Dockerfile index 6db3b415..f46c2030 100644 --- a/build/erpnext-assets/v11.Dockerfile +++ b/build/erpnext-assets/v11.Dockerfile @@ -1,38 +1,14 @@ FROM bitnami/node:10-prod -WORKDIR /home/frappe/frappe-bench -RUN mkdir -p /home/frappe/frappe-bench/sites \ - && echo "frappe\nerpnext" > /home/frappe/frappe-bench/sites/apps.txt +COPY build/erpnext-assets/install_app.sh /install_app -RUN install_packages git python2 +RUN /install_app erpnext https://github.com/frappe/erpnext version-11 -RUN mkdir -p apps sites/assets \ - && cd apps \ - && git clone --depth 1 https://github.com/frappe/frappe --branch version-11 \ - && git clone --depth 1 https://github.com/frappe/erpnext --branch version-11 - -RUN cd /home/frappe/frappe-bench/apps/frappe \ - && yarn \ - && yarn run production \ - && rm -fr node_modules \ - && yarn install --production=true - -RUN git clone --depth 1 https://github.com/frappe/bench /tmp/bench \ - && mkdir -p /var/www/error_pages \ - && cp -r /tmp/bench/bench/config/templates/502.html /var/www/error_pages - -RUN cp -R /home/frappe/frappe-bench/apps/frappe/frappe/public/* /home/frappe/frappe-bench/sites/assets/frappe \ - && cp -R /home/frappe/frappe-bench/apps/frappe/node_modules /home/frappe/frappe-bench/sites/assets/frappe/ \ - && mkdir -p /home/frappe/frappe-bench/sites/assets/erpnext \ - && cp -R /home/frappe/frappe-bench/apps/erpnext/erpnext/public/* /home/frappe/frappe-bench/sites/assets/erpnext - -FROM nginx:latest -COPY --from=0 /home/frappe/frappe-bench/sites /var/www/html/ -COPY --from=0 /var/www/error_pages /var/www/ -COPY build/common/nginx-default.conf.template /etc/nginx/conf.d/default.conf.template -COPY build/erpnext-assets/docker-entrypoint.sh / - -RUN apt-get update && apt-get install -y rsync && apt-get clean +FROM frappe/frappe-assets:v11 +RUN cp /home/frappe/frappe-bench/sites/apps.txt /home/frappe/frappe-bench/sites/apps.bak +COPY --from=0 /home/frappe/frappe-bench/sites/ /var/www/html/ +RUN mv /home/frappe/frappe-bench/sites/apps.bak /home/frappe/frappe-bench/sites/apps.txt \ + && echo -n "\nerpnext" >> /home/frappe/frappe-bench/sites/apps.txt VOLUME [ "/assets" ] diff --git a/build/erpnext-assets/v12.Dockerfile b/build/erpnext-assets/v12.Dockerfile index 9b13bb13..cb29ea1b 100644 --- a/build/erpnext-assets/v12.Dockerfile +++ b/build/erpnext-assets/v12.Dockerfile @@ -1,39 +1,14 @@ FROM bitnami/node:12-prod -WORKDIR /home/frappe/frappe-bench -RUN mkdir -p /home/frappe/frappe-bench/sites \ - && echo "frappe\nerpnext" > /home/frappe/frappe-bench/sites/apps.txt +COPY build/erpnext-assets/install_app.sh /install_app -RUN install_packages git python2 - -RUN mkdir -p apps sites/assets \ - && cd apps \ - && git clone --depth 1 https://github.com/frappe/frappe --branch version-12 \ - && git clone --depth 1 https://github.com/frappe/erpnext --branch version-12 - -RUN cd /home/frappe/frappe-bench/apps/frappe \ - && yarn \ - && yarn run production \ - && rm -fr node_modules \ - && yarn install --production=true - -RUN git clone --depth 1 https://github.com/frappe/bench /tmp/bench \ - && mkdir -p /var/www/error_pages \ - && cp -r /tmp/bench/bench/config/templates/502.html /var/www/error_pages - -RUN cp -R /home/frappe/frappe-bench/apps/frappe/frappe/public/* /home/frappe/frappe-bench/sites/assets/frappe \ - && cp -R /home/frappe/frappe-bench/apps/frappe/node_modules /home/frappe/frappe-bench/sites/assets/frappe/ \ - && mkdir -p /home/frappe/frappe-bench/sites/assets/erpnext \ - && cp -R /home/frappe/frappe-bench/apps/erpnext/erpnext/public/* /home/frappe/frappe-bench/sites/assets/erpnext - -FROM nginx:latest -COPY --from=0 /home/frappe/frappe-bench/sites /var/www/html/ -COPY --from=0 /var/www/error_pages /var/www/ -COPY build/common/nginx-default.conf.template /etc/nginx/conf.d/default.conf.template -COPY build/erpnext-assets/docker-entrypoint.sh / - -RUN apt-get update && apt-get install -y rsync && apt-get clean +RUN /install_app erpnext https://github.com/frappe/erpnext version-12 +FROM frappe/frappe-assets:v12 +RUN cp /home/frappe/frappe-bench/sites/apps.txt /home/frappe/frappe-bench/sites/apps.bak +COPY --from=0 /home/frappe/frappe-bench/sites/ /var/www/html/ +RUN mv /home/frappe/frappe-bench/sites/apps.bak /home/frappe/frappe-bench/sites/apps.txt \ + && echo -n "\nerpnext" >> /home/frappe/frappe-bench/sites/apps.txt VOLUME [ "/assets" ] ENTRYPOINT ["/docker-entrypoint.sh"] From 48a305bec6f08b836f5d5e9642d1b11cd7400061 Mon Sep 17 00:00:00 2001 From: chabad360 Date: Wed, 4 Mar 2020 03:43:49 +0000 Subject: [PATCH 12/65] Adding in the rsync for the docker-entrypoint --- build/erpnext-assets/Dockerfile | 1 + build/erpnext-assets/docker-entrypoint.sh | 40 ----------------------- build/erpnext-assets/install_app.sh | 1 + build/erpnext-assets/v11.Dockerfile | 1 + build/erpnext-assets/v12.Dockerfile | 1 + build/frappe-assets/docker-entrypoint.sh | 1 + 6 files changed, 5 insertions(+), 40 deletions(-) delete mode 100755 build/erpnext-assets/docker-entrypoint.sh diff --git a/build/erpnext-assets/Dockerfile b/build/erpnext-assets/Dockerfile index 6bec65a0..9e966d53 100644 --- a/build/erpnext-assets/Dockerfile +++ b/build/erpnext-assets/Dockerfile @@ -7,6 +7,7 @@ RUN /install_app erpnext https://github.com/frappe/erpnext FROM frappe/frappe-assets:develop RUN cp /home/frappe/frappe-bench/sites/apps.txt /home/frappe/frappe-bench/sites/apps.bak COPY --from=0 /home/frappe/frappe-bench/sites/ /var/www/html/ +COPY --from=0 /rsync /rsync RUN mv /home/frappe/frappe-bench/sites/apps.bak /home/frappe/frappe-bench/sites/apps.txt \ && echo -n "\nerpnext" >> /home/frappe/frappe-bench/sites/apps.txt diff --git a/build/erpnext-assets/docker-entrypoint.sh b/build/erpnext-assets/docker-entrypoint.sh deleted file mode 100755 index 4919fb34..00000000 --- a/build/erpnext-assets/docker-entrypoint.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash - -## Thanks -# https://serverfault.com/a/919212 -## - -set -e - -rsync -a --delete /var/www/html/assets/js /assets -rsync -a --delete /var/www/html/assets/css /assets -rsync -a --delete /var/www/html/assets/frappe /assets -rsync -a --delete /var/www/html/assets/erpnext /assets - -chmod -R 755 /assets - -if [[ -z "$FRAPPE_PY" ]]; then - export FRAPPE_PY=0.0.0.0 -fi - -if [[ -z "$FRAPPE_PY_PORT" ]]; then - export FRAPPE_PY_PORT=8000 -fi - -if [[ -z "$FRAPPE_SOCKETIO" ]]; then - export FRAPPE_SOCKETIO=0.0.0.0 -fi - -if [[ -z "$SOCKETIO_PORT" ]]; then - export SOCKETIO_PORT=9000 -fi - -envsubst '${API_HOST} - ${API_PORT} - ${FRAPPE_PY} - ${FRAPPE_PY_PORT} - ${FRAPPE_SOCKETIO} - ${SOCKETIO_PORT}' \ - < /etc/nginx/conf.d/default.conf.template > /etc/nginx/conf.d/default.conf - -exec "$@" diff --git a/build/erpnext-assets/install_app.sh b/build/erpnext-assets/install_app.sh index eefa538a..dd05d228 100644 --- a/build/erpnext-assets/install_app.sh +++ b/build/erpnext-assets/install_app.sh @@ -27,3 +27,4 @@ yarn install --production=true mkdir -p /home/frappe/frappe-bench/sites/assets/${APP_NAME} cp -R /home/frappe/frappe-bench/apps/${APP_NAME}/${APP_NAME}/public/* /home/frappe/frappe-bench/sites/assets/${APP_NAME} +echo "rsync -a --delete /var/www/html/assets/${APP_NAME} /assets" > /rsync \ No newline at end of file diff --git a/build/erpnext-assets/v11.Dockerfile b/build/erpnext-assets/v11.Dockerfile index f46c2030..351cacb8 100644 --- a/build/erpnext-assets/v11.Dockerfile +++ b/build/erpnext-assets/v11.Dockerfile @@ -7,6 +7,7 @@ RUN /install_app erpnext https://github.com/frappe/erpnext version-11 FROM frappe/frappe-assets:v11 RUN cp /home/frappe/frappe-bench/sites/apps.txt /home/frappe/frappe-bench/sites/apps.bak COPY --from=0 /home/frappe/frappe-bench/sites/ /var/www/html/ +COPY --from=0 /rsync /rsync RUN mv /home/frappe/frappe-bench/sites/apps.bak /home/frappe/frappe-bench/sites/apps.txt \ && echo -n "\nerpnext" >> /home/frappe/frappe-bench/sites/apps.txt diff --git a/build/erpnext-assets/v12.Dockerfile b/build/erpnext-assets/v12.Dockerfile index cb29ea1b..83e163b3 100644 --- a/build/erpnext-assets/v12.Dockerfile +++ b/build/erpnext-assets/v12.Dockerfile @@ -7,6 +7,7 @@ RUN /install_app erpnext https://github.com/frappe/erpnext version-12 FROM frappe/frappe-assets:v12 RUN cp /home/frappe/frappe-bench/sites/apps.txt /home/frappe/frappe-bench/sites/apps.bak COPY --from=0 /home/frappe/frappe-bench/sites/ /var/www/html/ +COPY --from=0 /rsync /rsync RUN mv /home/frappe/frappe-bench/sites/apps.bak /home/frappe/frappe-bench/sites/apps.txt \ && echo -n "\nerpnext" >> /home/frappe/frappe-bench/sites/apps.txt VOLUME [ "/assets" ] diff --git a/build/frappe-assets/docker-entrypoint.sh b/build/frappe-assets/docker-entrypoint.sh index f68e7fd3..67128558 100755 --- a/build/frappe-assets/docker-entrypoint.sh +++ b/build/frappe-assets/docker-entrypoint.sh @@ -9,6 +9,7 @@ set -e rsync -a --delete /var/www/html/assets/js /assets rsync -a --delete /var/www/html/assets/css /assets rsync -a --delete /var/www/html/assets/frappe /assets +. /rsync chmod -R 755 /assets From 8eb26446da3cf5c58917511de9e64e0fc86f0a74 Mon Sep 17 00:00:00 2001 From: chabad360 Date: Wed, 4 Mar 2020 03:59:53 +0000 Subject: [PATCH 13/65] make this pr not make travis build on the wrong image --- .travis.yml | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8158bb93..47306180 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,9 +17,9 @@ before_install: after_success: - docker --version -matrix: +jobs: include: - - name: "Build Frappe python environment (edge)" + - stage: "Build Frappe python environment (edge)" if: branch = develop AND type != pull_request script: - docker build -t frappe-worker -f build/frappe-worker/Dockerfile . @@ -27,7 +27,7 @@ matrix: - docker tag frappe-worker frappe/frappe-worker:develop - docker push frappe/frappe-worker:edge - docker push frappe/frappe-worker:develop - - name: "Build Frappe nginx + static assets (edge)" + - stage: "Build Frappe nginx + static assets (edge)" if: branch = develop AND type != pull_request script: - docker build -t frappe-assets -f build/frappe-assets/Dockerfile . @@ -35,7 +35,7 @@ matrix: - docker tag frappe-assets frappe/frappe-assets:develop - docker push frappe/frappe-assets:edge - docker push frappe/frappe-assets:develop - - name: "Build ERPNext python environment (edge)" + - stage: "Build ERPNext python environment (edge)" if: branch = develop AND type != pull_request script: - docker build -t erpnext-worker -f build/erpnext-worker/Dockerfile . @@ -43,7 +43,7 @@ matrix: - docker tag erpnext-worker frappe/erpnext-worker:develop - docker push frappe/erpnext-worker:edge - docker push frappe/erpnext-worker:develop - - name: "Build ERPNext nginx + static assets (edge)" + - stage: "Build ERPNext nginx + static assets (edge)" if: branch = develop AND type != pull_request script: - docker build -t erpnext-assets -f build/erpnext-assets/Dockerfile . @@ -51,7 +51,7 @@ matrix: - docker tag erpnext-assets frappe/erpnext-assets:develop - docker push frappe/erpnext-assets:edge - docker push frappe/erpnext-assets:develop - - name: "Build Frappe socketio service (edge)" + - stage: "Build Frappe socketio service (edge)" if: branch = develop AND type != pull_request script: - docker build -t frappe-socketio -f build/frappe-socketio/Dockerfile . @@ -59,7 +59,7 @@ matrix: - docker tag frappe-socketio frappe/frappe-socketio:develop - docker push frappe/frappe-socketio:edge - docker push frappe/frappe-socketio:develop - - name: "Build Frappe python environment (v12)" + - stage: "Build Frappe python environment (v12)" if: branch = master AND type != pull_request script: - git clone https://github.com/frappe/frappe --branch version-12 @@ -73,7 +73,7 @@ matrix: - docker push frappe/frappe-worker:$VERSION - docker push frappe/frappe-worker:version-12 - docker push frappe/frappe-worker:v12 - - name: "Build Frappe nginx + static assets (v12)" + - stage: "Build Frappe nginx + static assets (v12)" if: branch = master AND type != pull_request script: - git clone https://github.com/frappe/frappe --branch version-12 @@ -87,7 +87,7 @@ matrix: - docker push frappe/frappe-assets:$VERSION - docker push frappe/frappe-assets:version-12 - docker push frappe/frappe-assets:v12 - - name: "Build ERPNext python environment (v12)" + - stage: "Build ERPNext python environment (v12)" if: branch = master AND type != pull_request script: - git clone https://github.com/frappe/erpnext --branch version-12 @@ -101,7 +101,7 @@ matrix: - docker push frappe/erpnext-worker:$VERSION - docker push frappe/erpnext-worker:version-12 - docker push frappe/erpnext-worker:v12 - - name: "Build ERPNext nginx + static assets (v12)" + - stage: "Build ERPNext nginx + static assets (v12)" if: branch = master AND type != pull_request script: - git clone https://github.com/frappe/erpnext --branch version-12 @@ -115,7 +115,7 @@ matrix: - docker push frappe/erpnext-assets:$VERSION - docker push frappe/erpnext-assets:version-12 - docker push frappe/erpnext-assets:v12 - - name: "Build Frappe socketio service (v12)" + - stage: "Build Frappe socketio service (v12)" if: branch = master AND type != pull_request script: - git clone https://github.com/frappe/frappe --branch version-12 @@ -129,7 +129,7 @@ matrix: - docker push frappe/frappe-socketio:$VERSION - docker push frappe/frappe-socketio:version-12 - docker push frappe/frappe-socketio:v12 - - name: "Build Frappe python environment (v11)" + - stage: "Build Frappe python environment (v11)" if: branch = master AND type != pull_request script: - git clone https://github.com/frappe/frappe --branch version-11 @@ -143,7 +143,7 @@ matrix: - docker push frappe/frappe-worker:$VERSION - docker push frappe/frappe-worker:version-11 - docker push frappe/frappe-worker:v11 - - name: "Build Frappe nginx + static assets (v11)" + - stage: "Build Frappe nginx + static assets (v11)" if: branch = master AND type != pull_request script: - git clone https://github.com/frappe/frappe --branch version-11 @@ -157,7 +157,7 @@ matrix: - docker push frappe/frappe-assets:$VERSION - docker push frappe/frappe-assets:version-11 - docker push frappe/frappe-assets:v11 - - name: "Build ERPNext python environment (v11)" + - stage: "Build ERPNext python environment (v11)" if: branch = master AND type != pull_request script: - git clone https://github.com/frappe/erpnext --branch version-11 @@ -171,7 +171,7 @@ matrix: - docker push frappe/erpnext-worker:$VERSION - docker push frappe/erpnext-worker:version-11 - docker push frappe/erpnext-worker:v11 - - name: "Build ERPNext nginx + static assets (v11)" + - stage: "Build ERPNext nginx + static assets (v11)" if: branch = master AND type != pull_request script: - git clone https://github.com/frappe/erpnext --branch version-11 @@ -185,7 +185,7 @@ matrix: - docker push frappe/erpnext-assets:$VERSION - docker push frappe/erpnext-assets:version-11 - docker push frappe/erpnext-assets:v11 - - name: "Build Frappe socketio service (v11)" + - stage: "Build Frappe socketio service (v11)" if: branch = master AND type != pull_request script: - git clone https://github.com/frappe/frappe --branch version-11 From 501d14472896c5e0658ab66e1807cf1cec127a3b Mon Sep 17 00:00:00 2001 From: Revant Nandgaonkar Date: Wed, 4 Mar 2020 14:36:13 +0530 Subject: [PATCH 14/65] fix: worker images new site command install apps is a list not boolean --- build/common/commands/new.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/common/commands/new.py b/build/common/commands/new.py index b87641db..973a6245 100644 --- a/build/common/commands/new.py +++ b/build/common/commands/new.py @@ -6,7 +6,7 @@ site_name = os.environ.get("SITE_NAME", 'site1.localhost') mariadb_root_username = os.environ.get("DB_ROOT_USER", 'root') mariadb_root_password = os.environ.get("MYSQL_ROOT_PASSWORD", 'admin') force = True if os.environ.get("FORCE", None) else False -install_apps = ['erpnext'] if os.environ.get("INSTALL_ERPNEXT", None) else False +install_apps = ['erpnext'] if os.environ.get("INSTALL_ERPNEXT", None) else [] frappe.init(site_name, new_site=True) _new_site( From 922877bf9269f6cfcf36b7fee7ade55df15306d5 Mon Sep 17 00:00:00 2001 From: Davide Bortolami Date: Wed, 4 Mar 2020 14:15:25 +0000 Subject: [PATCH 15/65] Fixes #101 Nginx will now wait up to 10 seconds for frappe-python and frappe-socketio to be available --- build/erpnext-assets/docker-entrypoint.sh | 7 +++++++ build/frappe-assets/docker-entrypoint.sh | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/build/erpnext-assets/docker-entrypoint.sh b/build/erpnext-assets/docker-entrypoint.sh index 4919fb34..2774a9f4 100755 --- a/build/erpnext-assets/docker-entrypoint.sh +++ b/build/erpnext-assets/docker-entrypoint.sh @@ -37,4 +37,11 @@ envsubst '${API_HOST} ${SOCKETIO_PORT}' \ < /etc/nginx/conf.d/default.conf.template > /etc/nginx/conf.d/default.conf +echo "Waiting for frappe-python to be available on $FRAPPE_PY port $FRAPPE_PY_PORT" +timeout 10 bash -c 'until printf "" 2>>/dev/null >>/dev/tcp/$0/$1; do sleep 1; done' $FRAPPE_PY $FRAPPE_PY_PORT +echo "Frappe-python available on $FRAPPE_PY port $FRAPPE_PY_PORT" +echo "Waiting for frappe-socketio to be available on $FRAPPE_PY port $FRAPPE_PY_PORT" +timeout 10 bash -c 'until printf "" 2>>/dev/null >>/dev/tcp/$0/$1; do sleep 1; done' $FRAPPE_SOCKETIO $SOCKETIO_PORT +echo "Frappe-socketio available on $FRAPPE_PY port $FRAPPE_PY_PORT" + exec "$@" diff --git a/build/frappe-assets/docker-entrypoint.sh b/build/frappe-assets/docker-entrypoint.sh index f68e7fd3..6603aad9 100755 --- a/build/frappe-assets/docker-entrypoint.sh +++ b/build/frappe-assets/docker-entrypoint.sh @@ -36,4 +36,11 @@ envsubst '${API_HOST} ${SOCKETIO_PORT}' \ < /etc/nginx/conf.d/default.conf.template > /etc/nginx/conf.d/default.conf +echo "Waiting for frappe-python to be available on $FRAPPE_PY port $FRAPPE_PY_PORT" +timeout 10 bash -c 'until printf "" 2>>/dev/null >>/dev/tcp/$0/$1; do sleep 1; done' $FRAPPE_PY $FRAPPE_PY_PORT +echo "Frappe-python available on $FRAPPE_PY port $FRAPPE_PY_PORT" +echo "Waiting for frappe-socketio to be available on $FRAPPE_PY port $FRAPPE_PY_PORT" +timeout 10 bash -c 'until printf "" 2>>/dev/null >>/dev/tcp/$0/$1; do sleep 1; done' $FRAPPE_SOCKETIO $SOCKETIO_PORT +echo "Frappe-socketio available on $FRAPPE_PY port $FRAPPE_PY_PORT" + exec "$@" From 63ae6cf9ea6a8255660b0dbbfa6140997b776cdb Mon Sep 17 00:00:00 2001 From: chabad360 Date: Wed, 4 Mar 2020 20:21:19 +0000 Subject: [PATCH 16/65] consistent use of f-strings --- travis.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/travis.py b/travis.py index 0be54695..1a5884a3 100755 --- a/travis.py +++ b/travis.py @@ -47,7 +47,7 @@ def main(): if args.version: tag = git_version(args.service, args.version) - dockerfile = 'v{!r}.Dockerfile'.format(args.version) + dockerfile = f'v{args.version}.Dockerfile' else: tag = args.tag dockerfile = 'Dockerfile' From 301e5e3ab629b565bd0da6db2d84eb655e861c94 Mon Sep 17 00:00:00 2001 From: chabad360 Date: Wed, 4 Mar 2020 20:27:53 +0000 Subject: [PATCH 17/65] a bit of refactoring --- travis.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/travis.py b/travis.py index 1a5884a3..06ed6c17 100755 --- a/travis.py +++ b/travis.py @@ -6,19 +6,18 @@ import os parser = argparse.ArgumentParser(description='frappe_docker common CI elements', add_help=True) +parser.add_argument('service', action='store', type=str, help='Name of the service to build: "erpnext" or "frappe"') +parser.add_argument('-o', '--tag-only', required=False, action='store_true', dest='tag_only', help='Only tag an image and push it.') + image_type = parser.add_mutually_exclusive_group(required=True) image_type.add_argument('-a', '--nginx', action='store_const', dest='image_type', const='nginx', help='Build the nginx + static assets image') image_type.add_argument('-s', '--socketio', action='store_const', dest='image_type', const='socketio', help='Build the frappe-socketio image') image_type.add_argument('-w', '--worker', action='store_const', dest='image_type', const='worker', help='Build the python environment image') -parser.add_argument('service', action='store', type=str, help='Name of the service to build: "erpnext" or "frappe"') - tag_type = parser.add_mutually_exclusive_group(required=True) tag_type.add_argument('-g', '--git-version', action='store', type=int, dest='version', help='The version number of --service (i.e. "11", "12", etc.)') tag_type.add_argument('-t', '--tag', action='store', type=str, dest='tag', help='The image tag (i.e. erpnext-worker:$TAG )') -parser.add_argument('-o', '--tag-only', required=False, action='store_true', dest='tag_only', help='Only tag an image and push it.') - args = parser.parse_args() def git_version(service, version): From aa3f5f32b247088fc4d30f3c3453ec124d8d9453 Mon Sep 17 00:00:00 2001 From: Revant Nandgaonkar Date: Thu, 5 Mar 2020 06:17:55 +0530 Subject: [PATCH 18/65] fix: travis py script --- travis.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/travis.py b/travis.py index 06ed6c17..02101369 100755 --- a/travis.py +++ b/travis.py @@ -1,4 +1,4 @@ -#!/bin/env python3 +#!/usr/bin/env python3 import argparse import subprocess From 70021c7e50f34e76946201f665cc6476a3ee42c6 Mon Sep 17 00:00:00 2001 From: Revant Nandgaonkar Date: Thu, 5 Mar 2020 06:34:26 +0530 Subject: [PATCH 19/65] fix: travis yml use to bionic --- .travis.yml | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index a01d8898..7042d7b0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ sudo: required -dist: xenial +dist: bionic services: - docker @@ -23,7 +23,7 @@ matrix: - name: "Build Frappe python environment (edge)" if: branch = develop AND type != pull_request script: - - ./travis.py frappe --worker --tag edge + - ./travis.py frappe --worker --tag edge - ./travis.py frappe --worker --tag develop --tag-only - name: "Build Frappe nginx + static assets (edge)" if: branch = develop AND type != pull_request @@ -38,7 +38,7 @@ matrix: - name: "Build ERPNext nginx + static assets (edge)" if: branch = develop AND type != pull_request script: - - ./travis.py erpnext --nginx --tag edge + - ./travis.py erpnext --nginx --tag edge - ./travis.py erpnext --nginx --tag develop --tag-only - name: "Build Frappe socketio service (edge)" if: branch = develop AND type != pull_request @@ -48,13 +48,13 @@ matrix: - name: "Build Frappe python environment (v12)" if: branch = master AND type != pull_request script: - - ./travis.py frappe --worker --git-branch 12 + - ./travis.py frappe --worker --git-branch 12 - ./travis.py frappe --worker --tag v12 --tag-only - ./travis.py frappe --worker --tag version-12 --tag-only - name: "Build Frappe nginx + static assets (v12)" if: branch = master AND type != pull_request script: - - ./travis.py frappe --nginx --git-branch 12 + - ./travis.py frappe --nginx --git-branch 12 - ./travis.py frappe --nginx --tag v12 --tag-only - ./travis.py frappe --nginx --tag version-12 --tag-only - name: "Build ERPNext python environment (v12)" @@ -78,13 +78,13 @@ matrix: - name: "Build Frappe python environment (v11)" if: branch = master AND type != pull_request script: - - ./travis.py frappe --worker --git-branch 11 + - ./travis.py frappe --worker --git-branch 11 - ./travis.py frappe --worker --tag v11 --tag-only - ./travis.py frappe --worker --tag version-11 --tag-only - name: "Build Frappe nginx + static assets (v11)" if: branch = master AND type != pull_request script: - - ./travis.py erpnext frappe --nginx --git-branch 11 + - ./travis.py erpnext frappe --nginx --git-branch 11 - ./travis.py erpnext frappe --nginx --tag v11 --tag-only - ./travis.py erpnext frappe --nginx --tag version-11 --tag-only - name: "Build ERPNext python environment (v11)" @@ -105,5 +105,3 @@ matrix: - ./travis.py frappe --socketio --git-branch 11 - ./travis.py frappe --socketio --tag v11 --tag-only - ./travis.py frappe --socketio --tag version-11 --tag-only - - \ No newline at end of file From 959ab4fc7d294f5edf5b0acb652fac2399ce04b7 Mon Sep 17 00:00:00 2001 From: chabad360 Date: Thu, 5 Mar 2020 01:38:01 +0000 Subject: [PATCH 20/65] one small change to support multi-tenancy --- build/common/commands/new.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/common/commands/new.py b/build/common/commands/new.py index b87641db..4cc13a28 100644 --- a/build/common/commands/new.py +++ b/build/common/commands/new.py @@ -6,7 +6,7 @@ site_name = os.environ.get("SITE_NAME", 'site1.localhost') mariadb_root_username = os.environ.get("DB_ROOT_USER", 'root') mariadb_root_password = os.environ.get("MYSQL_ROOT_PASSWORD", 'admin') force = True if os.environ.get("FORCE", None) else False -install_apps = ['erpnext'] if os.environ.get("INSTALL_ERPNEXT", None) else False +install_apps = os.environ.get("INSTALL_APPS").split(",") frappe.init(site_name, new_site=True) _new_site( From 5cf8e68327bc248989bb5770b1c58dc6de272626 Mon Sep 17 00:00:00 2001 From: chabad360 Date: Thu, 5 Mar 2020 02:00:54 +0000 Subject: [PATCH 21/65] update docs for INSTALL_APPS --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 611cde45..bef76892 100644 --- a/README.md +++ b/README.md @@ -105,7 +105,7 @@ docker exec -it \ -e "DB_ROOT_USER=$DB_ROOT_USER" \ -e "MYSQL_ROOT_PASSWORD=$MYSQL_ROOT_PASSWORD" \ -e "ADMIN_PASSWORD=$ADMIN_PASSWORD" \ - -e "INSTALL_ERPNEXT=1" \ + -e "INSTALL_APPS='erpnext'" \ _erpnext-python_1 docker-entrypoint.sh new ``` @@ -115,7 +115,7 @@ Environment Variables needed: - `DB_ROOT_USER`: MariaDB Root user. The user that can create databases. - `MYSQL_ROOT_PASSWORD`: In case of mariadb docker container use the one set in `MYSQL_ROOT_PASSWORD` in previous steps. In case of managed database use appropriate password. - `ADMIN_PASSWORD`: set the administrator password for new site. -- `INSTALL_ERPNEXT=1`: available only in erpnext-worker and erpnext containers. Installs ERPNext on this new site. +- `INSTALL_APPS='erpnext'`: available only in erpnext-worker and erpnext containers (or other containers with custom apps). Installs ERPNext (and/or the specified apps, comma-delinieated) on this new site. - `FORCE=1`: is optional variable which force installs the same site. #### Backup Sites From b254e018e54a281c53c6a49ec83e2c9bc79700cc Mon Sep 17 00:00:00 2001 From: chabad360 Date: Thu, 5 Mar 2020 02:28:42 +0000 Subject: [PATCH 22/65] shave off a layer --- build/erpnext-assets/Dockerfile | 5 ++--- build/erpnext-assets/install_app.sh | 4 +++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/build/erpnext-assets/Dockerfile b/build/erpnext-assets/Dockerfile index 9e966d53..8ea44946 100644 --- a/build/erpnext-assets/Dockerfile +++ b/build/erpnext-assets/Dockerfile @@ -5,11 +5,10 @@ COPY build/erpnext-assets/install_app.sh /install_app RUN /install_app erpnext https://github.com/frappe/erpnext FROM frappe/frappe-assets:develop -RUN cp /home/frappe/frappe-bench/sites/apps.txt /home/frappe/frappe-bench/sites/apps.bak + COPY --from=0 /home/frappe/frappe-bench/sites/ /var/www/html/ COPY --from=0 /rsync /rsync -RUN mv /home/frappe/frappe-bench/sites/apps.bak /home/frappe/frappe-bench/sites/apps.txt \ - && echo -n "\nerpnext" >> /home/frappe/frappe-bench/sites/apps.txt +RUN echo -n "\nerpnext" >> /var/www/html/apps.txt VOLUME [ "/assets" ] diff --git a/build/erpnext-assets/install_app.sh b/build/erpnext-assets/install_app.sh index dd05d228..aa3cd98c 100644 --- a/build/erpnext-assets/install_app.sh +++ b/build/erpnext-assets/install_app.sh @@ -27,4 +27,6 @@ yarn install --production=true mkdir -p /home/frappe/frappe-bench/sites/assets/${APP_NAME} cp -R /home/frappe/frappe-bench/apps/${APP_NAME}/${APP_NAME}/public/* /home/frappe/frappe-bench/sites/assets/${APP_NAME} -echo "rsync -a --delete /var/www/html/assets/${APP_NAME} /assets" > /rsync \ No newline at end of file +echo "rsync -a --delete /var/www/html/assets/${APP_NAME} /assets" > /rsync + +rm /home/frappe/frappe-bench/sites/apps.txt \ No newline at end of file From d071bf232db3b4b2a1756944e7253587f4861986 Mon Sep 17 00:00:00 2001 From: Revant Nandgaonkar Date: Thu, 5 Mar 2020 21:39:03 +0530 Subject: [PATCH 23/65] feat: development docker --- .devcontainer/devcontainer.json | 12 +++ .devcontainer/docker-compose.yml | 30 ++++++++ .gitignore | 2 + .travis.yml | 13 +++- build/bench/Dockerfile | 58 +++++++++++++++ development/.vscode/launch.json | 22 ++++++ development/.vscode/settings.json | 4 + development/README.md | 118 ++++++++++++++++++++++++++++++ 8 files changed, 255 insertions(+), 4 deletions(-) create mode 100644 .devcontainer/devcontainer.json create mode 100644 .devcontainer/docker-compose.yml create mode 100644 build/bench/Dockerfile create mode 100644 development/.vscode/launch.json create mode 100644 development/.vscode/settings.json create mode 100644 development/README.md diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000..4bab99fc --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,12 @@ +{ + "name": "Frappe Bench", + "appPort": [8000, 9000, 6787], + "remoteUser": "frappe", + "settings": { + "terminal.integrated.shell.linux": "/bin/bash" + }, + "dockerComposeFile": "./docker-compose.yml", + "service": "frappe", + "workspaceFolder": "/workspace/development", + "shutdownAction": "stopCompose" +} diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml new file mode 100644 index 00000000..2d43b0c6 --- /dev/null +++ b/.devcontainer/docker-compose.yml @@ -0,0 +1,30 @@ +version: "3.7" +services: + mariadb: + image: mariadb:10.3 + environment: + - MYSQL_ROOT_PASSWORD=123 + - MYSQL_USER=root + volumes: + - ../installation/frappe-mariadb.cnf:/etc/mysql/conf.d/frappe.cnf + - mariadb-vol:/var/lib/mysql + + redis-cache: + image: redis:alpine + + redis-queue: + image: redis:alpine + + redis-socketio: + image: redis:alpine + + frappe: + image: frappe/bench:latest + command: sleep infinity + volumes: + - ..:/workspace:cached + ports: + - "8000:8000" + +volumes: + mariadb-vol: diff --git a/.gitignore b/.gitignore index 502c3673..cb373cae 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,5 @@ # mounted volume sites + +development diff --git a/.travis.yml b/.travis.yml index 7042d7b0..d8d22dff 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,12 +20,17 @@ after_success: matrix: include: - - name: "Build Frappe python environment (edge)" + - name: "Build Frappe bench development environment(latest)" if: branch = develop AND type != pull_request script: - - ./travis.py frappe --worker --tag edge - - ./travis.py frappe --worker --tag develop --tag-only - - name: "Build Frappe nginx + static assets (edge)" + - docker build -t frappe/bench:latest -f build/bench/Dockerfile . + - docker push frappe/bench:latest + - name: "Build Frappe python environment (edge)" + if: branch = develop AND type != pull_request + script: + - ./travis.py frappe --nginx --tag edge + - ./travis.py frappe --nginx --tag develop--tag-only + - name: "Build Frappe nginx + static assets (edge)" if: branch = develop AND type != pull_request script: - ./travis.py frappe --nginx --tag edge diff --git a/build/bench/Dockerfile b/build/bench/Dockerfile new file mode 100644 index 00000000..3f153bc7 --- /dev/null +++ b/build/bench/Dockerfile @@ -0,0 +1,58 @@ +# Frappe Bench Dockerfile + +FROM debian:9.6-slim +LABEL author=frappé + +RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends locales \ + && sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen \ + && dpkg-reconfigure --frontend=noninteractive locales \ + && apt-get clean && rm -rf /var/lib/apt/lists/* + +# Set locale en_us.UTF-8 for mariadb and general locale data +ENV PYTHONIOENCODING=utf-8 +ENV LANGUAGE=en_US.UTF-8 +ENV LANG=en_US.UTF-8 +ENV LC_ALL=en_US.UTF-8 + +# Install all neccesary packages +RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-suggests --no-install-recommends \ + build-essential cron curl git libffi-dev liblcms2-dev libldap2-dev libmariadbclient-dev libsasl2-dev libssl1.0-dev libtiff5-dev \ + libwebp-dev mariadb-client iputils-ping python3-dev python3-pip python3-setuptools python3-tk redis-tools rlwrap \ + software-properties-common sudo tk8.6-dev vim xfonts-75dpi xfonts-base wget wkhtmltopdf fonts-cantarell \ + && apt-get clean && rm -rf /var/lib/apt/lists/* + +# Install nvm with node +ENV NVM_DIR /usr/local/nvm +ENV NODE_VERSION 12.16.1 +RUN mkdir /usr/local/nvm \ + && wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.35.2/install.sh | bash \ + && . $NVM_DIR/nvm.sh \ + && nvm install $NODE_VERSION \ + && nvm install 10.19.0 \ + && nvm alias default $NODE_VERSION \ + && nvm use default \ + && npm install yarn -g +ENV NODE_PATH $NVM_DIR/v$NODE_VERSION/lib/node_modules +ENV PATH $NVM_DIR/v$NODE_VERSION/bin:$PATH + +# Install wkhtmltox correctly +RUN wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.stretch_amd64.deb +RUN dpkg -i wkhtmltox_0.12.5-1.stretch_amd64.deb && rm wkhtmltox_0.12.5-1.stretch_amd64.deb + + +# Add frappe user and setup sudo +RUN groupadd -g 1000 frappe \ + && useradd -ms /bin/bash -u 1000 -g 1000 -G sudo frappe \ + && chown -R 1000:1000 /home/frappe \ + && echo '. "$NVM_DIR/nvm.sh"' >> /home/frappe/.bashrc + +# Install bench +RUN pip3 install -e git+https://github.com/frappe/bench.git#egg=bench --no-cache + +USER frappe + +WORKDIR /home/frappe/frappe-bench + +EXPOSE 8000 9000 6787 + +VOLUME [ "/home/frappe/frappe-bench" ] diff --git a/development/.vscode/launch.json b/development/.vscode/launch.json new file mode 100644 index 00000000..21867b35 --- /dev/null +++ b/development/.vscode/launch.json @@ -0,0 +1,22 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Bench", + "type": "python", + "request": "launch", + "program": "${workspaceFolder}/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", + "args": [ + "frappe", "serve", "--port", "8000", "--noreload", "--nothreading" + ], + "pythonPath": "${workspaceFolder}/frappe-bench/env/bin/python", + "cwd": "${workspaceFolder}/frappe-bench/sites", + "env": { + "DEV_SERVER": "1" + } + } + ] +} \ No newline at end of file diff --git a/development/.vscode/settings.json b/development/.vscode/settings.json new file mode 100644 index 00000000..17a5d56d --- /dev/null +++ b/development/.vscode/settings.json @@ -0,0 +1,4 @@ +{ + "python.pythonPath": "frappe-bench/env/bin/python", + "debug.node.autoAttach": "on" +} \ No newline at end of file diff --git a/development/README.md b/development/README.md new file mode 100644 index 00000000..ba2aa311 --- /dev/null +++ b/development/README.md @@ -0,0 +1,118 @@ +# Getting Started + +## Prerequisites + +- Docker +- docker-compose +- user added to docker group + +### Bootstrap Containers for development + +Clone and change working directory to frappe_docker directory + +```shell +git clone https://github.com/frappe/frappe_docker.git +cd frappe_docker +``` + +#### Manually start containers + +```shell +docker-compose -f .devcontainer/docker-compose.yml up -d +``` + +Enter the bench container + +```shell +docker exec -e "TERM=xterm-256color" -w /workspace/development -it frappe bash +``` + +#### Use VSCode Remote Containers extension + +- Install Remote Development Pack / Remote Containers extension +- Install VSCode Python extension +- Open frappe_docker in VSCode +- From Command Palette (Ctrl + Shift + P) Execute Remote Containers : Reopen in Container + +### Setup Docker specific bench environment + +Notes: + +- `development` directory is ignored by it. It is mounted and available in container. Create all your benches inside this directory +- Execute these commands from container +- nvm with node v12 and v10 is installed. Check with `nvm ls`. Node v12 is default + +#### Setup first bench + +```shell +bench init --skip-redis-config-generation --frappe-branch version-12 frappe-bench +cd frappe-bench +``` + +#### Set hosts + +```shell +bench set-mariadb-host mariadb +bench set-redis-cache-host redis-cache:6379 +bench set-redis-queue-host redis-queue:6379 +bench set-redis-socketio-host redis-socketio:6379 +``` + +#### Changes related to bench start / honcho / Procfile + +- honcho/Procfile starts processes required for development. +- By default Procfile has 3 redis processes that it starts. Comment (`#`) or remove these lines and then run `bench start`. +- Another option is to run following command + +```shell +honcho start \ + web \ + socketio \ + watch \ + schedule \ + worker_short \ + worker_long \ + worker_default +``` + +#### Changes related to MariaDB + +Notes: + +- `bench new-site` command creates a user in mariadb with container IP as host +- After rebuilding container there is a chance that new bench container will not be able to access mariadb +- `'db_name'@'%'` needs to be set in mariadb and permission to the site database be given to the user +- Replace `db_name` and `db_password` from site's `site_config.json` +- MariaDB root password is 123 + +Enter mariadb shell + +```shell +mysql -uroot -p123 -hmariadb +``` + +Execute following queries + +```sql +UPDATE mysql.user SET Host = '%' where User = 'db_name'; FLUSH PRIVILEGES; +SET PASSWORD FOR 'db_name'@'%' = PASSWORD('db_password'); FLUSH PRIVILEGES; +GRANT ALL PRIVILEGES ON `db_name`.* TO 'db_name'@'%'; FLUSH PRIVILEGES; +``` + +### Visual Studio Code Python Debugging + +- Install VSCode Python Extension once in remote container +- Reload VSCode +- Do not start `web` process with honcho + +```shell +honcho start \ + socketio \ + watch \ + schedule \ + worker_short \ + worker_long \ + worker_default +``` + +- On debugger tab, Connect debugger. This will start the web process with debugger connected From 4771feee06ea5c9e89471e0e67ea5b262ac790d2 Mon Sep 17 00:00:00 2001 From: Revant Nandgaonkar Date: Thu, 5 Mar 2020 22:04:43 +0530 Subject: [PATCH 24/65] fix: travis yml formatting --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index d8d22dff..60881c42 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,7 +20,7 @@ after_success: matrix: include: - - name: "Build Frappe bench development environment(latest)" + - name: "Build Frappe bench development environment (latest)" if: branch = develop AND type != pull_request script: - docker build -t frappe/bench:latest -f build/bench/Dockerfile . @@ -30,7 +30,7 @@ matrix: script: - ./travis.py frappe --nginx --tag edge - ./travis.py frappe --nginx --tag develop--tag-only - - name: "Build Frappe nginx + static assets (edge)" + - name: "Build Frappe nginx + static assets (edge)" if: branch = develop AND type != pull_request script: - ./travis.py frappe --nginx --tag edge From 71763673b8f687416364381a76ebe6e6517e9c72 Mon Sep 17 00:00:00 2001 From: Davide Bortolami Date: Thu, 5 Mar 2020 16:39:32 +0000 Subject: [PATCH 25/65] merged documentation changes --- README.md | 136 +++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 105 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index 611cde45..778f3680 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -### Getting Started +## Getting Started The templates in this repository will help deploy Frappe/ERPNext docker in a production environment. @@ -8,31 +8,13 @@ This docker installation takes care of the following: * Setting up all the system requirements: eg. MariaDB, Node, Redis. * [OPTIONAL] Configuring networking for remote access and setting up LetsEncrypt -### Installation Process +## Deployment -#### Setting up Pre-requisites +### Setting up Pre-requisites This repository requires Docker and Git to be setup on the instance to be used. -#### Setup Letsencrypt Nginx Proxy Companion - -This is an optional first step. This step is only required if you want to have SSL setup on your docker instance. - -This step also assumes that the DNS is preconfigured since it automatically handles setup and renewal of SSL certificates. - -For more details, see: https://github.com/evertramos/docker-compose-letsencrypt-nginx-proxy-companion - -To setup the proxy companion, run the following steps: - -```sh -cd $HOME -git clone https://github.com/evertramos/docker-compose-letsencrypt-nginx-proxy-companion.git -cd docker-compose-letsencrypt-nginx-proxy-companion -cp .env.sample .env -./start.sh -``` - -#### Setting up Frappe/ERPNext Docker +### Cloning the repository and preliminary steps Clone this repository somewhere in your system: @@ -43,7 +25,7 @@ cd frappe_docker Copy the example docker environment file to `.env`: -``` +```sh cp installation/env-example installation/.env ``` @@ -53,9 +35,7 @@ Make a directory for sites: mkdir installation/sites ``` -#### Setup Environment Variables - -Docker allows passing an environment file to aide in setting up containers, which is used by this repository to pass secret and variable data. +### Setup Environment Variables To get started, copy the existing `env-example` file to `.env` inside the `installation` directory. By default, the file will contain the following variables: @@ -68,13 +48,70 @@ To get started, copy the existing `env-example` file to `.env` inside the `insta - In case of a separately managed database setup, set the value to the database's hostname/IP/domain. - `SITES=site1.domain.com,site2.domain.com` - List of sites that are part of the deployment "bench". Each site is separated by a comma(,). - - If LetsEncrypt is being setup, make sure that the DNS for all the site domains are pointing to the current instance. + - If LetsEncrypt is being setup, make sure that the DNS for all the site's domains are pointing to the current instance. - `LETSENCRYPT_EMAIL=your.email@your.domain.com` - - Email for LetsEncrypt expiry notification. This is only required if you are setting up the nginx proxy companion. + - Email for LetsEncrypt expiry notification. This is only required if you are setting up LetsEncrypt. + + +### Deployment for local development + +To start the Frappe/ERPNext services for production, run the following command: + +For Erpnext: + + +```sh +docker-compose \ + --project-name \ + -f installation/docker-compose-common.yml \ + -f installation/docker-compose-erpnext.yml \ + -f installation/docker-compose-networks.yml \ + --project-directory installation run --publish 80:80 erpnext-nginx +``` + +For Frappe: +```sh +docker-compose \ + --project-name \ + -f installation/docker-compose-common.yml \ + -f installation/docker-compose-frappe.yml \ + -f installation/docker-compose-networks.yml \ + --project-directory installation run --publish 80:80 frappe-nginx +``` + +Make sure to replace `` with any desired name you wish to set for the project. + +Note: this command does not run docker-compose in daemon mode. You will need to keep the terminal window open. +Note: the local deployment is for testing only. The site names are limited to patterns matching \*.localhost. + + +### Deployment for production + +#### Setup Letsencrypt Nginx Proxy Companion + + + +Letsencrypt Nginx Proxy Companion can optionally be setup to provide SSL. This is recommended for istances accessed over the internet. + +Your DNS will need to be configured correctly in order for Letsencrypt to verify your domain. + +To setup the proxy companion, run the following commands: + +```sh +cd $HOME +git clone https://github.com/evertramos/docker-compose-letsencrypt-nginx-proxy-companion.git +cd docker-compose-letsencrypt-nginx-proxy-companion +cp .env.sample .env +./start.sh +``` + +For more details, see: https://github.com/evertramos/docker-compose-letsencrypt-nginx-proxy-companion +Letsencrypt Nginx Proxy Companion works by automatically proxing to containers with the `VIRTUAL_HOST` environmental variable. + #### Start Frappe/ERPNext Services -To start the Frappe/ERPNext services, run the following command: +To start the Frappe/ERPNext services for production, run the following command: ```sh docker-compose \ @@ -86,8 +123,45 @@ docker-compose \ ``` Make sure to replace `` with any desired name you wish to set for the project. +Note: use `docker-compose-frappe.yml` in case you need only Frappe without ERPNext. -Note: use `docker-compose-frappe.yml` in case you need bench with just frappe installed. + +### Docker containers + +This repository contains the following docker-compose files each one containing the described images: +* docker-compose-common.yml + * redis-cache + * volume: redis-cache-vol + * redis-queue + * volume: redis-queue-vol + * redis-socketio + * volume: redis-socketio-vol + * mariadb: main database + * volume: mariadb-vol +* docker-compose-erpnext.yml + * erpnext-nginx: serves static assets and proxies web request to the appropriate container, allowing to offer all services on the same port. + * volume: assets + * erpnext-python: main application code + * frappe-socketio: enables realtime comunication to the user interface through websockets + * frappe-worker-default: background runner + * frappe-worker-short: background runner for short-running jobs + * frappe-worker-long: background runner for long-running jobs + * frappe-schedule + +* docker-compose-frappe.yml + * frappe-nginx: serves static assets and proxies web request to the appropriate container, allowing to offer all services on the same port. + * volume: assets + * erpnext-python: main application code + * frappe-socketio: enables realtime comunication to the user interface through websockets + * frappe-worker-default: background runner + * frappe-worker-short: background runner for short-running jobs + * frappe-worker-long: background runner for long-running jobs + * frappe-schedule + +* docker-compose-networks.yml: this yml define the network to comunicate with *Letsencrypt Nginx Proxy Companion*. + + +### Site operations #### Setup New Sites @@ -161,7 +235,7 @@ docker exec -it \ _erpnext-python_1 docker-entrypoint.sh migrate ``` -### Troubleshoot +## Troubleshoot 1. Remove containers and volumes, and clear redis cache: From 7477e53428fc8e2389254de8680fbd2aa72271a0 Mon Sep 17 00:00:00 2001 From: Revant Nandgaonkar Date: Thu, 5 Mar 2020 22:25:11 +0530 Subject: [PATCH 26/65] fix: travis yml indent error --- .travis.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 60881c42..f6fda31b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,10 +26,10 @@ matrix: - docker build -t frappe/bench:latest -f build/bench/Dockerfile . - docker push frappe/bench:latest - name: "Build Frappe python environment (edge)" - if: branch = develop AND type != pull_request - script: - - ./travis.py frappe --nginx --tag edge - - ./travis.py frappe --nginx --tag develop--tag-only + if: branch = develop AND type != pull_request + script: + - ./travis.py frappe --nginx --tag edge + - ./travis.py frappe --nginx --tag develop--tag-only - name: "Build Frappe nginx + static assets (edge)" if: branch = develop AND type != pull_request script: From be3d90dd03d35948ad7da27fed7ac0a631476c31 Mon Sep 17 00:00:00 2001 From: Revant Nandgaonkar Date: Thu, 5 Mar 2020 23:49:48 +0530 Subject: [PATCH 27/65] fix: bench image install nvm in user home allows npm install -g install yarn in v10 --- build/bench/Dockerfile | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/build/bench/Dockerfile b/build/bench/Dockerfile index 3f153bc7..a0f599ee 100644 --- a/build/bench/Dockerfile +++ b/build/bench/Dockerfile @@ -21,17 +21,25 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-ins software-properties-common sudo tk8.6-dev vim xfonts-75dpi xfonts-base wget wkhtmltopdf fonts-cantarell \ && apt-get clean && rm -rf /var/lib/apt/lists/* +# Add frappe user and setup sudo +RUN groupadd -g 1000 frappe \ + && useradd -ms /bin/bash -u 1000 -g 1000 -G sudo frappe \ + && chown -R 1000:1000 /home/frappe \ + && echo '. "$NVM_DIR/nvm.sh"' >> /home/frappe/.bashrc + # Install nvm with node -ENV NVM_DIR /usr/local/nvm +ENV NVM_DIR /home/frappe/.nvm ENV NODE_VERSION 12.16.1 -RUN mkdir /usr/local/nvm \ +RUN mkdir /home/frappe/.nvm \ && wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.35.2/install.sh | bash \ && . $NVM_DIR/nvm.sh \ && nvm install $NODE_VERSION \ && nvm install 10.19.0 \ + && npm install yarn -g \ && nvm alias default $NODE_VERSION \ && nvm use default \ - && npm install yarn -g + && npm install yarn -g \ + && chown -R frappe:frappe /home/frappe ENV NODE_PATH $NVM_DIR/v$NODE_VERSION/lib/node_modules ENV PATH $NVM_DIR/v$NODE_VERSION/bin:$PATH @@ -39,13 +47,6 @@ ENV PATH $NVM_DIR/v$NODE_VERSION/bin:$PATH RUN wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.stretch_amd64.deb RUN dpkg -i wkhtmltox_0.12.5-1.stretch_amd64.deb && rm wkhtmltox_0.12.5-1.stretch_amd64.deb - -# Add frappe user and setup sudo -RUN groupadd -g 1000 frappe \ - && useradd -ms /bin/bash -u 1000 -g 1000 -G sudo frappe \ - && chown -R 1000:1000 /home/frappe \ - && echo '. "$NVM_DIR/nvm.sh"' >> /home/frappe/.bashrc - # Install bench RUN pip3 install -e git+https://github.com/frappe/bench.git#egg=bench --no-cache From 2f085ea2349ca20985524508cdcf2546cb0e221d Mon Sep 17 00:00:00 2001 From: Revant Nandgaonkar Date: Fri, 6 Mar 2020 06:45:54 +0530 Subject: [PATCH 28/65] fix: Improve README(s) --- README.md | 63 +++++++++++++++++++++++++++---------------- development/README.md | 39 +++++++++++++++------------ 2 files changed, 62 insertions(+), 40 deletions(-) diff --git a/README.md b/README.md index 778f3680..9aadc8ef 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,8 @@ This docker installation takes care of the following: * Setting up all the system requirements: eg. MariaDB, Node, Redis. * [OPTIONAL] Configuring networking for remote access and setting up LetsEncrypt +For docker based development refer this [README](development/README.md) + ## Deployment ### Setting up Pre-requisites @@ -53,45 +55,62 @@ To get started, copy the existing `env-example` file to `.env` inside the `insta - Email for LetsEncrypt expiry notification. This is only required if you are setting up LetsEncrypt. -### Deployment for local development +### Local deployment -To start the Frappe/ERPNext services for production, run the following command: +For trying out locally or to develop apps using ERPNext ReST API port 80 must be published. +First start the containers and then run an additional command to publish port of *-nginx container. + +To start and publish Frappe/ERPNext services as local api, run the following commands: For Erpnext: - ```sh -docker-compose \ +# Start services +docker-compose \ --project-name \ -f installation/docker-compose-common.yml \ -f installation/docker-compose-erpnext.yml \ - -f installation/docker-compose-networks.yml \ - --project-directory installation run --publish 80:80 erpnext-nginx + --project-directory installation up -d + +# Publish port +docker-compose \ + --project-name \ + -f installation/docker-compose-common.yml \ + -f installation/docker-compose-erpnext.yml \ + --project-directory installation run --publish 80:80 -d erpnext-nginx ``` For Frappe: + ```sh -docker-compose \ +# Start services +docker-compose \ --project-name \ -f installation/docker-compose-common.yml \ -f installation/docker-compose-frappe.yml \ - -f installation/docker-compose-networks.yml \ - --project-directory installation run --publish 80:80 frappe-nginx + --project-directory installation up -d + +# Publish port +docker-compose \ + --project-name \ + -f installation/docker-compose-common.yml \ + -f installation/docker-compose-frappe.yml \ + --project-directory installation run --publish 80:80 -d frappe-nginx ``` Make sure to replace `` with any desired name you wish to set for the project. -Note: this command does not run docker-compose in daemon mode. You will need to keep the terminal window open. -Note: the local deployment is for testing only. The site names are limited to patterns matching \*.localhost. - +Note: + - This command adds an additional container for frappe-nginx with published ports. + - The local deployment is for testing and REST API development purpose only. + - The site names are limited to patterns matching \*.localhost by default + - Additional site name patterns can be added to /etc/hosts of desired container or host ### Deployment for production #### Setup Letsencrypt Nginx Proxy Companion - - -Letsencrypt Nginx Proxy Companion can optionally be setup to provide SSL. This is recommended for istances accessed over the internet. +Letsencrypt Nginx Proxy Companion can optionally be setup to provide SSL. This is recommended for instances accessed over the internet. Your DNS will need to be configured correctly in order for Letsencrypt to verify your domain. @@ -106,8 +125,7 @@ cp .env.sample .env ``` For more details, see: https://github.com/evertramos/docker-compose-letsencrypt-nginx-proxy-companion -Letsencrypt Nginx Proxy Companion works by automatically proxing to containers with the `VIRTUAL_HOST` environmental variable. - +Letsencrypt Nginx Proxy Companion works by automatically proxying to containers with the `VIRTUAL_HOST` environmental variable. #### Start Frappe/ERPNext Services @@ -125,7 +143,6 @@ docker-compose \ Make sure to replace `` with any desired name you wish to set for the project. Note: use `docker-compose-frappe.yml` in case you need only Frappe without ERPNext. - ### Docker containers This repository contains the following docker-compose files each one containing the described images: @@ -139,26 +156,26 @@ This repository contains the following docker-compose files each one containing * mariadb: main database * volume: mariadb-vol * docker-compose-erpnext.yml - * erpnext-nginx: serves static assets and proxies web request to the appropriate container, allowing to offer all services on the same port. + * erpnext-nginx: serves static assets and proxies web request to the appropriate container, allowing to offer all services on the same port. * volume: assets * erpnext-python: main application code - * frappe-socketio: enables realtime comunication to the user interface through websockets + * frappe-socketio: enables realtime communication to the user interface through websockets * frappe-worker-default: background runner * frappe-worker-short: background runner for short-running jobs * frappe-worker-long: background runner for long-running jobs * frappe-schedule * docker-compose-frappe.yml - * frappe-nginx: serves static assets and proxies web request to the appropriate container, allowing to offer all services on the same port. + * frappe-nginx: serves static assets and proxies web request to the appropriate container, allowing to offer all services on the same port. * volume: assets * erpnext-python: main application code - * frappe-socketio: enables realtime comunication to the user interface through websockets + * frappe-socketio: enables realtime communication to the user interface through websockets * frappe-worker-default: background runner * frappe-worker-short: background runner for short-running jobs * frappe-worker-long: background runner for long-running jobs * frappe-schedule -* docker-compose-networks.yml: this yml define the network to comunicate with *Letsencrypt Nginx Proxy Companion*. +* docker-compose-networks.yml: this yml define the network to communicate with *Letsencrypt Nginx Proxy Companion*. ### Site operations diff --git a/development/README.md b/development/README.md index ba2aa311..c7d78071 100644 --- a/development/README.md +++ b/development/README.md @@ -8,7 +8,7 @@ ### Bootstrap Containers for development -Clone and change working directory to frappe_docker directory +Clone and change to frappe_docker directory ```shell git clone https://github.com/frappe/frappe_docker.git @@ -17,30 +17,34 @@ cd frappe_docker #### Manually start containers +In case VS Code is not used follow these steps. + ```shell docker-compose -f .devcontainer/docker-compose.yml up -d ``` -Enter the bench container +Enter the bench container at location `/workspace/development` ```shell -docker exec -e "TERM=xterm-256color" -w /workspace/development -it frappe bash +docker exec -e "TERM=xterm-256color" -w /workspace/development -it devcontainer_frappe_1 bash ``` -#### Use VSCode Remote Containers extension +#### Use VS Code Remote Containers extension -- Install Remote Development Pack / Remote Containers extension -- Install VSCode Python extension -- Open frappe_docker in VSCode -- From Command Palette (Ctrl + Shift + P) Execute Remote Containers : Reopen in Container +Follow these in case VS Code is used. Do not start containers manually. + +- Install Remote Development Pack / Remote Containers extension. +- Install VS Code Python extension. +- Open frappe_docker in VS Code. +- From Command Palette (Ctrl + Shift + P) Execute Remote Containers : Reopen in Container. ### Setup Docker specific bench environment Notes: -- `development` directory is ignored by it. It is mounted and available in container. Create all your benches inside this directory -- Execute these commands from container -- nvm with node v12 and v10 is installed. Check with `nvm ls`. Node v12 is default +- `development` directory is ignored by git. It is mounted and available in container. Create all your benches inside this directory. +- Execute these commands from container. +- nvm with node v12 and v10 is installed. Check with `nvm ls`. Node v12 is default. #### Setup first bench @@ -62,7 +66,7 @@ bench set-redis-socketio-host redis-socketio:6379 - honcho/Procfile starts processes required for development. - By default Procfile has 3 redis processes that it starts. Comment (`#`) or remove these lines and then run `bench start`. -- Another option is to run following command +- Another option is to run following command : ```shell honcho start \ @@ -94,15 +98,16 @@ mysql -uroot -p123 -hmariadb Execute following queries ```sql -UPDATE mysql.user SET Host = '%' where User = 'db_name'; FLUSH PRIVILEGES; -SET PASSWORD FOR 'db_name'@'%' = PASSWORD('db_password'); FLUSH PRIVILEGES; -GRANT ALL PRIVILEGES ON `db_name`.* TO 'db_name'@'%'; FLUSH PRIVILEGES; +UPDATE mysql.user SET Host = '%' where User = 'db_name'; +SET PASSWORD FOR 'db_name'@'%' = PASSWORD('db_password'); +GRANT ALL PRIVILEGES ON `db_name`.* TO 'db_name'@'%'; +FLUSH PRIVILEGES; ``` ### Visual Studio Code Python Debugging -- Install VSCode Python Extension once in remote container -- Reload VSCode +- Install VS Code Python Extension once in remote container +- Reload VS Code - Do not start `web` process with honcho ```shell From be8f0e4fa0777a6b9149944b29b3ec889032fe63 Mon Sep 17 00:00:00 2001 From: chabad360 Date: Fri, 6 Mar 2020 06:12:11 +0000 Subject: [PATCH 29/65] rudimentary docs --- README.md | 57 ++++++++++++ installation/docker-compose-custom.yml | 117 +++++++++++++++++++++++++ 2 files changed, 174 insertions(+) create mode 100644 installation/docker-compose-custom.yml diff --git a/README.md b/README.md index bef76892..bbc93b1c 100644 --- a/README.md +++ b/README.md @@ -161,6 +161,63 @@ docker exec -it \ _erpnext-python_1 docker-entrypoint.sh migrate ``` +### Custom apps + +> For the sake of example, we'll be using a place holder called `[custom]`, and we'll be building off the edge image. + +To add your own apps to the image, we'll need to create a custom image with the help of a special wrapper script + +1. Create two folders called `[custom]-worker` and `[custom]-assets` in the `build` folder. + + ```bash + cd frappe_docker + mkdir ./build/[custom]-worker ./build/[custom]-assets + ``` + +2. Create a `Dockerfile` in `./build/[custom]-worker` with the following content: + + ```Dockerfile + FROM frappe/erpnext-worker:edge + + RUN install_app [custom] https://github.com/[username]/[custom] [branch] + # Only add the branch if you are using a specific tag or branch. + ``` + +3. Create a `Dockerfile` in `./build/[custom]-assets` with the following content: + + ```Dockerfile + FROM bitnami/node:12-prod + + COPY build/[custom]-assets/install_app.sh /install_app + + RUN /install_app [custom] https://github.com/[username]/[custom] + + FROM frappe/erpnext-assets:edge + + COPY --from=0 /home/frappe/frappe-bench/sites/ /var/www/html/ + COPY --from=0 /rsync /rsync + RUN echo -n "\nerpnext" >> /var/www/html/apps.txt + + VOLUME [ "/assets" ] + + ENTRYPOINT ["/docker-entrypoint.sh"] + CMD ["nginx", "-g", "daemon off;"] + ``` + +4. Copy over the `install_app.sh` file from `./build/erpnext-assets` + + ```bash + cp ./build/erpnext-assets/install.sh ./build/[custom]-assets + ``` + +5. Open up `./installation/docker-compose-custom.yml` and replace all instances of `[app]` with the name of your app. + + ```bash + sed -i "s#\[app\]#[custom]#" ./installation/docker-compose-custom.yml + ``` + +6. Install like usuall, except that when you set the `INSTALL_APPS` variable set it to `erpnext,[custom]`. + ### Troubleshoot 1. Remove containers and volumes, and clear redis cache: diff --git a/installation/docker-compose-custom.yml b/installation/docker-compose-custom.yml new file mode 100644 index 00000000..5a7c3696 --- /dev/null +++ b/installation/docker-compose-custom.yml @@ -0,0 +1,117 @@ +version: '3' + +services: + [app]-assets: + image: [app]-assets + build: + context: . + dockerfile: ./build/[app]-assets/Dockerfile + restart: on-failure + environment: + - FRAPPE_PY=erpnext-python + - FRAPPE_PY_PORT=8000 + - FRAPPE_SOCKETIO=frappe-socketio + - SOCKETIO_PORT=9000 + - LETSENCRYPT_HOST=${SITES} + - VIRTUAL_HOST=${SITES} + - LETSENCRYPT_EMAIL=${LETSENCRYPT_EMAIL} + depends_on: + - [app]-python + - frappe-socketio + - frappe-worker-default + - frappe-worker-long + - frappe-worker-short + links: + - [app]-python + - frappe-socketio + - frappe-worker-default + - frappe-worker-long + - frappe-worker-short + volumes: + - ./sites:/var/www/html/sites:rw + - assets-vol:/assets:rw + + [app]-python: + image: [app]-worker + build: + context: . + dockerfile: ./build/[app]-worker/Dockerfile + restart: on-failure + environment: + - MARIADB_HOST=${MARIADB_HOST} + - REDIS_CACHE=redis-cache:6379 + - REDIS_QUEUE=redis-queue:6379 + - REDIS_SOCKETIO=redis-socketio:6379 + - SOCKETIO_PORT=9000 + volumes: + - ./sites:/home/frappe/frappe-bench/sites:rw + - assets-vol:/home/frappe/frappe-bench/sites/assets:rw + + frappe-socketio: + image: frappe/frappe-socketio:${VERSION} + restart: on-failure + depends_on: + - redis-socketio + links: + - redis-socketio + volumes: + - ./sites:/home/frappe/frappe-bench/sites:rw + + frappe-worker-default: + image: [app]-worker + restart: on-failure + command: worker + depends_on: + - redis-queue + - redis-cache + links: + - redis-queue + - redis-cache + volumes: + - ./sites:/home/frappe/frappe-bench/sites:rw + + frappe-worker-short: + image: [app]-worker + restart: on-failure + command: worker + environment: + - WORKER_TYPE=short + depends_on: + - redis-queue + - redis-cache + links: + - redis-queue + - redis-cache + volumes: + - ./sites:/home/frappe/frappe-bench/sites:rw + + frappe-worker-long: + image: [app]-worker + restart: on-failure + command: worker + environment: + - WORKER_TYPE=long + depends_on: + - redis-queue + - redis-cache + links: + - redis-queue + - redis-cache + volumes: + - ./sites:/home/frappe/frappe-bench/sites:rw + + frappe-schedule: + image: [app]-worker + restart: on-failure + command: schedule + depends_on: + - redis-queue + - redis-cache + links: + - redis-queue + - redis-cache + volumes: + - ./sites:/home/frappe/frappe-bench/sites:rw + +volumes: + assets-vol: From 7bdd32979381a77ae82f71616a448c9f32c6178c Mon Sep 17 00:00:00 2001 From: chabad360 Date: Fri, 6 Mar 2020 06:23:53 +0000 Subject: [PATCH 30/65] some small changes --- README.md | 60 +++++++++++++++++----------------- build/erpnext-nginx/Dockerfile | 2 +- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index 7f7c5bcb..3bd34b90 100644 --- a/README.md +++ b/README.md @@ -258,54 +258,54 @@ docker exec -it \ To add your own apps to the image, we'll need to create a custom image with the help of a special wrapper script -1. Create two folders called `[custom]-worker` and `[custom]-assets` in the `build` folder. +1. Create two folders called `[custom]-worker` and `[custom]-nginx` in the `build` folder. - ```bash - cd frappe_docker - mkdir ./build/[custom]-worker ./build/[custom]-assets - ``` + ```bash + cd frappe_docker + mkdir ./build/[custom]-worker ./build/[custom]-nginx + ``` 2. Create a `Dockerfile` in `./build/[custom]-worker` with the following content: - ```Dockerfile - FROM frappe/erpnext-worker:edge + ```Dockerfile + FROM frappe/erpnext-worker:edge - RUN install_app [custom] https://github.com/[username]/[custom] [branch] - # Only add the branch if you are using a specific tag or branch. - ``` + RUN install_app [custom] https://github.com/[username]/[custom] [branch] + # Only add the branch if you are using a specific tag or branch. + ``` -3. Create a `Dockerfile` in `./build/[custom]-assets` with the following content: +3. Create a `Dockerfile` in `./build/[custom]-nginx` with the following content: - ```Dockerfile - FROM bitnami/node:12-prod + ```Dockerfile + FROM bitnami/node:12-prod - COPY build/[custom]-assets/install_app.sh /install_app + COPY build/[custom]-nginx/install_app.sh /install_app - RUN /install_app [custom] https://github.com/[username]/[custom] + RUN /install_app [custom] https://github.com/[username]/[custom] - FROM frappe/erpnext-assets:edge + FROM frappe/erpnext-nginx:edge - COPY --from=0 /home/frappe/frappe-bench/sites/ /var/www/html/ - COPY --from=0 /rsync /rsync - RUN echo -n "\nerpnext" >> /var/www/html/apps.txt + COPY --from=0 /home/frappe/frappe-bench/sites/ /var/www/html/ + COPY --from=0 /rsync /rsync + RUN echo -n "\n[custom]" >> /var/www/html/apps.txt - VOLUME [ "/assets" ] + VOLUME [ "/assets" ] - ENTRYPOINT ["/docker-entrypoint.sh"] - CMD ["nginx", "-g", "daemon off;"] - ``` + ENTRYPOINT ["/docker-entrypoint.sh"] + CMD ["nginx", "-g", "daemon off;"] + ``` -4. Copy over the `install_app.sh` file from `./build/erpnext-assets` +4. Copy over the `install_app.sh` file from `./build/erpnext-nginx` - ```bash - cp ./build/erpnext-assets/install.sh ./build/[custom]-assets - ``` + ```bash + cp ./build/erpnext-nginx/install.sh ./build/[custom]-nginx + ``` 5. Open up `./installation/docker-compose-custom.yml` and replace all instances of `[app]` with the name of your app. - ```bash - sed -i "s#\[app\]#[custom]#" ./installation/docker-compose-custom.yml - ``` + ```bash + sed -i "s#\[app\]#[custom]#" ./installation/docker-compose-custom.yml + ``` 6. Install like usuall, except that when you set the `INSTALL_APPS` variable set it to `erpnext,[custom]`. diff --git a/build/erpnext-nginx/Dockerfile b/build/erpnext-nginx/Dockerfile index 70c9f47d..0bbd2dc6 100644 --- a/build/erpnext-nginx/Dockerfile +++ b/build/erpnext-nginx/Dockerfile @@ -4,7 +4,7 @@ COPY build/erpnext-nginx/install_app.sh /install_app RUN /install_app erpnext https://github.com/frappe/erpnext -FROM frappe/frappe-assets:develop +FROM frappe/frappe-nginx:develop COPY --from=0 /home/frappe/frappe-bench/sites/ /var/www/html/ COPY --from=0 /rsync /rsync From b6eb3ccde263b1fe264bcefc1ef48c55f391367e Mon Sep 17 00:00:00 2001 From: chabad360 Date: Fri, 6 Mar 2020 06:29:12 +0000 Subject: [PATCH 31/65] bug fix in install_apps.sh --- build/common/worker/install_app.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/common/worker/install_app.sh b/build/common/worker/install_app.sh index e3b9b629..ac71cc6a 100755 --- a/build/common/worker/install_app.sh +++ b/build/common/worker/install_app.sh @@ -8,10 +8,10 @@ cd /home/frappe/frappe-bench/ . env/bin/activate -cd apps +cd ./apps [ "${APP_BRANCH}" ] && \ BRANCH="-b ${APP_BRANCH}" git clone --depth 1 -o upstream ${APP_REPO} ${BRANCH} -pip3 install --no-cache-dir -e /home/frappe/frappe-bench/apps/APP_NAME \ No newline at end of file +pip3 install --no-cache-dir -e /home/frappe/frappe-bench/apps/${APP_NAME} \ No newline at end of file From 4b87e507790ffdb95dbfb37673e504adc214390a Mon Sep 17 00:00:00 2001 From: chabad360 Date: Fri, 6 Mar 2020 06:43:28 +0000 Subject: [PATCH 32/65] ambiguous stage names for faster builds --- .travis.yml | 78 ++++++++++++++++++++++++++--------------------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/.travis.yml b/.travis.yml index a36d334e..8410199c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,93 +20,93 @@ after_success: jobs: include: - - name: "Build Frappe bench development environment (latest)" + - stage: "Build Frappe bench development environment (latest)" if: branch = develop AND type != pull_request script: - docker build -t frappe/bench:latest -f build/bench/Dockerfile . - docker push frappe/bench:latest - - name: "Build Frappe python environment (edge)" + - stage: "Frappe (edge)" if: branch = develop AND type != pull_request script: - ./travis.py frappe --nginx --tag edge - ./travis.py frappe --nginx --tag develop--tag-only - - name: "Build Frappe nginx + static assets (edge)" + - stage: "Frappe (edge)" if: branch = develop AND type != pull_request script: - ./travis.py frappe --nginx --tag edge - ./travis.py frappe --nginx --tag develop--tag-only - - stage: "Build ERPNext python environment (edge)" - if: branch = develop AND type != pull_request - script: - - ./travis.py erpnext --worker --tag edge - - ./travis.py erpnext --worker --tag develop --tag-only - - stage: "Build ERPNext nginx + static assets (edge)" - if: branch = develop AND type != pull_request - script: - - ./travis.py erpnext --nginx --tag edge - - ./travis.py erpnext --nginx --tag develop --tag-only - - stage: "Build Frappe socketio service (edge)" + - stage: "Frappe (edge)" if: branch = develop AND type != pull_request script: - ./travis.py frappe --socketio --tag edge - ./travis.py frappe --socketio --tag develop --tag-only - - stage: "Build Frappe python environment (v12)" + - stage: "ERPNext (edge)" + if: branch = develop AND type != pull_request + script: + - ./travis.py erpnext --worker --tag edge + - ./travis.py erpnext --worker --tag develop --tag-only + - stage: "ERPNext (edge)" + if: branch = develop AND type != pull_request + script: + - ./travis.py erpnext --nginx --tag edge + - ./travis.py erpnext --nginx --tag develop --tag-only + - stage: "Frappe (v12)" if: branch = master AND type != pull_request script: - ./travis.py frappe --worker --git-branch 12 - ./travis.py frappe --worker --tag v12 --tag-only - ./travis.py frappe --worker --tag version-12 --tag-only - - stage: "Build Frappe nginx + static assets (v12)" + - stage: "Frappe (v12)" if: branch = master AND type != pull_request script: - ./travis.py frappe --nginx --git-branch 12 - ./travis.py frappe --nginx --tag v12 --tag-only - ./travis.py frappe --nginx --tag version-12 --tag-only - - stage: "Build ERPNext python environment (v12)" + - stage: "Frappe (v12)" + if: branch = master AND type != pull_request + script: + - ./travis.py frappe --socketio --git-branch 12 + - ./travis.py frappe --socketio --tag v12 --tag-only + - ./travis.py frappe --socketio --tag version-12 --tag-only + - stage: "ERPNext (v12)" if: branch = master AND type != pull_request script: - ./travis.py erpnext --worker --git-branch 12 - ./travis.py erpnext --worker --tag v12 --tag-only - ./travis.py erpnext --worker --tag version-12 --tag-only - - stage: "Build ERPNext nginx + static assets (v12)" + - stage: "ERPNext (v12)" if: branch = master AND type != pull_request script: - ./travis.py erpnext --nginx --git-branch 12 - ./travis.py erpnext --nginx --tag v12 --tag-only - ./travis.py erpnext --nginx --tag version-12 --tag-only - - stage: "Build Frappe socketio service (v11)" - if: branch = master AND type != pull_request - script: - - ./travis.py frappe --socketio --git-branch 11 - - ./travis.py frappe --socketio --tag v11 --tag-only - - ./travis.py frappe --socketio --tag version-11 --tag-only - - stage: "Build Frappe python environment (v11)" + - stage: "Frappe (v11)" if: branch = master AND type != pull_request script: - ./travis.py frappe --worker --git-branch 11 - ./travis.py frappe --worker --tag v11 --tag-only - ./travis.py frappe --worker --tag version-11 --tag-only - - stage: "Build Frappe nginx + static assets (v11)" + - stage: "Frappe (v11)" if: branch = master AND type != pull_request script: - ./travis.py erpnext frappe --nginx --git-branch 11 - ./travis.py erpnext frappe --nginx --tag v11 --tag-only - ./travis.py erpnext frappe --nginx --tag version-11 --tag-only - - stage: "Build ERPNext python environment (v11)" - if: branch = master AND type != pull_request - script: - - ./travis.py erpnext --worker --git-branch 11 - - ./travis.py erpnext --worker --tag v11 --tag-only - - ./travis.py erpnext --worker --tag version-11 --tag-only - - stage: "Build ERPNext nginx + static assets (v11)" - if: branch = master AND type != pull_request - script: - - ./travis.py erpnext --nginx --git-branch 11 - - ./travis.py erpnext --nginx --tag v11 --tag-only - - ./travis.py erpnext --nginx --tag version-11 --tag-only - - stage: "Build Frappe socketio service (v11)" + - stage: "Frappe (v11)" if: branch = master AND type != pull_request script: - ./travis.py frappe --socketio --git-branch 11 - ./travis.py frappe --socketio --tag v11 --tag-only - ./travis.py frappe --socketio --tag version-11 --tag-only + - stage: "ERPNext (v11)" + if: branch = master AND type != pull_request + script: + - ./travis.py erpnext --worker --git-branch 11 + - ./travis.py erpnext --worker --tag v11 --tag-only + - ./travis.py erpnext --worker --tag version-11 --tag-only + - stage: "ERPNext (v11)" + if: branch = master AND type != pull_request + script: + - ./travis.py erpnext --nginx --git-branch 11 + - ./travis.py erpnext --nginx --tag v11 --tag-only + - ./travis.py erpnext --nginx --tag version-11 --tag-only \ No newline at end of file From d00770e42f347279fe4fb10e9e995cc6ffceaaeb Mon Sep 17 00:00:00 2001 From: Revant Nandgaonkar Date: Sat, 7 Mar 2020 05:33:32 +0530 Subject: [PATCH 33/65] fix: install_app set branch --- build/common/worker/install_app.sh | 3 +-- build/erpnext-nginx/install_app.sh | 5 ++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/build/common/worker/install_app.sh b/build/common/worker/install_app.sh index ac71cc6a..c378be17 100755 --- a/build/common/worker/install_app.sh +++ b/build/common/worker/install_app.sh @@ -10,8 +10,7 @@ cd /home/frappe/frappe-bench/ cd ./apps -[ "${APP_BRANCH}" ] && \ - BRANCH="-b ${APP_BRANCH}" +[ "${APP_BRANCH}" ] && BRANCH="-b ${APP_BRANCH}" git clone --depth 1 -o upstream ${APP_REPO} ${BRANCH} pip3 install --no-cache-dir -e /home/frappe/frappe-bench/apps/${APP_NAME} \ No newline at end of file diff --git a/build/erpnext-nginx/install_app.sh b/build/erpnext-nginx/install_app.sh index aa3cd98c..a01e957b 100644 --- a/build/erpnext-nginx/install_app.sh +++ b/build/erpnext-nginx/install_app.sh @@ -4,8 +4,7 @@ APP_NAME=${1} APP_REPO=${2} APP_BRANCH=${3} -[ "${APP_BRANCH}" ] && \ - BRANCH="-b ${APP_BRANCH}" +[ "${APP_BRANCH}" ] && BRANCH="-b ${APP_BRANCH}" cd /home/frappe/frappe-bench mkdir -p /home/frappe/frappe-bench/sites @@ -13,7 +12,7 @@ echo "frappe\n${APP_NAME}" > /home/frappe/frappe-bench/sites/apps.txt install_packages git python2 -mkdir -p apps sites/assets +mkdir -p apps sites/assets cd apps git clone --depth 1 https://github.com/frappe/frappe ${BRANCH} git clone --depth 1 ${APP_REPO} ${BRANCH} From 845f8546ff5aaecc19891e57aabfbdce611cfe09 Mon Sep 17 00:00:00 2001 From: Revant Nandgaonkar Date: Sat, 7 Mar 2020 05:34:06 +0530 Subject: [PATCH 34/65] fix: travis duplicate stages --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8410199c..9d232816 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,8 +28,8 @@ jobs: - stage: "Frappe (edge)" if: branch = develop AND type != pull_request script: - - ./travis.py frappe --nginx --tag edge - - ./travis.py frappe --nginx --tag develop--tag-only + - ./travis.py frappe --worker --tag edge + - ./travis.py frappe --worker --tag develop--tag-only - stage: "Frappe (edge)" if: branch = develop AND type != pull_request script: From 843d09fb6d3e7b3c4eb2b77c2530dc7d2e57eb59 Mon Sep 17 00:00:00 2001 From: Revant Nandgaonkar Date: Sat, 7 Mar 2020 05:55:11 +0530 Subject: [PATCH 35/65] fix: development README for MariaDB setup --- development/README.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/development/README.md b/development/README.md index c7d78071..8f69c03c 100644 --- a/development/README.md +++ b/development/README.md @@ -98,10 +98,9 @@ mysql -uroot -p123 -hmariadb Execute following queries ```sql -UPDATE mysql.user SET Host = '%' where User = 'db_name'; -SET PASSWORD FOR 'db_name'@'%' = PASSWORD('db_password'); -GRANT ALL PRIVILEGES ON `db_name`.* TO 'db_name'@'%'; -FLUSH PRIVILEGES; +UPDATE mysql.user SET Host = '%' where User = 'db_name'; FLUSH PRIVILEGES; +SET PASSWORD FOR 'db_name'@'%' = PASSWORD('db_password'); FLUSH PRIVILEGES; +GRANT ALL PRIVILEGES ON `db_name`.* TO 'db_name'@'%'; FLUSH PRIVILEGES; ``` ### Visual Studio Code Python Debugging From 94e62d026865bb4db5c3af656c1c3cf23e7fb1df Mon Sep 17 00:00:00 2001 From: Davide Bortolami Date: Sat, 7 Mar 2020 00:38:10 +0000 Subject: [PATCH 36/65] fix #119 --- build/bench/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/bench/Dockerfile b/build/bench/Dockerfile index a0f599ee..9a9ca286 100644 --- a/build/bench/Dockerfile +++ b/build/bench/Dockerfile @@ -18,7 +18,7 @@ ENV LC_ALL=en_US.UTF-8 RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-suggests --no-install-recommends \ build-essential cron curl git libffi-dev liblcms2-dev libldap2-dev libmariadbclient-dev libsasl2-dev libssl1.0-dev libtiff5-dev \ libwebp-dev mariadb-client iputils-ping python3-dev python3-pip python3-setuptools python3-tk redis-tools rlwrap \ - software-properties-common sudo tk8.6-dev vim xfonts-75dpi xfonts-base wget wkhtmltopdf fonts-cantarell \ + software-properties-common sudo tk8.6-dev vim xfonts-75dpi xfonts-base wget wkhtmltopdf fonts-cantarell net-tools \ && apt-get clean && rm -rf /var/lib/apt/lists/* # Add frappe user and setup sudo From e53ac6b8b88d9323edcf13bf9e4c64aeaed6121b Mon Sep 17 00:00:00 2001 From: Revant Nandgaonkar Date: Sat, 7 Mar 2020 13:27:19 +0530 Subject: [PATCH 37/65] fix: erpnext image build --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9d232816..c2946355 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,12 +29,12 @@ jobs: if: branch = develop AND type != pull_request script: - ./travis.py frappe --worker --tag edge - - ./travis.py frappe --worker --tag develop--tag-only + - ./travis.py frappe --worker --tag develop --tag-only - stage: "Frappe (edge)" if: branch = develop AND type != pull_request script: - ./travis.py frappe --nginx --tag edge - - ./travis.py frappe --nginx --tag develop--tag-only + - ./travis.py frappe --nginx --tag develop --tag-only - stage: "Frappe (edge)" if: branch = develop AND type != pull_request script: From e5a5a05dfbd83cd63e168da47237702080089e52 Mon Sep 17 00:00:00 2001 From: Revant Nandgaonkar Date: Sat, 7 Mar 2020 15:47:50 +0530 Subject: [PATCH 38/65] fix: erpnext nginx image build --- build/erpnext-nginx/install_app.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) mode change 100644 => 100755 build/erpnext-nginx/install_app.sh diff --git a/build/erpnext-nginx/install_app.sh b/build/erpnext-nginx/install_app.sh old mode 100644 new mode 100755 index a01e957b..54e7e176 --- a/build/erpnext-nginx/install_app.sh +++ b/build/erpnext-nginx/install_app.sh @@ -6,13 +6,13 @@ APP_BRANCH=${3} [ "${APP_BRANCH}" ] && BRANCH="-b ${APP_BRANCH}" +mkdir -p /home/frappe/frappe-bench/sites/assets cd /home/frappe/frappe-bench -mkdir -p /home/frappe/frappe-bench/sites echo "frappe\n${APP_NAME}" > /home/frappe/frappe-bench/sites/apps.txt install_packages git python2 -mkdir -p apps sites/assets +mkdir -p apps cd apps git clone --depth 1 https://github.com/frappe/frappe ${BRANCH} git clone --depth 1 ${APP_REPO} ${BRANCH} From 0f03713e5c8e6bdd76066f5900e91375874b02d6 Mon Sep 17 00:00:00 2001 From: Revant Nandgaonkar Date: Sat, 7 Mar 2020 16:45:53 +0530 Subject: [PATCH 39/65] fix: erpnext nginx image install_app script --- build/erpnext-nginx/install_app.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/erpnext-nginx/install_app.sh b/build/erpnext-nginx/install_app.sh index 54e7e176..65a1af6f 100755 --- a/build/erpnext-nginx/install_app.sh +++ b/build/erpnext-nginx/install_app.sh @@ -8,7 +8,7 @@ APP_BRANCH=${3} mkdir -p /home/frappe/frappe-bench/sites/assets cd /home/frappe/frappe-bench -echo "frappe\n${APP_NAME}" > /home/frappe/frappe-bench/sites/apps.txt +echo -e "frappe\n${APP_NAME}" > /home/frappe/frappe-bench/sites/apps.txt install_packages git python2 @@ -19,7 +19,7 @@ git clone --depth 1 ${APP_REPO} ${BRANCH} cd /home/frappe/frappe-bench/apps/frappe yarn -yarn production +yarn production rm -fr node_modules yarn install --production=true From 07806f10866dbefb7e435cd69c269c7d31d87a68 Mon Sep 17 00:00:00 2001 From: Revant Nandgaonkar Date: Sat, 7 Mar 2020 19:39:59 +0530 Subject: [PATCH 40/65] fix: worker new-site command fixes #128 --- build/common/commands/new.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build/common/commands/new.py b/build/common/commands/new.py index 80332a1e..c951e63e 100644 --- a/build/common/commands/new.py +++ b/build/common/commands/new.py @@ -6,7 +6,8 @@ site_name = os.environ.get("SITE_NAME", 'site1.localhost') mariadb_root_username = os.environ.get("DB_ROOT_USER", 'root') mariadb_root_password = os.environ.get("MYSQL_ROOT_PASSWORD", 'admin') force = True if os.environ.get("FORCE", None) else False -install_apps = if os.environ.get("INSTALL_APPS").split(",") else [] +install_apps = os.environ.get("INSTALL_APPS", None) +install_apps = install_apps.split(',') if install_apps else [] frappe.init(site_name, new_site=True) _new_site( From b437dcd2847d034510173c6fd2bc13fbffe2ba96 Mon Sep 17 00:00:00 2001 From: Davide Bortolami Date: Sat, 7 Mar 2020 18:24:54 +0000 Subject: [PATCH 41/65] Update development Dockerfile to better resemble production dockerfiles. Still untested. --- build/bench/Dockerfile | 104 +++++++++++++++++++++++++---------------- 1 file changed, 65 insertions(+), 39 deletions(-) diff --git a/build/bench/Dockerfile b/build/bench/Dockerfile index 9a9ca286..840d28ca 100644 --- a/build/bench/Dockerfile +++ b/build/bench/Dockerfile @@ -1,52 +1,78 @@ # Frappe Bench Dockerfile - -FROM debian:9.6-slim +FROM bitnami/minideb:latest LABEL author=frappé -RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends locales \ - && sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen \ - && dpkg-reconfigure --frontend=noninteractive locales \ - && apt-get clean && rm -rf /var/lib/apt/lists/* -# Set locale en_us.UTF-8 for mariadb and general locale data -ENV PYTHONIOENCODING=utf-8 -ENV LANGUAGE=en_US.UTF-8 -ENV LANG=en_US.UTF-8 -ENV LC_ALL=en_US.UTF-8 +WORKDIR /home/frappe/frappe-bench +RUN install_packages \ + git \ + wkhtmltopdf \ + mariadb-client \ + gettext-base \ + wget \ + # for PDF + libssl-dev \ + fonts-cantarell \ + xfonts-75dpi \ + xfonts-base \ + # to work inside the container + locales \ + build-essential \ + cron \ + curl \ + vim \ + sudo \ + iputils-ping \ + software-properties-common \ + # For psycopg2 + libpq-dev \ + build-essential \ + # Other + libffi-dev \ + liblcms2-dev \ + libldap2-dev \ + libmariadbclient-dev \ + libsasl2-dev \ + libtiff5-dev \ + libwebp-dev \ + redis-tools \ + rlwrap \ + tk8.6-dev \ + fonts-cantarell \ + # VSCode container requirements + net-tools \ +# PYTHON + python3-dev \ + python3-pip \ + python3-setuptools \ + python3-tk -# Install all neccesary packages -RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-suggests --no-install-recommends \ - build-essential cron curl git libffi-dev liblcms2-dev libldap2-dev libmariadbclient-dev libsasl2-dev libssl1.0-dev libtiff5-dev \ - libwebp-dev mariadb-client iputils-ping python3-dev python3-pip python3-setuptools python3-tk redis-tools rlwrap \ - software-properties-common sudo tk8.6-dev vim xfonts-75dpi xfonts-base wget wkhtmltopdf fonts-cantarell net-tools \ - && apt-get clean && rm -rf /var/lib/apt/lists/* - -# Add frappe user and setup sudo -RUN groupadd -g 1000 frappe \ - && useradd -ms /bin/bash -u 1000 -g 1000 -G sudo frappe \ - && chown -R 1000:1000 /home/frappe \ - && echo '. "$NVM_DIR/nvm.sh"' >> /home/frappe/.bashrc - -# Install nvm with node -ENV NVM_DIR /home/frappe/.nvm -ENV NODE_VERSION 12.16.1 -RUN mkdir /home/frappe/.nvm \ - && wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.35.2/install.sh | bash \ - && . $NVM_DIR/nvm.sh \ - && nvm install $NODE_VERSION \ - && nvm install 10.19.0 \ - && npm install yarn -g \ - && nvm alias default $NODE_VERSION \ - && nvm use default \ - && npm install yarn -g \ - && chown -R frappe:frappe /home/frappe -ENV NODE_PATH $NVM_DIR/v$NODE_VERSION/lib/node_modules -ENV PATH $NVM_DIR/v$NODE_VERSION/bin:$PATH # Install wkhtmltox correctly RUN wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.stretch_amd64.deb RUN dpkg -i wkhtmltox_0.12.5-1.stretch_amd64.deb && rm wkhtmltox_0.12.5-1.stretch_amd64.deb + + +# Add frappe user and setup sudo +RUN groupadd -g 1000 frappe \ + && useradd -ms /bin/bash -u 1000 -g 1000 -G sudo frappe \ + && chown -R 1000:1000 /home/frappe + +# Install nvm with node +ENV NODE_VERSION=13.10.1 +RUN curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash +ENV NVM_DIR=/root/.nvm +RUN . "$NVM_DIR/nvm.sh" && nvm install ${NODE_VERSION} +RUN . "$NVM_DIR/nvm.sh" && nvm use v${NODE_VERSION} +RUN . "$NVM_DIR/nvm.sh" && nvm alias default v${NODE_VERSION} +ENV PATH="/root/.nvm/versions/node/v${NODE_VERSION}/bin/:${PATH}" +RUN node --version +RUN npm --version +RUN npm install -g yarn +RUN yarn --version +RUN echo '. "$NVM_DIR/nvm.sh"' >> /home/frappe/.bashrc + # Install bench RUN pip3 install -e git+https://github.com/frappe/bench.git#egg=bench --no-cache From 333786d01370fbc8ed1fcf9a6371b5d57d71936d Mon Sep 17 00:00:00 2001 From: Davide Bortolami Date: Sat, 7 Mar 2020 18:43:58 +0000 Subject: [PATCH 42/65] small cleanup --- build/bench/Dockerfile | 2 -- 1 file changed, 2 deletions(-) diff --git a/build/bench/Dockerfile b/build/bench/Dockerfile index 840d28ca..b89141a0 100644 --- a/build/bench/Dockerfile +++ b/build/bench/Dockerfile @@ -77,9 +77,7 @@ RUN echo '. "$NVM_DIR/nvm.sh"' >> /home/frappe/.bashrc RUN pip3 install -e git+https://github.com/frappe/bench.git#egg=bench --no-cache USER frappe - WORKDIR /home/frappe/frappe-bench - EXPOSE 8000 9000 6787 VOLUME [ "/home/frappe/frappe-bench" ] From d46c97f64a5d6f609f416f313fe3e11f04d87505 Mon Sep 17 00:00:00 2001 From: Davide Bortolami Date: Sun, 8 Mar 2020 16:24:07 +0000 Subject: [PATCH 43/65] Enumerate node packages --- build/frappe-nginx/Dockerfile | 4 ++++ build/frappe-nginx/v11.Dockerfile | 4 ++++ build/frappe-nginx/v12.Dockerfile | 4 ++++ build/frappe-socketio/Dockerfile | 3 +++ build/frappe-socketio/v11.Dockerfile | 3 +++ build/frappe-socketio/v12.Dockerfile | 3 +++ 6 files changed, 21 insertions(+) diff --git a/build/frappe-nginx/Dockerfile b/build/frappe-nginx/Dockerfile index 03b40883..425b3fe0 100644 --- a/build/frappe-nginx/Dockerfile +++ b/build/frappe-nginx/Dockerfile @@ -31,6 +31,10 @@ COPY build/frappe-nginx/docker-entrypoint.sh / RUN apt-get update && apt-get install -y rsync && apt-get clean +RUN node --version +RUN npm --version +RUN yarn --version + VOLUME [ "/assets" ] ENTRYPOINT ["/docker-entrypoint.sh"] diff --git a/build/frappe-nginx/v11.Dockerfile b/build/frappe-nginx/v11.Dockerfile index cfeb2c3d..f6590101 100644 --- a/build/frappe-nginx/v11.Dockerfile +++ b/build/frappe-nginx/v11.Dockerfile @@ -31,6 +31,10 @@ COPY build/frappe-nginx/docker-entrypoint.sh / RUN apt-get update && apt-get install -y rsync && apt-get clean +RUN node --version +RUN npm --version +RUN yarn --version + VOLUME [ "/assets" ] ENTRYPOINT ["/docker-entrypoint.sh"] diff --git a/build/frappe-nginx/v12.Dockerfile b/build/frappe-nginx/v12.Dockerfile index 4994ad28..bb9b0e49 100644 --- a/build/frappe-nginx/v12.Dockerfile +++ b/build/frappe-nginx/v12.Dockerfile @@ -31,6 +31,10 @@ COPY build/frappe-nginx/docker-entrypoint.sh / RUN apt-get update && apt-get install -y rsync && apt-get clean +RUN node --version +RUN npm --version +RUN yarn --version + VOLUME [ "/assets" ] ENTRYPOINT ["/docker-entrypoint.sh"] diff --git a/build/frappe-socketio/Dockerfile b/build/frappe-socketio/Dockerfile index a74b0d3e..fcb6c0fb 100644 --- a/build/frappe-socketio/Dockerfile +++ b/build/frappe-socketio/Dockerfile @@ -30,5 +30,8 @@ RUN ln -s /usr/local/bin/docker-entrypoint.sh / # backwards compat WORKDIR /home/frappe/frappe-bench/sites +RUN node --version +RUN npm --version + ENTRYPOINT ["docker-entrypoint.sh"] CMD ["start"] diff --git a/build/frappe-socketio/v11.Dockerfile b/build/frappe-socketio/v11.Dockerfile index fcaac8ac..49732267 100644 --- a/build/frappe-socketio/v11.Dockerfile +++ b/build/frappe-socketio/v11.Dockerfile @@ -30,5 +30,8 @@ RUN ln -s /usr/local/bin/docker-entrypoint.sh / # backwards compat WORKDIR /home/frappe/frappe-bench/sites +RUN node --version +RUN npm --version + ENTRYPOINT ["docker-entrypoint.sh"] CMD ["start"] diff --git a/build/frappe-socketio/v12.Dockerfile b/build/frappe-socketio/v12.Dockerfile index adf536bd..618712e9 100644 --- a/build/frappe-socketio/v12.Dockerfile +++ b/build/frappe-socketio/v12.Dockerfile @@ -30,5 +30,8 @@ RUN ln -s /usr/local/bin/docker-entrypoint.sh / # backwards compat WORKDIR /home/frappe/frappe-bench/sites +RUN node --version +RUN npm --version + ENTRYPOINT ["docker-entrypoint.sh"] CMD ["start"] From ae5979ee8f26c0d665a8009c2817b7a079a42b73 Mon Sep 17 00:00:00 2001 From: Davide Bortolami Date: Sun, 8 Mar 2020 18:37:26 +0000 Subject: [PATCH 44/65] Fixed node and python installation, local user --- build/bench/Dockerfile | 66 ++++++++++++++++++++++++++++++------------ 1 file changed, 47 insertions(+), 19 deletions(-) diff --git a/build/bench/Dockerfile b/build/bench/Dockerfile index b89141a0..77ae4997 100644 --- a/build/bench/Dockerfile +++ b/build/bench/Dockerfile @@ -2,8 +2,6 @@ FROM bitnami/minideb:latest LABEL author=frappé - -WORKDIR /home/frappe/frappe-bench RUN install_packages \ git \ wkhtmltopdf \ @@ -41,43 +39,73 @@ RUN install_packages \ fonts-cantarell \ # VSCode container requirements net-tools \ -# PYTHON + # PYTHON python3-dev \ python3-pip \ python3-setuptools \ - python3-tk - + python3-tk \ + python-virtualenv # Install wkhtmltox correctly RUN wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.stretch_amd64.deb RUN dpkg -i wkhtmltox_0.12.5-1.stretch_amd64.deb && rm wkhtmltox_0.12.5-1.stretch_amd64.deb +# Create new user with directory, add user to sudo group, allow passwordless sudo, switch to that user and change directory to user home directory +RUN useradd --no-log-init -r -m -g sudo frappe +RUN echo "frappe ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers +USER frappe +WORKDIR /home/frappe +# Install bench in the local user home directory +RUN pip3 install --user git+https://github.com/frappe/bench.git#egg=bench --no-cache + +# Export python executables for Dockerfile +ENV PATH=/home/frappe/.local/bin/:$PATH +# Export python executables for interactive shell +RUN echo "export PATH=/home/frappe/.local/bin/:\$PATH" >> /home/frappe/.bashrc + +# Print version and verify bashrc is properly sourced so that everything works in the Dockerfile +RUN bench --version +# Print version and verify bashrc is properly sourced so that everything works in the interactive shell +RUN bash -c "bench --version" -# Add frappe user and setup sudo -RUN groupadd -g 1000 frappe \ - && useradd -ms /bin/bash -u 1000 -g 1000 -G sudo frappe \ - && chown -R 1000:1000 /home/frappe # Install nvm with node -ENV NODE_VERSION=13.10.1 -RUN curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash -ENV NVM_DIR=/root/.nvm +# !!! UPDATE PERIODICALLY WITH LATEST VERSIONS !!! +# https://nodejs.org/en/about/releases/ +# https://nodejs.org/download/release/latest-v10.x/ +# https://nodejs.org/download/release/latest-v12.x/ +# https://nodejs.org/download/release/latest-v13.x/ + +ENV NODE_VERSION=12.16.1 +ENV NODE_VERSION_FRAPPEV11=10.19.0 + +RUN wget https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh +RUN chmod +x install.sh +RUN ./install.sh + +ENV NVM_DIR=/home/frappe/.nvm RUN . "$NVM_DIR/nvm.sh" && nvm install ${NODE_VERSION} +RUN . "$NVM_DIR/nvm.sh" && nvm install ${NODE_VERSION_FRAPPEV11} RUN . "$NVM_DIR/nvm.sh" && nvm use v${NODE_VERSION} RUN . "$NVM_DIR/nvm.sh" && nvm alias default v${NODE_VERSION} -ENV PATH="/root/.nvm/versions/node/v${NODE_VERSION}/bin/:${PATH}" +# Add NVM path for user in Dockerfile, interactive shell is already managed by the NVM install script +ENV PATH="/home/frappe/.nvm/versions/node/v${NODE_VERSION}/bin/:${PATH}" + +# Install yarn +RUN npm install -g yarn + +# Print version and verify bashrc is properly sourced so that everything works in the Dockerfile RUN node --version RUN npm --version -RUN npm install -g yarn RUN yarn --version -RUN echo '. "$NVM_DIR/nvm.sh"' >> /home/frappe/.bashrc +# Print version and verify bashrc is properly sourced so that everything works in the interactive shell +RUN bash -c "node --version" +RUN bash -c "npm --version" +RUN bash -c "yarn --version" -# Install bench -RUN pip3 install -e git+https://github.com/frappe/bench.git#egg=bench --no-cache -USER frappe WORKDIR /home/frappe/frappe-bench EXPOSE 8000 9000 6787 -VOLUME [ "/home/frappe/frappe-bench" ] +VOLUME [ "/root/frappe-bench" ] From 0746693c1f47959cd71a85fce0efdc587ce15204 Mon Sep 17 00:00:00 2001 From: Davide Bortolami Date: Sun, 8 Mar 2020 19:07:03 +0000 Subject: [PATCH 45/65] some other useful software --- build/bench/Dockerfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build/bench/Dockerfile b/build/bench/Dockerfile index 77ae4997..4261adc8 100644 --- a/build/bench/Dockerfile +++ b/build/bench/Dockerfile @@ -21,6 +21,9 @@ RUN install_packages \ vim \ sudo \ iputils-ping \ + watch \ + tree \ + nano \ software-properties-common \ # For psycopg2 libpq-dev \ From f43670c7c507d4d123f82a689507f3d96e7a5a3b Mon Sep 17 00:00:00 2001 From: Davide Bortolami Date: Sun, 8 Mar 2020 20:16:47 +0000 Subject: [PATCH 46/65] Fix .gitiggnore, it was ignoring the README.md under development --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index cb373cae..d93ce912 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ sites development +!development/README.md From 32b4c29df1a0aae7cef3995b20aa1fd68e9cb79a Mon Sep 17 00:00:00 2001 From: Davide Bortolami Date: Sun, 8 Mar 2020 20:17:22 +0000 Subject: [PATCH 47/65] Rewrite Development Readme so it's idiotproof --- development/README.md | 137 ++++++++++++++++++++++++++---------------- 1 file changed, 84 insertions(+), 53 deletions(-) diff --git a/development/README.md b/development/README.md index 8f69c03c..57c1453e 100644 --- a/development/README.md +++ b/development/README.md @@ -6,54 +6,46 @@ - docker-compose - user added to docker group -### Bootstrap Containers for development +## Bootstrap Containers for development -Clone and change to frappe_docker directory +Clone and change directory to frappe_docker directory ```shell git clone https://github.com/frappe/frappe_docker.git cd frappe_docker ``` -#### Manually start containers +## Use VSCode Remote Containers extension -In case VS Code is not used follow these steps. +For most people getting started with Frappe development, the best solution is to use [ VSCode Remote - Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers). -```shell -docker-compose -f .devcontainer/docker-compose.yml up -d -``` - -Enter the bench container at location `/workspace/development` - -```shell -docker exec -e "TERM=xterm-256color" -w /workspace/development -it devcontainer_frappe_1 bash -``` - -#### Use VS Code Remote Containers extension - -Follow these in case VS Code is used. Do not start containers manually. - -- Install Remote Development Pack / Remote Containers extension. -- Install VS Code Python extension. -- Open frappe_docker in VS Code. -- From Command Palette (Ctrl + Shift + P) Execute Remote Containers : Reopen in Container. - -### Setup Docker specific bench environment +- Install Remote - Containers for VSCode + - through command line `code --install-extension ms-vscode-remote.remote-containers` + - clicking on the following link: [install](vscode:extension/ms-vscode-remote.remote-containers) +- Install Python for VSCode + - through command line `code --install-extension ms-python.python` + - clicking on the following link: [install](vscode:extension/ms-python.python) +- Open frappe_docker folder in VS Code. + - `code .` +- From Command Palette (Ctrl + Shift + P) Execute Remote Containers : Reopen in Container. You can also click in the bottom left corner to access the remote container menu. Notes: -- `development` directory is ignored by git. It is mounted and available in container. Create all your benches inside this directory. -- Execute these commands from container. +- The `development` directory is ignored by git. It is mounted and available inside the container. Create all your benches (installations of bench, the tool that manages frappe) inside this directory. - nvm with node v12 and v10 is installed. Check with `nvm ls`. Node v12 is default. -#### Setup first bench +### Setup first bench + +Run the following commands in the terminal inside the container. You might need to create a new terminal in VSCode. ```shell bench init --skip-redis-config-generation --frappe-branch version-12 frappe-bench cd frappe-bench ``` -#### Set hosts +### Setup hosts + +We need to tell bench to use the right containers instead of localhosts. Run the following commands inside the container: ```shell bench set-mariadb-host mariadb @@ -62,52 +54,91 @@ bench set-redis-queue-host redis-queue:6379 bench set-redis-socketio-host redis-socketio:6379 ``` -#### Changes related to bench start / honcho / Procfile +### Edit Honcho's Procfile -- honcho/Procfile starts processes required for development. -- By default Procfile has 3 redis processes that it starts. Comment (`#`) or remove these lines and then run `bench start`. -- Another option is to run following command : +Honcho is the tool used by Bench to manage all the processes Frappe requires. Usually, these all run in localhost, but in this case we have external containers for Redis. For this reason, we have to stop Honcho from trying to start Redis processes. + +Open the Procfile file and remove the three lines containing the configuration from Redis, either by editing manually the file ```shell -honcho start \ - web \ - socketio \ - watch \ - schedule \ - worker_short \ - worker_long \ - worker_default +code Procfile ``` -#### Changes related to MariaDB +or running the following command: +```shell +sed -i '/redis/d' ./Procfile +``` -Notes: +### Create a new site with bench -- `bench new-site` command creates a user in mariadb with container IP as host -- After rebuilding container there is a chance that new bench container will not be able to access mariadb -- `'db_name'@'%'` needs to be set in mariadb and permission to the site database be given to the user -- Replace `db_name` and `db_password` from site's `site_config.json` -- MariaDB root password is 123 +You can create a new site with the following command -Enter mariadb shell +```shell +bench new-site sitename +``` + +for example: + +```shell +bench new-site localhost +``` + +The command will ask the MariaDB root password. The default root password is `123` +Your website will now be accessible on [localhost on port 8000](http://locahost:8000) + +### Fixing MariaDB issues after rebuilding the container + +The `bench new-site` command creates a user in MariaDB with container IP as host, for this reason after rebuilding the container there is a chance that you will not be able to access MariaDB correctly with the previous configuration +The parameter `'db_name'@'%'` needs to be set in MariaDB and permission to the site database properly assigned to the user. + +Open sites/common_site_config.json: + + +```shell +code sites/common_site_config.json +``` + +and take note of the parameters `db_name` and `db_password`. + +Enter MariaDB Interactive shell: ```shell mysql -uroot -p123 -hmariadb ``` -Execute following queries +Execute following queries replacing db_name` and `db_password` with the values found in common_site_config.json. ```sql UPDATE mysql.user SET Host = '%' where User = 'db_name'; FLUSH PRIVILEGES; SET PASSWORD FOR 'db_name'@'%' = PASSWORD('db_password'); FLUSH PRIVILEGES; GRANT ALL PRIVILEGES ON `db_name`.* TO 'db_name'@'%'; FLUSH PRIVILEGES; +EXIT; +``` + +## Manually start containers + +In case you don't use VSCode, you may start the containers manually with the following command: + +```shell +docker-compose -f .devcontainer/docker-compose.yml up -d +``` + +And enter the interactive shell for the development container with the following command: + +```shell +docker exec -e "TERM=xterm-256color" -w /workspace/development -it devcontainer_frappe_1 bash ``` ### Visual Studio Code Python Debugging -- Install VS Code Python Extension once in remote container -- Reload VS Code -- Do not start `web` process with honcho +To enable Python debugging inside Visual Studio Code, you must first install the `ms-python.python` extension inside the container. + +- Click on the extensions icon of VSCode +- Search `ms-python.python` +- Click on `Install on Dev Container: Frappe Bench` +- Click on 'Reload' + +We need to start bench separately through the VSCode debugger. For this reason, **instead** of running `bench start` you should run the following command inside the frappe-bench directory: ```shell honcho start \ @@ -119,4 +150,4 @@ honcho start \ worker_default ``` -- On debugger tab, Connect debugger. This will start the web process with debugger connected +This command starts all processes but Redis (which is already running in separate container) and the `web` process, which we can finally start from the debugger tab of VSCode. From 3bf1fdcc759ebc846c849afea3ec496a22e69125 Mon Sep 17 00:00:00 2001 From: Davide Bortolami Date: Sun, 8 Mar 2020 20:17:39 +0000 Subject: [PATCH 48/65] Clean up main README, add development section --- README.md | 114 +++++++++++++++++++++++++++++------------------------- 1 file changed, 62 insertions(+), 52 deletions(-) diff --git a/README.md b/README.md index 3bd34b90..c10bbb28 100644 --- a/README.md +++ b/README.md @@ -55,12 +55,11 @@ To get started, copy the existing `env-example` file to `.env` inside the `insta - Email for LetsEncrypt expiry notification. This is only required if you are setting up LetsEncrypt. -### Local deployment +### Local deployment for testing -For trying out locally or to develop apps using ERPNext ReST API port 80 must be published. -First start the containers and then run an additional command to publish port of *-nginx container. +For trying out locally or to develop apps using ERPNext REST API port 80 must be published. +The first command will start the containers, the second command will publish the port of the *-nginx container. -To start and publish Frappe/ERPNext services as local api, run the following commands: For Erpnext: @@ -98,13 +97,13 @@ docker-compose \ --project-directory installation run --publish 80:80 -d frappe-nginx ``` -Make sure to replace `` with any desired name you wish to set for the project. +Make sure to replace `` with the desired name you wish to set for the project. -Note: - - This command adds an additional container for frappe-nginx with published ports. - - The local deployment is for testing and REST API development purpose only. +Notes: + - The local deployment is for testing and REST API development purpose only +- A more complete development environment is available [here](Development/README.md) - The site names are limited to patterns matching \*.localhost by default - - Additional site name patterns can be added to /etc/hosts of desired container or host + - Additional site name patterns can be added by editing /etc/hosts of your host machine ### Deployment for production @@ -124,8 +123,7 @@ cp .env.sample .env ./start.sh ``` -For more details, see: https://github.com/evertramos/docker-compose-letsencrypt-nginx-proxy-companion -Letsencrypt Nginx Proxy Companion works by automatically proxying to containers with the `VIRTUAL_HOST` environmental variable. +For more details, see the [Letsencrypt Nginx Proxy Companion github repo](https://github.com/evertramos/docker-compose-letsencrypt-nginx-proxy-companion). Letsencrypt Nginx Proxy Companion github repo works by automatically proxying to containers with the `VIRTUAL_HOST` environmental variable. #### Start Frappe/ERPNext Services @@ -254,68 +252,69 @@ docker exec -it \ ### Custom apps -> For the sake of example, we'll be using a place holder called `[custom]`, and we'll be building off the edge image. +To add your own Frappe/ERPNext apps to the image, we'll need to create a custom image with the help of a special wrapper script -To add your own apps to the image, we'll need to create a custom image with the help of a special wrapper script +> For the sake of simplicity, in this example, we'll be using a place holder called `[custom]`, and we'll be building off the edge image. -1. Create two folders called `[custom]-worker` and `[custom]-nginx` in the `build` folder. +Create two directories called `[custom]-worker` and `[custom]-nginx` in the `build` directory. - ```bash - cd frappe_docker - mkdir ./build/[custom]-worker ./build/[custom]-nginx - ``` +```shell +cd frappe_docker +mkdir ./build/[custom]-worker ./build/[custom]-nginx +``` -2. Create a `Dockerfile` in `./build/[custom]-worker` with the following content: +Create a `Dockerfile` in `./build/[custom]-worker` with the following content: - ```Dockerfile - FROM frappe/erpnext-worker:edge +```Dockerfile +FROM frappe/erpnext-worker:edge - RUN install_app [custom] https://github.com/[username]/[custom] [branch] - # Only add the branch if you are using a specific tag or branch. - ``` +RUN install_app [custom] https://github.com/[username]/[custom] [branch] +# Only add the branch if you are using a specific tag or branch. +``` -3. Create a `Dockerfile` in `./build/[custom]-nginx` with the following content: +Create a `Dockerfile` in `./build/[custom]-nginx` with the following content: - ```Dockerfile - FROM bitnami/node:12-prod +```Dockerfile +FROM bitnami/node:12-prod - COPY build/[custom]-nginx/install_app.sh /install_app +COPY build/[custom]-nginx/install_app.sh /install_app - RUN /install_app [custom] https://github.com/[username]/[custom] +RUN /install_app [custom] https://github.com/[username]/[custom] - FROM frappe/erpnext-nginx:edge +FROM frappe/erpnext-nginx:edge - COPY --from=0 /home/frappe/frappe-bench/sites/ /var/www/html/ - COPY --from=0 /rsync /rsync - RUN echo -n "\n[custom]" >> /var/www/html/apps.txt +COPY --from=0 /home/frappe/frappe-bench/sites/ /var/www/html/ +COPY --from=0 /rsync /rsync +RUN echo -n "\n[custom]" >> /var/www/html/apps.txt - VOLUME [ "/assets" ] +VOLUME [ "/assets" ] - ENTRYPOINT ["/docker-entrypoint.sh"] - CMD ["nginx", "-g", "daemon off;"] - ``` +ENTRYPOINT ["/docker-entrypoint.sh"] +CMD ["nginx", "-g", "daemon off;"] +``` -4. Copy over the `install_app.sh` file from `./build/erpnext-nginx` +Copy over the `install_app.sh` file from `./build/erpnext-nginx` - ```bash - cp ./build/erpnext-nginx/install.sh ./build/[custom]-nginx - ``` +```shell +cp ./build/erpnext-nginx/install.sh ./build/[custom]-nginx +``` -5. Open up `./installation/docker-compose-custom.yml` and replace all instances of `[app]` with the name of your app. +Open up `./installation/docker-compose-custom.yml` and replace all instances of `[app]` with the name of your app. - ```bash - sed -i "s#\[app\]#[custom]#" ./installation/docker-compose-custom.yml - ``` +```shell +sed -i "s#\[app\]#[custom]#" ./installation/docker-compose-custom.yml +``` -6. Install like usuall, except that when you set the `INSTALL_APPS` variable set it to `erpnext,[custom]`. +Install like usual, except that when you set the `INSTALL_APPS` variable set it to `erpnext,[custom]`. ## Troubleshoot -1. Remove containers and volumes, and clear redis cache: +### Failed migration after image upgrade -This can be used when existing images are upgraded and migration fails. +Issue: After upgrade of the containers, the automatic migration fails. +Solution: Remove containers and volumes, and clear redis cache: -``` +```shell # change to repo root cd $HOME/frappe_docker @@ -350,9 +349,10 @@ docker-compose \ --project-directory installation up -d ``` -2. Clear redis cache using `docker exec` command: +### ValueError: There exists an active worker named XXX already + +Issue: You have the following error during container restart -In case of following error during container restarts: ``` frappe-worker-short_1 | Traceback (most recent call last): @@ -367,7 +367,7 @@ frappe-worker-short_1 | raise ValueError(msg.format(self.name)) frappe-worker-short_1 | ValueError: There exists an active worker named '8dfe5c234085.10.short' already ``` -Use commands : +Solution: Clear redis cache using `docker exec` command (take care of replacing `` accordingly): ```sh # Clear the cache which is causing problem. @@ -378,3 +378,13 @@ docker exec -it _redis-socketio_1 redis-cli FLUSHALL ``` Note: Environment variables from `.env` file located at current working directory will be used. + +## Development + +This repository includes a complete setup to develop with Frappe/ERPNext and Bench, Including the following features: + +- VSCode containers integration +- VSCode Python debugger +- Pre-configured Docker containers for an easy start + +A complete Readme is available in [development/README.md](development/README.md) \ No newline at end of file From 3ff3df0831a042ef345b03d01db6ec8cd7bcdc09 Mon Sep 17 00:00:00 2001 From: Davide Bortolami Date: Sun, 8 Mar 2020 20:29:17 +0000 Subject: [PATCH 49/65] Grammar fixes --- README.md | 53 ++++++++++++++++++++++--------------------- development/README.md | 14 ++++++------ 2 files changed, 34 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index c10bbb28..264e568e 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ This docker installation takes care of the following: * Setting up all the system requirements: eg. MariaDB, Node, Redis. * [OPTIONAL] Configuring networking for remote access and setting up LetsEncrypt -For docker based development refer this [README](development/README.md) +For docker based development refer to this [README](development/README.md) ## Deployment @@ -44,13 +44,13 @@ To get started, copy the existing `env-example` file to `.env` inside the `insta - `VERSION=edge` - In this case, `edge` corresponds to `develop`. To setup any other version, you may use the branch name or version specific tags. (eg. version-12, v11.1.15, v11) - `MYSQL_ROOT_PASSWORD=admin` - - Bootstraps a MariaDB container with this value set as the root password. If a managed MariaDB instance is to be used, there is no need to set the password here. + - Bootstraps a MariaDB container with this value set as the root password. If a managed MariaDB instance is used, there is no need to set the password here. - `MARIADB_HOST=mariadb` - - Sets the hostname to `mariadb`. This is required if the database is managed with the containerized MariaDB instance. - - In case of a separately managed database setup, set the value to the database's hostname/IP/domain. + - Sets the hostname to `mariadb`. This is required if the database is managed by the containerized MariaDB instance. + - In case of a separately managed database setups, set the value to the database's hostname/IP/domain. - `SITES=site1.domain.com,site2.domain.com` - - List of sites that are part of the deployment "bench". Each site is separated by a comma(,). - - If LetsEncrypt is being setup, make sure that the DNS for all the site's domains are pointing to the current instance. + - List of sites that are part of the deployment "bench" Each site is separated by a comma(,). + - If LetsEncrypt is being setup, make sure that the DNS for all the site's domains correctly point to the current instance. - `LETSENCRYPT_EMAIL=your.email@your.domain.com` - Email for LetsEncrypt expiry notification. This is only required if you are setting up LetsEncrypt. @@ -58,7 +58,7 @@ To get started, copy the existing `env-example` file to `.env` inside the `insta ### Local deployment for testing For trying out locally or to develop apps using ERPNext REST API port 80 must be published. -The first command will start the containers, the second command will publish the port of the *-nginx container. +The first command will start the containers; the second command will publish the port of the *-nginx container. For Erpnext: @@ -100,10 +100,11 @@ docker-compose \ Make sure to replace `` with the desired name you wish to set for the project. Notes: - - The local deployment is for testing and REST API development purpose only -- A more complete development environment is available [here](Development/README.md) - - The site names are limited to patterns matching \*.localhost by default - - Additional site name patterns can be added by editing /etc/hosts of your host machine + +- The local deployment is for testing and REST API development purpose only +- A complete development environment is available [here](Development/README.md) +- The site names are limited to patterns matching \*.localhost by default +- Additional site name patterns can be added by editing /etc/hosts of your host machine ### Deployment for production @@ -111,7 +112,7 @@ Notes: Letsencrypt Nginx Proxy Companion can optionally be setup to provide SSL. This is recommended for instances accessed over the internet. -Your DNS will need to be configured correctly in order for Letsencrypt to verify your domain. +Your DNS will need to be configured correctly for Letsencrypt to verify your domain. To setup the proxy companion, run the following commands: @@ -143,7 +144,7 @@ Note: use `docker-compose-frappe.yml` in case you need only Frappe without ERPNe ### Docker containers -This repository contains the following docker-compose files each one containing the described images: +This repository contains the following docker-compose files, each one containing the described images: * docker-compose-common.yml * redis-cache * volume: redis-cache-vol @@ -173,7 +174,7 @@ This repository contains the following docker-compose files each one containing * frappe-worker-long: background runner for long-running jobs * frappe-schedule -* docker-compose-networks.yml: this yml define the network to communicate with *Letsencrypt Nginx Proxy Companion*. +* docker-compose-networks.yml: this yaml define the network to communicate with *Letsencrypt Nginx Proxy Companion*. ### Site operations @@ -182,8 +183,8 @@ This repository contains the following docker-compose files each one containing Note: -- Wait for the mariadb service to start before trying to create a new site. - - If new site creation fails, retry after the mariadb container is up and running. +- Wait for the MariaDB service to start before trying to create a new site. + - If new site creation fails, retry after the MariaDB container is up and running. - If you're using a managed database instance, make sure that the database is running before setting up a new site. - Use `.env` file or environment variables instead of passing secrets as command arguments. @@ -201,18 +202,18 @@ docker exec -it \ Environment Variables needed: - `SITE_NAME`: name of the new site to create. -- `DB_ROOT_USER`: MariaDB Root user. The user that can create databases. -- `MYSQL_ROOT_PASSWORD`: In case of mariadb docker container use the one set in `MYSQL_ROOT_PASSWORD` in previous steps. In case of managed database use appropriate password. -- `ADMIN_PASSWORD`: set the administrator password for new site. +- `DB_ROOT_USER`: MariaDB Root user. +- `MYSQL_ROOT_PASSWORD`: In case of the MariaDB docker container use the one set in `MYSQL_ROOT_PASSWORD` in previous steps. In case of a managed database use the appropriate password. +- `ADMIN_PASSWORD`: set the administrator password for the new site. - `INSTALL_APPS='erpnext'`: available only in erpnext-worker and erpnext containers (or other containers with custom apps). Installs ERPNext (and/or the specified apps, comma-delinieated) on this new site. -- `FORCE=1`: is optional variable which force installs the same site. +- `FORCE=1`: optional variable which force installation of the same site. #### Backup Sites Environment Variables -- `SITES` is list of sites separated by (:) colon to migrate. e.g. `SITES=site1.domain.com` or `SITES=site1.domain.com:site2.domain.com` By default all sites in bench will be backed up. -- `WITH_FILES` if set to 1, it will backup user uploaded files for the sites. +- `SITES` is list of sites separated by `:` colon to migrate. e.g. `SITES=site1.domain.com` or `SITES=site1.domain.com:site2.domain.com` By default all sites in bench will be backed up. +- `WITH_FILES` if set to 1, it will backup user-uploaded files. ```sh docker exec -it \ @@ -221,7 +222,7 @@ docker exec -it \ _erpnext-python_1 docker-entrypoint.sh backup ``` -Backup will be available in the `sites` mounted volume. +The backup will be available in the `sites` mounted volume. #### Updating and Migrating Sites @@ -252,7 +253,7 @@ docker exec -it \ ### Custom apps -To add your own Frappe/ERPNext apps to the image, we'll need to create a custom image with the help of a special wrapper script +To add your own Frappe/ERPNext apps to the image, we'll need to create a custom image with the help of a unique wrapper script > For the sake of simplicity, in this example, we'll be using a place holder called `[custom]`, and we'll be building off the edge image. @@ -305,7 +306,7 @@ Open up `./installation/docker-compose-custom.yml` and replace all instances of sed -i "s#\[app\]#[custom]#" ./installation/docker-compose-custom.yml ``` -Install like usual, except that when you set the `INSTALL_APPS` variable set it to `erpnext,[custom]`. +Install like usual, except that when you set the `INSTALL_APPS` variable to `erpnext,[custom]`. ## Troubleshoot @@ -377,7 +378,7 @@ docker exec -it _redis-queue_1 redis-cli FLUSHALL docker exec -it _redis-socketio_1 redis-cli FLUSHALL ``` -Note: Environment variables from `.env` file located at current working directory will be used. +Note: Environment variables from `.env` file located at the current working directory will be used. ## Development diff --git a/development/README.md b/development/README.md index 57c1453e..6c9d708a 100644 --- a/development/README.md +++ b/development/README.md @@ -32,7 +32,7 @@ For most people getting started with Frappe development, the best solution is to Notes: - The `development` directory is ignored by git. It is mounted and available inside the container. Create all your benches (installations of bench, the tool that manages frappe) inside this directory. -- nvm with node v12 and v10 is installed. Check with `nvm ls`. Node v12 is default. +- nvm with node v12 and v10 is installed. Check with `nvm ls`. Node v12 is used by default. ### Setup first bench @@ -56,9 +56,9 @@ bench set-redis-socketio-host redis-socketio:6379 ### Edit Honcho's Procfile -Honcho is the tool used by Bench to manage all the processes Frappe requires. Usually, these all run in localhost, but in this case we have external containers for Redis. For this reason, we have to stop Honcho from trying to start Redis processes. +Honcho is the tool used by Bench to manage all the processes Frappe requires. Usually, these all run in localhost, but in this case, we have external containers for Redis. For this reason, we have to stop Honcho from trying to start Redis processes. -Open the Procfile file and remove the three lines containing the configuration from Redis, either by editing manually the file +Open the Procfile file and remove the three lines containing the configuration from Redis, either by editing manually the file. ```shell code Procfile @@ -71,7 +71,7 @@ sed -i '/redis/d' ./Procfile ### Create a new site with bench -You can create a new site with the following command +You can create a new site with the following command: ```shell bench new-site sitename @@ -89,7 +89,7 @@ Your website will now be accessible on [localhost on port 8000](http://locahost: ### Fixing MariaDB issues after rebuilding the container The `bench new-site` command creates a user in MariaDB with container IP as host, for this reason after rebuilding the container there is a chance that you will not be able to access MariaDB correctly with the previous configuration -The parameter `'db_name'@'%'` needs to be set in MariaDB and permission to the site database properly assigned to the user. +The parameter `'db_name'@'%'` needs to be set in MariaDB and permission to the site database suitably assigned to the user. Open sites/common_site_config.json: @@ -133,7 +133,7 @@ docker exec -e "TERM=xterm-256color" -w /workspace/development -it devcontainer_ To enable Python debugging inside Visual Studio Code, you must first install the `ms-python.python` extension inside the container. -- Click on the extensions icon of VSCode +- Click on the extension icon inside VSCode - Search `ms-python.python` - Click on `Install on Dev Container: Frappe Bench` - Click on 'Reload' @@ -150,4 +150,4 @@ honcho start \ worker_default ``` -This command starts all processes but Redis (which is already running in separate container) and the `web` process, which we can finally start from the debugger tab of VSCode. +This command starts all processes with the exception of Redis (which is already running in separate container) and the `web` process. The latter can can finally be started from the debugger tab of VSCode. From 8611c2dc051053f1bec044b0152f690fe18f7acd Mon Sep 17 00:00:00 2001 From: Davide Bortolami Date: Sun, 8 Mar 2020 23:37:30 +0000 Subject: [PATCH 50/65] reduce layers, cleanup comments --- build/bench/Dockerfile | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/build/bench/Dockerfile b/build/bench/Dockerfile index 4261adc8..e5800ba9 100644 --- a/build/bench/Dockerfile +++ b/build/bench/Dockerfile @@ -72,17 +72,15 @@ RUN bench --version # Print version and verify bashrc is properly sourced so that everything works in the interactive shell RUN bash -c "bench --version" - -# Install nvm with node -# !!! UPDATE PERIODICALLY WITH LATEST VERSIONS !!! +# !!! UPDATE NODEJS PERIODICALLY WITH LATEST VERSIONS !!! # https://nodejs.org/en/about/releases/ # https://nodejs.org/download/release/latest-v10.x/ # https://nodejs.org/download/release/latest-v12.x/ # https://nodejs.org/download/release/latest-v13.x/ - ENV NODE_VERSION=12.16.1 ENV NODE_VERSION_FRAPPEV11=10.19.0 +# Install nvm with node RUN wget https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh RUN chmod +x install.sh RUN ./install.sh @@ -99,13 +97,13 @@ ENV PATH="/home/frappe/.nvm/versions/node/v${NODE_VERSION}/bin/:${PATH}" RUN npm install -g yarn # Print version and verify bashrc is properly sourced so that everything works in the Dockerfile -RUN node --version -RUN npm --version -RUN yarn --version +RUN node --version \ + && npm --version \ + && yarn --version # Print version and verify bashrc is properly sourced so that everything works in the interactive shell -RUN bash -c "node --version" -RUN bash -c "npm --version" -RUN bash -c "yarn --version" +RUN bash -c "node --version" \ + && bash -c "npm --version" \ + && bash -c "yarn --version" WORKDIR /home/frappe/frappe-bench From 4e0d744591fcd4a66a9a162c7eb871ff8b52911f Mon Sep 17 00:00:00 2001 From: Revant Nandgaonkar Date: Mon, 9 Mar 2020 13:49:35 +0530 Subject: [PATCH 51/65] fix: README(s) INSTALL_APPS variable fix, previous failed site_config has db info instead of common_site_config --- README.md | 6 +++--- development/README.md | 14 +++++++++----- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 264e568e..2b688b1f 100644 --- a/README.md +++ b/README.md @@ -195,17 +195,17 @@ docker exec -it \ -e "DB_ROOT_USER=$DB_ROOT_USER" \ -e "MYSQL_ROOT_PASSWORD=$MYSQL_ROOT_PASSWORD" \ -e "ADMIN_PASSWORD=$ADMIN_PASSWORD" \ - -e "INSTALL_APPS='erpnext'" \ + -e "INSTALL_APPS=erpnext" \ _erpnext-python_1 docker-entrypoint.sh new ``` Environment Variables needed: - `SITE_NAME`: name of the new site to create. -- `DB_ROOT_USER`: MariaDB Root user. +- `DB_ROOT_USER`: MariaDB Root user. - `MYSQL_ROOT_PASSWORD`: In case of the MariaDB docker container use the one set in `MYSQL_ROOT_PASSWORD` in previous steps. In case of a managed database use the appropriate password. - `ADMIN_PASSWORD`: set the administrator password for the new site. -- `INSTALL_APPS='erpnext'`: available only in erpnext-worker and erpnext containers (or other containers with custom apps). Installs ERPNext (and/or the specified apps, comma-delinieated) on this new site. +- `INSTALL_APPS=erpnext`: available only in erpnext-worker and erpnext containers (or other containers with custom apps). Installs ERPNext (and/or the specified apps, comma-delinieated) on this new site. - `FORCE=1`: optional variable which force installation of the same site. #### Backup Sites diff --git a/development/README.md b/development/README.md index 6c9d708a..81489a1e 100644 --- a/development/README.md +++ b/development/README.md @@ -45,7 +45,7 @@ cd frappe-bench ### Setup hosts -We need to tell bench to use the right containers instead of localhosts. Run the following commands inside the container: +We need to tell bench to use the right containers instead of localhost. Run the following commands inside the container: ```shell bench set-mariadb-host mariadb @@ -83,7 +83,8 @@ for example: bench new-site localhost ``` -The command will ask the MariaDB root password. The default root password is `123` +The command will ask the MariaDB root password. The default root password is `123`. +This will create a new site and a `localhost` directory under `frappe-bench/sites`. Your website will now be accessible on [localhost on port 8000](http://locahost:8000) ### Fixing MariaDB issues after rebuilding the container @@ -91,11 +92,14 @@ Your website will now be accessible on [localhost on port 8000](http://locahost: The `bench new-site` command creates a user in MariaDB with container IP as host, for this reason after rebuilding the container there is a chance that you will not be able to access MariaDB correctly with the previous configuration The parameter `'db_name'@'%'` needs to be set in MariaDB and permission to the site database suitably assigned to the user. -Open sites/common_site_config.json: +This step has to be repeated for all sites available under the current bench. +Example shows the queries to be executed for site `localhost` + +Open sites/localhost/site_config.json: ```shell -code sites/common_site_config.json +code sites/localhost/site_config.json ``` and take note of the parameters `db_name` and `db_password`. @@ -106,7 +110,7 @@ Enter MariaDB Interactive shell: mysql -uroot -p123 -hmariadb ``` -Execute following queries replacing db_name` and `db_password` with the values found in common_site_config.json. +Execute following queries replacing `db_name` and `db_password` with the values found in site_config.json. ```sql UPDATE mysql.user SET Host = '%' where User = 'db_name'; FLUSH PRIVILEGES; From 07a43e5386f984dd4259e10e511d017dffaf15e8 Mon Sep 17 00:00:00 2001 From: Davide Bortolami Date: Mon, 9 Mar 2020 13:26:42 +0000 Subject: [PATCH 52/65] removed not needed volume --- build/bench/Dockerfile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/build/bench/Dockerfile b/build/bench/Dockerfile index e5800ba9..39fbabea 100644 --- a/build/bench/Dockerfile +++ b/build/bench/Dockerfile @@ -107,6 +107,4 @@ RUN bash -c "node --version" \ WORKDIR /home/frappe/frappe-bench -EXPOSE 8000 9000 6787 - -VOLUME [ "/root/frappe-bench" ] +EXPOSE 8000 9000 6787 \ No newline at end of file From b36513f8fd8badfdd14d6269df1212655941324c Mon Sep 17 00:00:00 2001 From: Davide Bortolami Date: Mon, 9 Mar 2020 13:29:58 +0000 Subject: [PATCH 53/65] fix image build fail --- build/frappe-nginx/Dockerfile | 8 ++++---- build/frappe-nginx/v11.Dockerfile | 8 ++++---- build/frappe-nginx/v12.Dockerfile | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/build/frappe-nginx/Dockerfile b/build/frappe-nginx/Dockerfile index 425b3fe0..36168b9c 100644 --- a/build/frappe-nginx/Dockerfile +++ b/build/frappe-nginx/Dockerfile @@ -23,6 +23,10 @@ RUN git clone --depth 1 https://github.com/frappe/bench /tmp/bench \ RUN cp -R /home/frappe/frappe-bench/apps/frappe/frappe/public/* /home/frappe/frappe-bench/sites/assets/frappe \ && cp -R /home/frappe/frappe-bench/apps/frappe/node_modules /home/frappe/frappe-bench/sites/assets/frappe/ +RUN node --version +RUN npm --version +RUN yarn --version + FROM nginx:latest COPY --from=0 /home/frappe/frappe-bench/sites /var/www/html/ COPY --from=0 /var/www/error_pages /var/www/ @@ -31,10 +35,6 @@ COPY build/frappe-nginx/docker-entrypoint.sh / RUN apt-get update && apt-get install -y rsync && apt-get clean -RUN node --version -RUN npm --version -RUN yarn --version - VOLUME [ "/assets" ] ENTRYPOINT ["/docker-entrypoint.sh"] diff --git a/build/frappe-nginx/v11.Dockerfile b/build/frappe-nginx/v11.Dockerfile index f6590101..4c97dccc 100644 --- a/build/frappe-nginx/v11.Dockerfile +++ b/build/frappe-nginx/v11.Dockerfile @@ -23,6 +23,10 @@ RUN git clone --depth 1 https://github.com/frappe/bench /tmp/bench \ RUN cp -R /home/frappe/frappe-bench/apps/frappe/frappe/public/* /home/frappe/frappe-bench/sites/assets/frappe \ && cp -R /home/frappe/frappe-bench/apps/frappe/node_modules /home/frappe/frappe-bench/sites/assets/frappe/ +RUN node --version +RUN npm --version +RUN yarn --version + FROM nginx:latest COPY --from=0 /home/frappe/frappe-bench/sites /var/www/html/ COPY --from=0 /var/www/error_pages /var/www/ @@ -31,10 +35,6 @@ COPY build/frappe-nginx/docker-entrypoint.sh / RUN apt-get update && apt-get install -y rsync && apt-get clean -RUN node --version -RUN npm --version -RUN yarn --version - VOLUME [ "/assets" ] ENTRYPOINT ["/docker-entrypoint.sh"] diff --git a/build/frappe-nginx/v12.Dockerfile b/build/frappe-nginx/v12.Dockerfile index bb9b0e49..869b45bc 100644 --- a/build/frappe-nginx/v12.Dockerfile +++ b/build/frappe-nginx/v12.Dockerfile @@ -23,6 +23,10 @@ RUN git clone --depth 1 https://github.com/frappe/bench /tmp/bench \ RUN cp -R /home/frappe/frappe-bench/apps/frappe/frappe/public/* /home/frappe/frappe-bench/sites/assets/frappe \ && cp -R /home/frappe/frappe-bench/apps/frappe/node_modules /home/frappe/frappe-bench/sites/assets/frappe/ +RUN node --version +RUN npm --version +RUN yarn --version + FROM nginx:latest COPY --from=0 /home/frappe/frappe-bench/sites /var/www/html/ COPY --from=0 /var/www/error_pages /var/www/ @@ -31,10 +35,6 @@ COPY build/frappe-nginx/docker-entrypoint.sh / RUN apt-get update && apt-get install -y rsync && apt-get clean -RUN node --version -RUN npm --version -RUN yarn --version - VOLUME [ "/assets" ] ENTRYPOINT ["/docker-entrypoint.sh"] From 104f3e67e23a05388b119a925e01f1cb19daaf53 Mon Sep 17 00:00:00 2001 From: Davide Bortolami Date: Mon, 9 Mar 2020 13:39:28 +0000 Subject: [PATCH 54/65] =?UTF-8?q?reduce=20layers=20=E2=80=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build/frappe-socketio/Dockerfile | 7 +++---- build/frappe-socketio/v11.Dockerfile | 7 +++---- build/frappe-socketio/v12.Dockerfile | 7 +++---- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/build/frappe-socketio/Dockerfile b/build/frappe-socketio/Dockerfile index fcb6c0fb..da9462c1 100644 --- a/build/frappe-socketio/Dockerfile +++ b/build/frappe-socketio/Dockerfile @@ -19,7 +19,9 @@ RUN cd /home/frappe/frappe-bench/apps/frappe \ --output /home/frappe/frappe-bench/apps/frappe/node_utils.js RUN cd /home/frappe/frappe-bench/apps/frappe \ - && npm install --only=production + && npm install --only=production \ + && node --version \ + && npm --version COPY build/frappe-socketio/health.js /home/frappe/frappe-bench/apps/frappe/health.js RUN chown -R frappe:frappe /home/frappe @@ -30,8 +32,5 @@ RUN ln -s /usr/local/bin/docker-entrypoint.sh / # backwards compat WORKDIR /home/frappe/frappe-bench/sites -RUN node --version -RUN npm --version - ENTRYPOINT ["docker-entrypoint.sh"] CMD ["start"] diff --git a/build/frappe-socketio/v11.Dockerfile b/build/frappe-socketio/v11.Dockerfile index 49732267..ed3885fc 100644 --- a/build/frappe-socketio/v11.Dockerfile +++ b/build/frappe-socketio/v11.Dockerfile @@ -19,7 +19,9 @@ RUN cd /home/frappe/frappe-bench/apps/frappe \ --output /home/frappe/frappe-bench/apps/frappe/node_utils.js RUN cd /home/frappe/frappe-bench/apps/frappe \ - && npm install --only=production + && npm install --only=production \ + && node --version \ + && npm --version COPY build/frappe-socketio/health.js /home/frappe/frappe-bench/apps/frappe/health.js RUN chown -R frappe:frappe /home/frappe @@ -30,8 +32,5 @@ RUN ln -s /usr/local/bin/docker-entrypoint.sh / # backwards compat WORKDIR /home/frappe/frappe-bench/sites -RUN node --version -RUN npm --version - ENTRYPOINT ["docker-entrypoint.sh"] CMD ["start"] diff --git a/build/frappe-socketio/v12.Dockerfile b/build/frappe-socketio/v12.Dockerfile index 618712e9..e0cf42b8 100644 --- a/build/frappe-socketio/v12.Dockerfile +++ b/build/frappe-socketio/v12.Dockerfile @@ -19,7 +19,9 @@ RUN cd /home/frappe/frappe-bench/apps/frappe \ --output /home/frappe/frappe-bench/apps/frappe/node_utils.js RUN cd /home/frappe/frappe-bench/apps/frappe \ - && npm install --only=production + && npm install --only=production \ + && node --version \ + && npm --version COPY build/frappe-socketio/health.js /home/frappe/frappe-bench/apps/frappe/health.js RUN chown -R frappe:frappe /home/frappe @@ -30,8 +32,5 @@ RUN ln -s /usr/local/bin/docker-entrypoint.sh / # backwards compat WORKDIR /home/frappe/frappe-bench/sites -RUN node --version -RUN npm --version - ENTRYPOINT ["docker-entrypoint.sh"] CMD ["start"] From 3f8aa8a557d5d1fecf207be2178a08128f0bfd2b Mon Sep 17 00:00:00 2001 From: Davide Bortolami Date: Mon, 9 Mar 2020 16:12:59 +0000 Subject: [PATCH 55/65] Add extensions.json for vscode --- .vscode/extensions.json | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .vscode/extensions.json diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 00000000..0b370274 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,14 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations. + // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp + + // List of extensions which should be recommended for users of this workspace. + "recommendations": [ + "ms-vscode-remote.remote-containers", + "ms-python.python" + ], + // List of extensions recommended by VS Code that should not be recommended for users of this workspace. + "unwantedRecommendations": [ + + ] +} \ No newline at end of file From 6787aae39a407838838d09b3ec8a4d1f1e6be7a0 Mon Sep 17 00:00:00 2001 From: Davide Bortolami Date: Mon, 9 Mar 2020 16:13:13 +0000 Subject: [PATCH 56/65] fixes in readme --- development/README.md | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/development/README.md b/development/README.md index 6c9d708a..229f6004 100644 --- a/development/README.md +++ b/development/README.md @@ -19,15 +19,22 @@ cd frappe_docker For most people getting started with Frappe development, the best solution is to use [ VSCode Remote - Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers). +VSCode should automatically inquiry you to install the required extensions, that can also be installed manually as follows: + - Install Remote - Containers for VSCode - through command line `code --install-extension ms-vscode-remote.remote-containers` - - clicking on the following link: [install](vscode:extension/ms-vscode-remote.remote-containers) + - clicking on the button at the following link: [Remote - Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) + - searching for extension `ms-vscode-remote.remote-containers` - Install Python for VSCode - through command line `code --install-extension ms-python.python` - - clicking on the following link: [install](vscode:extension/ms-python.python) + - clicking on the button at the following link: [install](https://marketplace.visualstudio.com/items?itemName=ms-python.python) + - searching for extension `ms-python.python` + +After the extensions are installed, you can: + - Open frappe_docker folder in VS Code. - `code .` -- From Command Palette (Ctrl + Shift + P) Execute Remote Containers : Reopen in Container. You can also click in the bottom left corner to access the remote container menu. +- Launch the command, from Command Palette (Ctrl + Shift + P) `Execute Remote Containers : Reopen in Container`. You can also click in the bottom left corner to access the remote container menu. Notes: From 1e9cdacf1a0b1e87fc9d995a118d5b7df01201bd Mon Sep 17 00:00:00 2001 From: Davide Bortolami Date: Mon, 9 Mar 2020 23:37:25 +0000 Subject: [PATCH 57/65] Reduce layers --- build/frappe-nginx/Dockerfile | 9 ++++----- build/frappe-nginx/v11.Dockerfile | 9 ++++----- build/frappe-nginx/v12.Dockerfile | 9 ++++----- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/build/frappe-nginx/Dockerfile b/build/frappe-nginx/Dockerfile index 36168b9c..64df31b7 100644 --- a/build/frappe-nginx/Dockerfile +++ b/build/frappe-nginx/Dockerfile @@ -14,7 +14,10 @@ RUN cd /home/frappe/frappe-bench/apps/frappe \ && yarn \ && yarn run production \ && rm -fr node_modules \ - && yarn install --production=true + && yarn install --production=true \ + && node --version \ + && npm --version \ + && yarn --version RUN git clone --depth 1 https://github.com/frappe/bench /tmp/bench \ && mkdir -p /var/www/error_pages \ @@ -23,10 +26,6 @@ RUN git clone --depth 1 https://github.com/frappe/bench /tmp/bench \ RUN cp -R /home/frappe/frappe-bench/apps/frappe/frappe/public/* /home/frappe/frappe-bench/sites/assets/frappe \ && cp -R /home/frappe/frappe-bench/apps/frappe/node_modules /home/frappe/frappe-bench/sites/assets/frappe/ -RUN node --version -RUN npm --version -RUN yarn --version - FROM nginx:latest COPY --from=0 /home/frappe/frappe-bench/sites /var/www/html/ COPY --from=0 /var/www/error_pages /var/www/ diff --git a/build/frappe-nginx/v11.Dockerfile b/build/frappe-nginx/v11.Dockerfile index 4c97dccc..e44e7663 100644 --- a/build/frappe-nginx/v11.Dockerfile +++ b/build/frappe-nginx/v11.Dockerfile @@ -14,7 +14,10 @@ RUN cd /home/frappe/frappe-bench/apps/frappe \ && yarn \ && yarn run production \ && rm -fr node_modules \ - && yarn install --production=true + && yarn install --production=true \ + && node --version \ + && npm --version \ + && yarn --version RUN git clone --depth 1 https://github.com/frappe/bench /tmp/bench \ && mkdir -p /var/www/error_pages \ @@ -23,10 +26,6 @@ RUN git clone --depth 1 https://github.com/frappe/bench /tmp/bench \ RUN cp -R /home/frappe/frappe-bench/apps/frappe/frappe/public/* /home/frappe/frappe-bench/sites/assets/frappe \ && cp -R /home/frappe/frappe-bench/apps/frappe/node_modules /home/frappe/frappe-bench/sites/assets/frappe/ -RUN node --version -RUN npm --version -RUN yarn --version - FROM nginx:latest COPY --from=0 /home/frappe/frappe-bench/sites /var/www/html/ COPY --from=0 /var/www/error_pages /var/www/ diff --git a/build/frappe-nginx/v12.Dockerfile b/build/frappe-nginx/v12.Dockerfile index 869b45bc..29adfead 100644 --- a/build/frappe-nginx/v12.Dockerfile +++ b/build/frappe-nginx/v12.Dockerfile @@ -14,7 +14,10 @@ RUN cd /home/frappe/frappe-bench/apps/frappe \ && yarn \ && yarn run production \ && rm -fr node_modules \ - && yarn install --production=true + && yarn install --production=true \ + && node --version \ + && npm --version \ + && yarn --version RUN git clone --depth 1 https://github.com/frappe/bench /tmp/bench \ && mkdir -p /var/www/error_pages \ @@ -23,10 +26,6 @@ RUN git clone --depth 1 https://github.com/frappe/bench /tmp/bench \ RUN cp -R /home/frappe/frappe-bench/apps/frappe/frappe/public/* /home/frappe/frappe-bench/sites/assets/frappe \ && cp -R /home/frappe/frappe-bench/apps/frappe/node_modules /home/frappe/frappe-bench/sites/assets/frappe/ -RUN node --version -RUN npm --version -RUN yarn --version - FROM nginx:latest COPY --from=0 /home/frappe/frappe-bench/sites /var/www/html/ COPY --from=0 /var/www/error_pages /var/www/ From 31f770d467c2e92c2f0e2ae0c7c303870f025546 Mon Sep 17 00:00:00 2001 From: Davide Bortolami Date: Tue, 10 Mar 2020 00:00:46 +0000 Subject: [PATCH 58/65] UID GID 1000 --- build/bench/Dockerfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/build/bench/Dockerfile b/build/bench/Dockerfile index 39fbabea..04375ab8 100644 --- a/build/bench/Dockerfile +++ b/build/bench/Dockerfile @@ -53,8 +53,9 @@ RUN install_packages \ RUN wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.stretch_amd64.deb RUN dpkg -i wkhtmltox_0.12.5-1.stretch_amd64.deb && rm wkhtmltox_0.12.5-1.stretch_amd64.deb -# Create new user with directory, add user to sudo group, allow passwordless sudo, switch to that user and change directory to user home directory -RUN useradd --no-log-init -r -m -g sudo frappe +# Create new user with home directory, improve docker compatibility with UID/GID 1000, add user to sudo group, allow passwordless sudo, switch to that user and change directory to user home directory +RUN groupadd -g 1000 frappe +RUN useradd --no-log-init -r -m -u 1000 -g 1000 -G sudo frappe RUN echo "frappe ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers USER frappe WORKDIR /home/frappe From ba239c0ebe8bb84e7bd99bc502ec0540612386c9 Mon Sep 17 00:00:00 2001 From: Davide Bortolami Date: Tue, 10 Mar 2020 00:08:50 +0000 Subject: [PATCH 59/65] Install yarn in both nodes --- build/bench/Dockerfile | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/build/bench/Dockerfile b/build/bench/Dockerfile index 04375ab8..d77f6b15 100644 --- a/build/bench/Dockerfile +++ b/build/bench/Dockerfile @@ -85,13 +85,15 @@ ENV NODE_VERSION_FRAPPEV11=10.19.0 RUN wget https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh RUN chmod +x install.sh RUN ./install.sh - ENV NVM_DIR=/home/frappe/.nvm -RUN . "$NVM_DIR/nvm.sh" && nvm install ${NODE_VERSION} + +# Install node for Frappe V11, install yarn RUN . "$NVM_DIR/nvm.sh" && nvm install ${NODE_VERSION_FRAPPEV11} -RUN . "$NVM_DIR/nvm.sh" && nvm use v${NODE_VERSION} +RUN . "$NVM_DIR/nvm.sh" && nvm use v${NODE_VERSION_FRAPPEV11} && npm install -g yarn +# Install node for latest frappe, set as default, install node +RUN . "$NVM_DIR/nvm.sh" && nvm install ${NODE_VERSION} +RUN . "$NVM_DIR/nvm.sh" && nvm use v${NODE_VERSION} && npm install -g yarn RUN . "$NVM_DIR/nvm.sh" && nvm alias default v${NODE_VERSION} -# Add NVM path for user in Dockerfile, interactive shell is already managed by the NVM install script ENV PATH="/home/frappe/.nvm/versions/node/v${NODE_VERSION}/bin/:${PATH}" # Install yarn From 46713d91babfb4af24a536a6b23748873960a55f Mon Sep 17 00:00:00 2001 From: Davide Bortolami Date: Tue, 10 Mar 2020 13:58:06 +0000 Subject: [PATCH 60/65] Add section pointing to documentation on how to enable developer mode --- development/README.md | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/development/README.md b/development/README.md index 7a9e80b1..2f08d3d1 100644 --- a/development/README.md +++ b/development/README.md @@ -65,13 +65,13 @@ bench set-redis-socketio-host redis-socketio:6379 Honcho is the tool used by Bench to manage all the processes Frappe requires. Usually, these all run in localhost, but in this case, we have external containers for Redis. For this reason, we have to stop Honcho from trying to start Redis processes. -Open the Procfile file and remove the three lines containing the configuration from Redis, either by editing manually the file. +Open the Procfile file and remove the three lines containing the configuration from Redis, either by editing manually the file: ```shell code Procfile ``` -or running the following command: +Or running the following command: ```shell sed -i '/redis/d' ./Procfile ``` @@ -94,6 +94,15 @@ The command will ask the MariaDB root password. The default root password is `12 This will create a new site and a `localhost` directory under `frappe-bench/sites`. Your website will now be accessible on [localhost on port 8000](http://locahost:8000) +### Set bench developer mode on the new site + +To develop a new app, the last step will be setting the site into developer mode. Documentation is available at [this link](https://frappe.io/docs/user/en/guides/app-development/how-enable-developer-mode-in-frappe). + +```shell +bench set-config developer_mode 1 +bench clear-cache +``` + ### Fixing MariaDB issues after rebuilding the container The `bench new-site` command creates a user in MariaDB with container IP as host, for this reason after rebuilding the container there is a chance that you will not be able to access MariaDB correctly with the previous configuration From 307ef2d67a475423ce6a54146b17ff1f34bbfe6d Mon Sep 17 00:00:00 2001 From: Revant Nandgaonkar Date: Tue, 10 Mar 2020 20:05:38 +0530 Subject: [PATCH 61/65] fix: publish socketio port in dev docker-compose --- .devcontainer/docker-compose.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml index 2d43b0c6..43498259 100644 --- a/.devcontainer/docker-compose.yml +++ b/.devcontainer/docker-compose.yml @@ -25,6 +25,7 @@ services: - ..:/workspace:cached ports: - "8000:8000" + - "9000:9000" volumes: mariadb-vol: From f506c25a6ed423e40252d2a89af83c532da97561 Mon Sep 17 00:00:00 2001 From: Revant Nandgaonkar Date: Wed, 11 Mar 2020 22:38:48 +0530 Subject: [PATCH 62/65] feat(bench): bash-completion add bash-completion package remove install_packages duplicates workdir set to /home/frappe --- build/bench/Dockerfile | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/build/bench/Dockerfile b/build/bench/Dockerfile index d77f6b15..7c58114d 100644 --- a/build/bench/Dockerfile +++ b/build/bench/Dockerfile @@ -25,9 +25,9 @@ RUN install_packages \ tree \ nano \ software-properties-common \ + bash-completion \ # For psycopg2 libpq-dev \ - build-essential \ # Other libffi-dev \ liblcms2-dev \ @@ -39,7 +39,6 @@ RUN install_packages \ redis-tools \ rlwrap \ tk8.6-dev \ - fonts-cantarell \ # VSCode container requirements net-tools \ # PYTHON @@ -64,9 +63,9 @@ WORKDIR /home/frappe RUN pip3 install --user git+https://github.com/frappe/bench.git#egg=bench --no-cache # Export python executables for Dockerfile -ENV PATH=/home/frappe/.local/bin/:$PATH +ENV PATH=/home/frappe/.local/bin:$PATH # Export python executables for interactive shell -RUN echo "export PATH=/home/frappe/.local/bin/:\$PATH" >> /home/frappe/.bashrc +RUN echo "export PATH=/home/frappe/.local/bin:\$PATH" >> /home/frappe/.bashrc # Print version and verify bashrc is properly sourced so that everything works in the Dockerfile RUN bench --version @@ -89,10 +88,10 @@ ENV NVM_DIR=/home/frappe/.nvm # Install node for Frappe V11, install yarn RUN . "$NVM_DIR/nvm.sh" && nvm install ${NODE_VERSION_FRAPPEV11} -RUN . "$NVM_DIR/nvm.sh" && nvm use v${NODE_VERSION_FRAPPEV11} && npm install -g yarn +RUN . "$NVM_DIR/nvm.sh" && nvm use v${NODE_VERSION_FRAPPEV11} && npm install -g yarn # Install node for latest frappe, set as default, install node RUN . "$NVM_DIR/nvm.sh" && nvm install ${NODE_VERSION} -RUN . "$NVM_DIR/nvm.sh" && nvm use v${NODE_VERSION} && npm install -g yarn +RUN . "$NVM_DIR/nvm.sh" && nvm use v${NODE_VERSION} && npm install -g yarn RUN . "$NVM_DIR/nvm.sh" && nvm alias default v${NODE_VERSION} ENV PATH="/home/frappe/.nvm/versions/node/v${NODE_VERSION}/bin/:${PATH}" @@ -101,13 +100,11 @@ RUN npm install -g yarn # Print version and verify bashrc is properly sourced so that everything works in the Dockerfile RUN node --version \ - && npm --version \ + && npm --version \ && yarn --version # Print version and verify bashrc is properly sourced so that everything works in the interactive shell RUN bash -c "node --version" \ && bash -c "npm --version" \ && bash -c "yarn --version" - -WORKDIR /home/frappe/frappe-bench -EXPOSE 8000 9000 6787 \ No newline at end of file +EXPOSE 8000 9000 6787 From 56124984d737286f4b975d3955b1cd8fe0b7d25e Mon Sep 17 00:00:00 2001 From: Revant Nandgaonkar Date: Thu, 12 Mar 2020 05:53:47 +0530 Subject: [PATCH 63/65] fix(bench): debugger fail after bench update fix debugger fail after bench update error locale.Error: unsupported locale setting add locale to image --- build/bench/Dockerfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build/bench/Dockerfile b/build/bench/Dockerfile index 7c58114d..78a2381c 100644 --- a/build/bench/Dockerfile +++ b/build/bench/Dockerfile @@ -48,6 +48,9 @@ RUN install_packages \ python3-tk \ python-virtualenv +RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen \ + && dpkg-reconfigure --frontend=noninteractive locales + # Install wkhtmltox correctly RUN wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.stretch_amd64.deb RUN dpkg -i wkhtmltox_0.12.5-1.stretch_amd64.deb && rm wkhtmltox_0.12.5-1.stretch_amd64.deb From 40ceb79023232585d66e92eb4ed95e8cd5b1d6c6 Mon Sep 17 00:00:00 2001 From: Revant Nandgaonkar Date: Sat, 14 Mar 2020 22:47:35 +0530 Subject: [PATCH 64/65] fix: python container healthcheck ping all backing services --- build/common/commands/check_connection.py | 118 ++++++++++++++++------ build/common/commands/doctor.py | 26 ++++- 2 files changed, 109 insertions(+), 35 deletions(-) diff --git a/build/common/commands/check_connection.py b/build/common/commands/check_connection.py index abe17199..80fb7dbd 100644 --- a/build/common/commands/check_connection.py +++ b/build/common/commands/check_connection.py @@ -1,6 +1,13 @@ import socket, os, json, time from six.moves.urllib.parse import urlparse +COMMON_SITE_CONFIG_FILE = 'common_site_config.json' +REDIS_QUEUE_KEY = 'redis_queue' +REDIS_CACHE_KEY = 'redis_cache' +REDIS_SOCKETIO_KEY = 'redis_socketio' +DB_HOST_KEY = 'db_host' +DB_PORT = 3306 + def is_open(ip, port, timeout=30): s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.settimeout(timeout) @@ -13,10 +20,11 @@ def is_open(ip, port, timeout=30): finally: s.close() -def check_host(ip, port, retry=10, delay=3): +def check_host(ip, port, retry=10, delay=3, print_attempt=True): ipup = False for i in range(retry): - print("Attempt {i} to connect to {ip}:{port}".format(ip=ip,port=port,i=i+1)) + if print_attempt: + print("Attempt {i} to connect to {ip}:{port}".format(ip=ip,port=port,i=i+1)) if is_open(ip, port): ipup = True break @@ -25,43 +33,87 @@ def check_host(ip, port, retry=10, delay=3): return ipup # Check connection to servers -config = None -try: - with open('common_site_config.json') as config_file: - config = json.load(config_file) -except FileNotFoundError: - raise FileNotFoundError("common_site_config.json missing") -except: - raise ValueError("common_site_config.json is not valid") +def get_config(): + config = None + try: + with open(COMMON_SITE_CONFIG_FILE) as config_file: + config = json.load(config_file) + except FileNotFoundError as exception: + print(exception) + exit(1) + except: + print(COMMON_SITE_CONFIG_FILE+" is not valid") + exit(1) + return config # Check mariadb -check_mariadb = False -check_mariadb = check_host(config.get('db_host', 'mariadb'), 3306) -if not check_mariadb: - raise ConnectionError("Connection to mariadb timed out") +def check_mariadb(retry=10, delay=3, print_attempt=True): + config = get_config() + check_mariadb = False + check_mariadb = check_host( + config.get(DB_HOST_KEY, 'mariadb'), + DB_PORT, + retry, + delay, + print_attempt) + if not check_mariadb: + print("Connection to MariaDB timed out") + exit(1) # Check redis queue -check_redis_queue = False -redis_queue_url = urlparse(config.get("redis_queue","redis://redis:6379")).netloc -redis_queue, redis_queue_port = redis_queue_url.split(":") -check_redis_queue = check_host(redis_queue, redis_queue_port) -if not check_redis_queue: - raise ConnectionError("Connection to redis queue timed out") +def check_redis_queue(retry=10, delay=3, print_attempt=True): + check_redis_queue = False + config = get_config() + redis_queue_url = urlparse(config.get(REDIS_QUEUE_KEY,"redis://redis-queue:6379")).netloc + redis_queue, redis_queue_port = redis_queue_url.split(":") + check_redis_queue = check_host( + redis_queue, + redis_queue_port, + retry, + delay, + print_attempt) + if not check_redis_queue: + print("Connection to redis queue timed out") + exit(1) # Check redis cache -check_redis_cache = False -redis_cache_url = urlparse(config.get("redis_cache","redis://redis:6379")).netloc -redis_cache, redis_cache_port = redis_cache_url.split(":") -check_redis_cache = check_host(redis_cache, redis_cache_port) -if not check_redis_cache: - raise ConnectionError("Connection to redis cache timed out") +def check_redis_cache(retry=10, delay=3, print_attempt=True): + check_redis_cache = False + config = get_config() + redis_cache_url = urlparse(config.get(REDIS_CACHE_KEY,"redis://redis-cache:6379")).netloc + redis_cache, redis_cache_port = redis_cache_url.split(":") + check_redis_cache = check_host( + redis_cache, + redis_cache_port, + retry, + delay, + print_attempt) + if not check_redis_cache: + print("Connection to redis cache timed out") + exit(1) # Check redis socketio -check_redis_socketio = False -redis_socketio_url = urlparse(config.get("redis_socketio","redis://redis:6379")).netloc -redis_socketio, redis_socketio_port = redis_socketio_url.split(":") -check_redis_socketio = check_host(redis_socketio, redis_socketio_port) -if not check_redis_socketio: - raise ConnectionError("Connection to redis socketio timed out") +def check_redis_socketio(retry=10, delay=3, print_attempt=True): + check_redis_socketio = False + config = get_config() + redis_socketio_url = urlparse(config.get(REDIS_SOCKETIO_KEY,"redis://redis-socketio:6379")).netloc + redis_socketio, redis_socketio_port = redis_socketio_url.split(":") + check_redis_socketio = check_host( + redis_socketio, + redis_socketio_port, + retry, + delay, + print_attempt) + if not check_redis_socketio: + print("Connection to redis socketio timed out") + exit(1) -print('Connections OK') +def main(): + check_mariadb() + check_redis_queue() + check_redis_cache() + check_redis_socketio() + print('Connections OK') + +if __name__ == "__main__": + main() diff --git a/build/common/commands/doctor.py b/build/common/commands/doctor.py index 54f508fb..36e71411 100644 --- a/build/common/commands/doctor.py +++ b/build/common/commands/doctor.py @@ -1,4 +1,26 @@ import frappe -from frappe.utils.doctor import doctor +import json +import redis +from rq import Worker +from check_connection import ( + check_mariadb, + check_redis_cache, + check_redis_queue, + check_redis_socketio, +) -doctor() +def main(): + check_mariadb(retry=1, delay=0, print_attempt=False) + print("MariaDB Connected") + check_redis_cache(retry=1, delay=0, print_attempt=False) + print("Redis Cache Connected") + check_redis_queue(retry=1, delay=0, print_attempt=False) + print("Redis Queue Connected") + check_redis_socketio(retry=1, delay=0, print_attempt=False) + print("Redis SocketIO Connected") + + print("Health check successful") + exit(0) + +if __name__ == "__main__": + main() From 6e8d2bf7c234c2256fa348d3d0ec261e94f3220d Mon Sep 17 00:00:00 2001 From: Revant Nandgaonkar Date: Sun, 15 Mar 2020 00:20:28 +0530 Subject: [PATCH 65/65] fix: nginx config add updates from frappe/bench to config --- build/common/nginx-default.conf.template | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/build/common/nginx-default.conf.template b/build/common/nginx-default.conf.template index b9fc161a..f19ccee2 100644 --- a/build/common/nginx-default.conf.template +++ b/build/common/nginx-default.conf.template @@ -11,6 +11,11 @@ server { server_name $http_host; root /var/www/html; + add_header X-Frame-Options "SAMEORIGIN"; + add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload"; + add_header X-Content-Type-Options nosniff; + add_header X-XSS-Protection "1; mode=block"; + location /assets { try_files $uri =404; } @@ -32,6 +37,15 @@ server { } location / { + rewrite ^(.+)/$ $1 permanent; + rewrite ^(.+)/index\.html$ $1 permanent; + rewrite ^(.+)\.html$ $1 permanent; + + location ~ ^/files/.*.(htm|html|svg|xml) { + add_header Content-disposition "attachment"; + try_files /sites/$http_host/public/$uri @webserver; + } + try_files /sites/$http_host/public/$uri @webserver; }