diff --git a/.github/scripts/get_latest_tags.py b/.github/scripts/get_latest_tags.py index b2e083c4..7d168bab 100644 --- a/.github/scripts/get_latest_tags.py +++ b/.github/scripts/get_latest_tags.py @@ -9,7 +9,7 @@ import sys from typing import Literal Repo = Literal["frappe", "erpnext"] -MajorVersion = Literal["12", "13", "14", "develop"] +MajorVersion = Literal["12", "13", "14", "15", "develop"] def get_latest_tag(repo: Repo, version: MajorVersion) -> str: @@ -57,7 +57,7 @@ def main(_args: list[str]) -> int: parser = argparse.ArgumentParser() parser.add_argument("--repo", choices=["frappe", "erpnext"], required=True) parser.add_argument( - "--version", choices=["12", "13", "14", "develop"], required=True + "--version", choices=["12", "13", "14", "15", "develop"], required=True ) args = parser.parse_args(_args) diff --git a/.github/workflows/build_bench.yml b/.github/workflows/build_bench.yml index a3c87984..26003f28 100644 --- a/.github/workflows/build_bench.yml +++ b/.github/workflows/build_bench.yml @@ -20,16 +20,16 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup QEMU - uses: docker/setup-qemu-action@v2 + uses: docker/setup-qemu-action@v3 with: image: tonistiigi/binfmt:latest platforms: all - name: Setup Buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 - name: Set Environment Variables run: cat example.env | grep -o '^[^#]*' >> "$GITHUB_ENV" @@ -38,20 +38,20 @@ jobs: run: echo "LATEST_BENCH_RELEASE=$(curl -s 'https://api.github.com/repos/frappe/bench/releases/latest' | jq -r '.tag_name')" >> "$GITHUB_ENV" - name: Build and test - uses: docker/bake-action@v3.1.0 + uses: docker/bake-action@v4.1.0 with: targets: bench-test - name: Login if: ${{ github.repository == 'frappe/frappe_docker' && github.event_name != 'pull_request' }} - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Push if: ${{ github.repository == 'frappe/frappe_docker' && github.event_name != 'pull_request' }} - uses: docker/bake-action@v3.1.0 + uses: docker/bake-action@v4.1.0 with: targets: bench push: true diff --git a/.github/workflows/build_develop.yml b/.github/workflows/build_develop.yml index 97ed9a88..e37c5858 100644 --- a/.github/workflows/build_develop.yml +++ b/.github/workflows/build_develop.yml @@ -26,8 +26,8 @@ jobs: repo: erpnext version: develop push: ${{ github.repository == 'frappe/frappe_docker' && github.event_name != 'pull_request' }} - python_version: 3.11.4 - node_version: 18.16.1 + python_version: 3.11.6 + node_version: 18.18.2 secrets: DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} diff --git a/.github/workflows/build_stable.yml b/.github/workflows/build_stable.yml index f33832c1..3566b2ba 100644 --- a/.github/workflows/build_stable.yml +++ b/.github/workflows/build_stable.yml @@ -30,26 +30,26 @@ on: workflow_dispatch: jobs: - v13: - uses: ./.github/workflows/docker-build-push.yml - with: - repo: erpnext - version: "13" - push: ${{ github.repository == 'frappe/frappe_docker' && github.event_name != 'pull_request' }} - python_version: 3.9.17 - node_version: 14.21.3 - secrets: - DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} - DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} - v14: uses: ./.github/workflows/docker-build-push.yml with: repo: erpnext version: "14" push: ${{ github.repository == 'frappe/frappe_docker' && github.event_name != 'pull_request' }} - python_version: 3.10.12 - node_version: 16.20.1 + python_version: 3.10.13 + node_version: 16.20.2 + secrets: + DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} + + v15: + uses: ./.github/workflows/docker-build-push.yml + with: + repo: erpnext + version: "15" + push: ${{ github.repository == 'frappe/frappe_docker' && github.event_name != 'pull_request' }} + python_version: 3.11.6 + node_version: 18.18.2 secrets: DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} @@ -58,19 +58,19 @@ jobs: name: Update example.env and pwd.yml runs-on: ubuntu-latest if: ${{ github.repository == 'frappe/frappe_docker' && github.event_name != 'pull_request' }} - needs: v14 + needs: v15 steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: "3.10" - name: Get latest versions - run: python3 ./.github/scripts/get_latest_tags.py --repo erpnext --version 14 + run: python3 ./.github/scripts/get_latest_tags.py --repo erpnext --version 15 - name: Update run: | @@ -96,7 +96,7 @@ jobs: name: Release Helm runs-on: ubuntu-latest if: ${{ github.repository == 'frappe/frappe_docker' && github.event_name != 'pull_request' }} - needs: v14 + needs: v15 steps: - name: Setup deploy key @@ -113,4 +113,4 @@ jobs: run: | git clone git@github.com:frappe/helm.git && cd helm pip install -r release_wizard/requirements.txt - ./release_wizard/wizard 14 patch --remote origin --ci + ./release_wizard/wizard 15 patch --remote origin --ci diff --git a/.github/workflows/docker-build-push.yml b/.github/workflows/docker-build-push.yml index 2bdb363d..b519ec9a 100644 --- a/.github/workflows/docker-build-push.yml +++ b/.github/workflows/docker-build-push.yml @@ -40,10 +40,10 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup Buildx - uses: docker/setup-buildx-action@v2 + uses: docker/setup-buildx-action@v3 with: driver-opts: network=host @@ -56,14 +56,14 @@ jobs: echo "NODE_VERSION=${{ inputs.node_version }}" >> "$GITHUB_ENV" - name: Build - uses: docker/bake-action@v3.1.0 + uses: docker/bake-action@v4.1.0 with: push: true env: REGISTRY_USER: localhost:5000/frappe - name: Setup Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: "3.10" @@ -77,13 +77,13 @@ jobs: - name: Login if: ${{ inputs.push }} - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Push if: ${{ inputs.push }} - uses: docker/bake-action@v3.1.0 + uses: docker/bake-action@v4.1.0 with: push: true diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 432c9dbd..ce4ab6ee 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -13,16 +13,16 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: "3.10.6" # For shfmt pre-commit hook - name: Setup Go - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: go-version: "^1.14" diff --git a/.github/workflows/pre-commit-autoupdate.yml b/.github/workflows/pre-commit-autoupdate.yml index 7290563b..a8e5bf1b 100644 --- a/.github/workflows/pre-commit-autoupdate.yml +++ b/.github/workflows/pre-commit-autoupdate.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Update pre-commit hooks uses: vrslev/pre-commit-autoupdate@v1.0.0 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a541f46c..a7e6e048 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v4.5.0 hooks: - id: check-executables-have-shebangs - id: check-shebang-scripts-are-executable @@ -8,13 +8,13 @@ repos: - id: end-of-file-fixer - repo: https://github.com/asottile/pyupgrade - rev: v3.10.1 + rev: v3.15.0 hooks: - id: pyupgrade args: [--py37-plus] - repo: https://github.com/psf/black - rev: 23.7.0 + rev: 23.11.0 hooks: - id: black @@ -24,12 +24,12 @@ repos: - id: isort - repo: https://github.com/pre-commit/mirrors-prettier - rev: v3.0.1 + rev: v3.1.0 hooks: - id: prettier - repo: https://github.com/codespell-project/codespell - rev: v2.2.5 + rev: v2.2.6 hooks: - id: codespell args: @@ -47,7 +47,7 @@ repos: types: [shell] - repo: https://github.com/shellcheck-py/shellcheck-py - rev: v0.9.0.5 + rev: v0.9.0.6 hooks: - id: shellcheck args: [-x] diff --git a/compose.yaml b/compose.yaml index 10b1e663..75baa6b6 100644 --- a/compose.yaml +++ b/compose.yaml @@ -20,6 +20,7 @@ services: entrypoint: - bash - -c + # add redis_socketio for backward compatibility command: - > ls -1 apps > sites/apps.txt; @@ -27,14 +28,13 @@ services: bench set-config -gp db_port $$DB_PORT; bench set-config -g redis_cache "redis://$$REDIS_CACHE"; bench set-config -g redis_queue "redis://$$REDIS_QUEUE"; - bench set-config -g redis_socketio "redis://$$REDIS_SOCKETIO"; + bench set-config -g redis_socketio "redis://$$REDIS_QUEUE"; bench set-config -gp socketio_port $$SOCKETIO_PORT; environment: DB_HOST: ${DB_HOST} DB_PORT: ${DB_PORT} REDIS_CACHE: ${REDIS_CACHE} REDIS_QUEUE: ${REDIS_QUEUE} - REDIS_SOCKETIO: ${REDIS_SOCKETIO} SOCKETIO_PORT: 9000 depends_on: {} @@ -70,15 +70,11 @@ services: queue-short: <<: *backend_defaults - command: bench worker --queue short - - queue-default: - <<: *backend_defaults - command: bench worker --queue default + command: bench worker --queue short,default queue-long: <<: *backend_defaults - command: bench worker --queue long + command: bench worker --queue long,default,short scheduler: <<: *backend_defaults diff --git a/devcontainer-example/docker-compose.yml b/devcontainer-example/docker-compose.yml index ea07eb3a..e27b8daa 100644 --- a/devcontainer-example/docker-compose.yml +++ b/devcontainer-example/docker-compose.yml @@ -1,7 +1,7 @@ version: "3.7" services: mariadb: - image: mariadb:10.6 + image: docker.io/mariadb:10.6 command: - --character-set-server=utf8mb4 - --collation-server=utf8mb4_unicode_ci @@ -20,17 +20,29 @@ services: # volumes: # - postgresql-data:/var/lib/postgresql/data + # Enable Mailpit if you need to test outgoing mail services + # See https://mailpit.axllent.org/ + # mailpit: + # image: axllent/mailpit + # volumes: + # - mailpit-data:/data + # ports: + # - 8025:8025 + # - 1025:1025 + # environment: + # MP_MAX_MESSAGES: 5000 + # MP_DATA_FILE: /data/mailpit.db + # MP_SMTP_AUTH_ACCEPT_ANY: 1 + # MP_SMTP_AUTH_ALLOW_INSECURE: 1 + redis-cache: - image: redis:alpine + image: docker.io/redis:alpine redis-queue: - image: redis:alpine - - redis-socketio: - image: redis:alpine + image: docker.io/redis:alpine frappe: - image: frappe/bench:latest + image: docker.io/frappe/bench:latest command: sleep infinity environment: - SHELL=/bin/bash @@ -42,7 +54,34 @@ services: ports: - 8000-8005:8000-8005 - 9000-9005:9000-9005 - + # enable the below service if you need Cypress UI Tests to be executed + # Before enabling ensure install_x11_deps.sh has been executed and display variable is exported. + # Run install_x11_deps.sh again if DISPLAY is not set + # ui-tester: + # # pass custom command to start Cypress otherwise it will use the entrypoint + # # specified in the Cypress Docker image. + # # also pass "--project " so that when Cypress opens + # # it can find file "cypress.json" and show integration specs + # # https://on.cypress.io/command-line#cypress-open + # entrypoint: 'sleep infinity' + # image: "docker.io/cypress/included:latest" + # environment: + # - SHELL=/bin/bash + # # get the IP address of the host machine and allow X11 to accept + # # incoming connections from that IP address + # # IP=$(ipconfig getifaddr en0) or mac or \ + # # IP=$($(hostname -I | awk '{print $1}') ) for Ubuntu + # # /usr/X11/bin/xhost + $IP + # # then pass the environment variable DISPLAY to show Cypress GUI on the host system + # # DISPLAY=$IP:0 + # - DISPLAY + # volumes: + # # for Cypress to communicate with the X11 server pass this socket file + # # in addition to any other mapped volumes + # - /tmp/.X11-unix:/tmp/.X11-unix + # - ..:/workspace:z,cached + # network_mode: "host" volumes: mariadb-data: - postgresql-data: + #postgresql-data: + #mailpit-data: diff --git a/development/apps-example.json b/development/apps-example.json index f73d9278..513d3d10 100644 --- a/development/apps-example.json +++ b/development/apps-example.json @@ -1,6 +1,6 @@ [ { "url": "https://github.com/frappe/erpnext.git", - "branch": "version-14" + "branch": "version-15" } ] diff --git a/development/installer.py b/development/installer.py index ad5d52c5..44aca431 100755 --- a/development/installer.py +++ b/development/installer.py @@ -72,8 +72,8 @@ def get_args_parser(): "--frappe-branch", action="store", type=str, - help="frappe repo to use, default: version-14", # noqa: E501 - default="version-14", + help="frappe repo to use, default: version-15", # noqa: E501 + default="version-15", ) parser.add_argument( "-p", @@ -97,6 +97,22 @@ def get_args_parser(): action="store_true", help="verbose output", # noqa: E501 ) + parser.add_argument( + "-a", + "--admin-password", + action="store", + type=str, + help="admin password for site, default: admin", # noqa: E501 + default="admin", + ) + parser.add_argument( + "-d", + "--db-type", + action="store", + type=str, + help="Database type to use (e.g., mariadb or postgres)", + default="mariadb", # Set your default database type here + ) return parser @@ -104,7 +120,6 @@ def init_bench_if_not_exist(args): if os.path.exists(args.bench_name): cprint("Bench already exists. Only site will be created", level=3) return - try: env = os.environ.copy() if args.py_version: @@ -129,11 +144,14 @@ def init_bench_if_not_exist(args): ] subprocess.call(command, env=env, cwd=os.getcwd()) cprint("Configuring Bench ...", level=2) - cprint("Set db_host to mariadb", level=3) - subprocess.call( - ["bench", "set-config", "-g", "db_host", "mariadb"], - cwd=os.getcwd() + "/" + args.bench_name, - ) + cprint("Set db_host", level=3) + if args.db_type: + cprint(f"Setting db_type to {args.db_type}", level=3) + subprocess.call( + ["bench", "set-config", "-g", "db_type", args.db_type], + cwd=os.path.join(os.getcwd(), args.bench_name), + ) + cprint("Set redis_cache to redis://redis-cache:6379", level=3) subprocess.call( [ @@ -156,14 +174,17 @@ def init_bench_if_not_exist(args): ], cwd=os.getcwd() + "/" + args.bench_name, ) - cprint("Set redis_socketio to redis://redis-socketio:6379", level=3) + cprint( + "Set redis_socketio to redis://redis-queue:6379 for backward compatibility", # noqa: E501 + level=3, + ) subprocess.call( [ "bench", "set-config", "-g", "redis_socketio", - "redis://redis-socketio:6379", + "redis://redis-queue:6379", ], cwd=os.getcwd() + "/" + args.bench_name, ) @@ -177,20 +198,41 @@ def init_bench_if_not_exist(args): def create_site_in_bench(args): - new_site_cmd = [ - "bench", - "new-site", - "--no-mariadb-socket", - "--mariadb-root-password=123", - "--admin-password=admin", - ] + if "mariadb" == args.db_type: + cprint("Set db_host", level=3) + subprocess.call( + ["bench", "set-config", "-g", "db_host", "mariadb"], + cwd=os.getcwd() + "/" + args.bench_name, + ) + new_site_cmd = [ + "bench", + "new-site", + f"--db-host=mariadb", # Should match the compose service name + f"--db-type={args.db_type}", # Add the selected database type + f"--no-mariadb-socket", + f"--db-root-password=123", # Replace with your MariaDB password + f"--admin-password={args.admin_password}", + ] + else: + cprint("Set db_host", level=3) + subprocess.call( + ["bench", "set-config", "-g", "db_host", "postgresql"], + cwd=os.getcwd() + "/" + args.bench_name, + ) + new_site_cmd = [ + "bench", + "new-site", + f"--db-host=postgresql", # Should match the compose service name + f"--db-type={args.db_type}", # Add the selected database type + f"--db-root-password=123", # Replace with your PostgreSQL password + f"--admin-password={args.admin_password}", + ] apps = os.listdir(f"{os.getcwd()}/{args.bench_name}/apps") apps.remove("frappe") for app in apps: new_site_cmd.append(f"--install-app={app}") - new_site_cmd.append(args.site_name) - + cprint(f"Creating Site {args.site_name} ...", level=2) subprocess.call( new_site_cmd, cwd=os.getcwd() + "/" + args.bench_name, diff --git a/development/vscode-example/launch.json b/development/vscode-example/launch.json index 68fa9309..e3100c7a 100644 --- a/development/vscode-example/launch.json +++ b/development/vscode-example/launch.json @@ -23,18 +23,6 @@ "DEV_SERVER": "1" } }, - { - "name": "Bench Default Worker", - "type": "python", - "request": "launch", - "program": "${workspaceFolder}/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", - "args": ["frappe", "worker", "--queue", "default"], - "pythonPath": "${workspaceFolder}/frappe-bench/env/bin/python", - "cwd": "${workspaceFolder}/frappe-bench/sites", - "env": { - "DEV_SERVER": "1" - } - }, { "name": "Bench Short Worker", "type": "python", diff --git a/docker-bake.hcl b/docker-bake.hcl index a217c6ea..f2a9fc70 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -6,10 +6,10 @@ variable "REGISTRY_USER" { } variable PYTHON_VERSION { - default = "3.11.4" + default = "3.11.6" } variable NODE_VERSION { - default = "18.16.1" + default = "18.18.2" } variable "FRAPPE_VERSION" { diff --git a/docs/development.md b/docs/development.md index 97c07c1e..d8813326 100644 --- a/docs/development.md +++ b/docs/development.md @@ -70,6 +70,8 @@ Notes: Run the following commands in the terminal inside the container. You might need to create a new terminal in VSCode. +NOTE: Prior to doing the following, make sure the user is **frappe**. + ```shell bench init --skip-redis-config-generation frappe-bench cd frappe-bench @@ -82,12 +84,12 @@ To setup frappe framework version 14 bench set `PYENV_VERSION` environment varia bench init --skip-redis-config-generation --frappe-branch version-14 frappe-bench # Or set environment versions explicitly nvm use v16 -PYENV_VERSION=3.10.12 bench init --skip-redis-config-generation --frappe-branch version-14 frappe-bench +PYENV_VERSION=3.10.13 bench init --skip-redis-config-generation --frappe-branch version-14 frappe-bench # Switch directory cd frappe-bench ``` -To setup frappe framework version 13 bench set `PYENV_VERSION` environment variable to `3.9.9` and use NodeJS version 14, +To setup frappe framework version 13 bench set `PYENV_VERSION` environment variable to `3.9.17` and use NodeJS version 14, ```shell nvm use v14 @@ -103,7 +105,7 @@ We need to tell bench to use the right containers instead of localhost. Run the bench set-config -g db_host mariadb bench set-config -g redis_cache redis://redis-cache:6379 bench set-config -g redis_queue redis://redis-queue:6379 -bench set-config -g redis_socketio redis://redis-socketio:6379 +bench set-config -g redis_socketio redis://redis-queue:6379 ``` For any reason the above commands fail, set the values in `common_site_config.json` manually. @@ -113,7 +115,7 @@ For any reason the above commands fail, set the values in `common_site_config.js "db_host": "mariadb", "redis_cache": "redis://redis-cache:6379", "redis_queue": "redis://redis-queue:6379", - "redis_socketio": "redis://redis-socketio:6379" + "redis_socketio": "redis://redis-queue:6379" } ``` @@ -142,7 +144,7 @@ sed -i '/redis/d' ./Procfile You can create a new site with the following command: ```shell -bench new-site sitename --no-mariadb-socket +bench new-site --no-mariadb-socket sitename ``` sitename MUST end with .localhost for trying deployments locally. @@ -150,13 +152,13 @@ sitename MUST end with .localhost for trying deployments locally. for example: ```shell -bench new-site development.localhost --no-mariadb-socket +bench new-site --no-mariadb-socket development.localhost ``` The same command can be run non-interactively as well: ```shell -bench new-site development.localhost --mariadb-root-password 123 --admin-password admin --no-mariadb-socket +bench new-site --mariadb-root-password 123 --admin-password admin --no-mariadb-socket development.localhost ``` The command will ask the MariaDB root password. The default root password is `123`. @@ -169,7 +171,7 @@ To setup site with PostgreSQL as database use option `--db-type postgres` and `- Example: ```shell -bench new-site mypgsql.localhost --db-type postgres --db-host postgresql +bench new-site --db-type postgres --db-host postgresql mypgsql.localhost ``` To avoid entering postgresql username and root password, set it in `common_site_config.json`, @@ -236,21 +238,21 @@ Note: To start bench with debugger refer section for debugging. Most developers work with numerous clients and versions. Moreover, apps may be required to be installed by everyone on the team working for a client. -This is simplified using a script to automate the process of creating a new bench / site and installing the required apps. +This is simplified using a script to automate the process of creating a new bench / site and installing the required apps. `Administrator` password is for created sites is `admin`. Sample `apps-example.json` is used by default, it installs erpnext on current stable release. To install custom apps, copy the `apps-example.json` to custom json file and make changes to list of apps. Pass this file to the `installer.py` script. > You may have apps in private repos which may require ssh access. You may use SSH from your home directory on linux (configurable in docker-compose.yml). ```shell -python installer.py +python installer.py #pass --db-type postgres for postgresdb ``` For command help ```shell python installer.py --help -usage: installer.py [-h] [-j APPS_JSON] [-b BENCH_NAME] [-s SITE_NAME] [-r FRAPPE_REPO] [-t FRAPPE_BRANCH] [-p PY_VERSION] [-n NODE_VERSION] [-v] +usage: installer.py [-h] [-j APPS_JSON] [-b BENCH_NAME] [-s SITE_NAME] [-r FRAPPE_REPO] [-t FRAPPE_BRANCH] [-p PY_VERSION] [-n NODE_VERSION] [-v] [-a ADMIN_PASSWORD] [-d DB_TYPE] options: -h, --help show this help message and exit @@ -263,12 +265,16 @@ options: -r FRAPPE_REPO, --frappe-repo FRAPPE_REPO frappe repo to use, default: https://github.com/frappe/frappe -t FRAPPE_BRANCH, --frappe-branch FRAPPE_BRANCH - frappe repo to use, default: version-14 + frappe repo to use, default: version-15 -p PY_VERSION, --py-version PY_VERSION python version, default: Not Set -n NODE_VERSION, --node-version NODE_VERSION node version, default: Not Set -v, --verbose verbose output + -a ADMIN_PASSWORD, --admin-password ADMIN_PASSWORD + admin password for site, default: admin + -d DB_TYPE, --db-type DB_TYPE + Database type to use (e.g., mariadb or postgres) ``` A new bench and / or site is created for the client with following defaults. @@ -276,6 +282,8 @@ A new bench and / or site is created for the client with following defaults. - MariaDB root password: `123` - Admin password: `admin` +> To use Postegres DB, comment the mariabdb service and uncomment postegres service. + ### Start Frappe with Visual Studio Code Python Debugging To enable Python debugging inside Visual Studio Code, you must first install the `ms-python.python` extension inside the container. This should have already happened automatically, but depending on your VSCode config, you can force it by: @@ -293,8 +301,7 @@ honcho start \ watch \ schedule \ worker_short \ - worker_long \ - worker_default + worker_long ``` Alternatively you can use the VSCode launch configuration "Honcho SocketIO Watch Schedule Worker" which launches the same command as above. @@ -381,3 +388,30 @@ volumes: ``` Access the service by service name from the `frappe` development container. The above service will be accessible via hostname `postgresql`. If ports are published on to host, access it via `localhost:5432`. + +## Using Cypress UI tests + +To run cypress based UI tests in a docker environment, follow the below steps: + +1. Install and setup X11 tooling on VM using the script `install_x11_deps.sh` + +```shell + sudo bash ./install_x11_deps.sh +``` + +This script will install required deps, enable X11Forwarding and restart SSH daemon and export `DISPLAY` variable. + +2. Run X11 service `startx` or `xquartz` +3. Start docker compose services. +4. SSH into ui-tester service using `docker exec..` command +5. Export CYPRESS_baseUrl and other required env variables +6. Start Cypress UI console by issuing `cypress run command` + +> More references : [Cypress Official Documentation](https://www.cypress.io/blog/2019/05/02/run-cypress-with-a-single-docker-command) + +> Ensure DISPLAY environment is always exported. + +## Using Mailpit to test mail services + +To use Mailpit just uncomment the service in the docker-compose.yml file. +The Interface is then available under port 8025 and the smtp service can be used as mailpit:1025. diff --git a/docs/environment-variables.md b/docs/environment-variables.md index 15e61818..0101fcbd 100644 --- a/docs/environment-variables.md +++ b/docs/environment-variables.md @@ -39,11 +39,7 @@ Hostname for redis server to store cache. Set only if external service for redis ### `REDIS_QUEUE` -Hostname for redis server to store queue data. Set only if external service for redis is used. - -### `REDIS_SOCKETIO` - -Hostname for redis server to store socketio data. Set only if external service for redis is used. +Hostname for redis server to store queue data and socketio. Set only if external service for redis is used. ### `ERPNEXT_VERSION` diff --git a/docs/list-of-containers.md b/docs/list-of-containers.md index 2d33ff7a..4ccf66ee 100644 --- a/docs/list-of-containers.md +++ b/docs/list-of-containers.md @@ -30,7 +30,7 @@ All services are described in `compose.yaml` - `frontend`. [nginx](https://www.nginx.com) server that serves JS/CSS assets and routes incoming requests. - `proxy`. [Traefik](https://traefik.io/traefik/) proxy. It is here for complicated setups or HTTPS override (with `overrides/compose.https.yaml`). - `websocket`. Node server that runs [Socket.IO](https://socket.io). -- `queue-short`, `queue-default`, `queue-long`. Python servers that run job queues using [rq](https://python-rq.org). +- `queue-short`, `queue-long`. Python servers that run job queues using [rq](https://python-rq.org). - `scheduler`. Python server that runs tasks on schedule using [schedule](https://schedule.readthedocs.io/en/stable/). ## Overrides diff --git a/docs/migrate-from-multi-image-setup.md b/docs/migrate-from-multi-image-setup.md index 002b5901..79072b0d 100644 --- a/docs/migrate-from-multi-image-setup.md +++ b/docs/migrate-from-multi-image-setup.md @@ -62,14 +62,12 @@ configurator: bench set-config -gp db_port $$DB_PORT; bench set-config -g redis_cache "redis://$$REDIS_CACHE"; bench set-config -g redis_queue "redis://$$REDIS_QUEUE"; - bench set-config -g redis_socketio "redis://$$REDIS_SOCKETIO"; bench set-config -gp socketio_port $$SOCKETIO_PORT; environment: DB_HOST: db DB_PORT: "3306" REDIS_CACHE: redis-cache:6379 REDIS_QUEUE: redis-queue:6379 - REDIS_SOCKETIO: redis-socketio:6379 SOCKETIO_PORT: "9000" # ... removed for brevity ``` @@ -95,7 +93,6 @@ create-site: wait-for-it -t 120 db:3306; wait-for-it -t 120 redis-cache:6379; wait-for-it -t 120 redis-queue:6379; - wait-for-it -t 120 redis-socketio:6379; export start=`date +%s`; until [[ -n `grep -hs ^ sites/common_site_config.json | jq -r ".db_host // empty"` ]] && \ [[ -n `grep -hs ^ sites/common_site_config.json | jq -r ".redis_cache // empty"` ]] && \ @@ -109,7 +106,7 @@ create-site: fi done; echo "sites/common_site_config.json found"; - bench new-site frontend --no-mariadb-socket --admin-password=admin --db-root-password=admin --install-app erpnext --set-default; + bench new-site --no-mariadb-socket --admin-password=admin --db-root-password=admin --install-app erpnext --set-default frontend; # ... removed for brevity ``` diff --git a/docs/setup-options.md b/docs/setup-options.md index afe92ae7..1d49ceea 100644 --- a/docs/setup-options.md +++ b/docs/setup-options.md @@ -40,8 +40,7 @@ Instead of `docker compose config`, you can directly use `docker compose up` to ### Setup Frappe without proxy and external MariaDB and Redis -In this case make sure you've set `DB_HOST`, `DB_PORT`, `REDIS_CACHE`, `REDIS_QUEUE` and `REDIS_SOCKETIO` -environment variables or the `configurator` will fail. +In this case make sure you've set `DB_HOST`, `DB_PORT`, `REDIS_CACHE` and `REDIS_QUEUE` environment variables or the `configurator` will fail. ```sh # Generate YAML @@ -53,8 +52,7 @@ docker compose --project-name -f ~/gitops/docker-compose.yml up - ### Setup ERPNext with proxy and external MariaDB and Redis -In this case make sure you've set `DB_HOST`, `DB_PORT`, `REDIS_CACHE`, `REDIS_QUEUE` and `REDIS_SOCKETIO` -environment variables or the `configurator` will fail. +In this case make sure you've set `DB_HOST`, `DB_PORT`, `REDIS_CACHE` and `REDIS_QUEUE` environment variables or the `configurator` will fail. ```sh # Generate YAML diff --git a/docs/setup_for_linux_mac.md b/docs/setup_for_linux_mac.md index c805fe14..651f67ca 100644 --- a/docs/setup_for_linux_mac.md +++ b/docs/setup_for_linux_mac.md @@ -15,7 +15,7 @@ version: "3" services: backend: - image: frappe/erpnext:v14.27.1 + image: frappe/erpnext:v14 platform: linux/amd64 deploy: restart_policy: @@ -25,7 +25,7 @@ services: - logs:/home/frappe/frappe-bench/logs configurator: - image: frappe/erpnext:v14.27.1 + image: frappe/erpnext:v14 platform: linux/amd64 deploy: restart_policy: @@ -40,21 +40,19 @@ services: bench set-config -gp db_port $$DB_PORT; bench set-config -g redis_cache "redis://$$REDIS_CACHE"; bench set-config -g redis_queue "redis://$$REDIS_QUEUE"; - bench set-config -g redis_socketio "redis://$$REDIS_SOCKETIO"; bench set-config -gp socketio_port $$SOCKETIO_PORT; environment: DB_HOST: db DB_PORT: "3306" 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 - logs:/home/frappe/frappe-bench/logs create-site: - image: frappe/erpnext:v14.27.1 + image: frappe/erpnext:v14 platform: linux/amd64 deploy: restart_policy: @@ -70,7 +68,6 @@ services: wait-for-it -t 120 db:3306; wait-for-it -t 120 redis-cache:6379; wait-for-it -t 120 redis-queue:6379; - wait-for-it -t 120 redis-socketio:6379; export start=`date +%s`; until [[ -n `grep -hs ^ sites/common_site_config.json | jq -r ".db_host // empty"` ]] && \ [[ -n `grep -hs ^ sites/common_site_config.json | jq -r ".redis_cache // empty"` ]] && \ @@ -84,7 +81,7 @@ services: fi done; echo "sites/common_site_config.json found"; - bench new-site frontend --no-mariadb-socket --admin-password=admin --db-root-password=admin --install-app erpnext --set-default; + bench new-site --no-mariadb-socket --admin-password=admin --db-root-password=admin --install-app erpnext --set-default frontend; db: image: mariadb:10.6 @@ -107,7 +104,7 @@ services: - db-data:/var/lib/mysql frontend: - image: frappe/erpnext:v14.27.1 + image: frappe/erpnext:v14 platform: linux/amd64 deploy: restart_policy: @@ -129,23 +126,8 @@ services: ports: - "8080:8080" - queue-default: - image: frappe/erpnext:v14.27.1 - platform: linux/amd64 - deploy: - restart_policy: - condition: on-failure - command: - - bench - - worker - - --queue - - default - volumes: - - sites:/home/frappe/frappe-bench/sites - - logs:/home/frappe/frappe-bench/logs - queue-long: - image: frappe/erpnext:v14.27.1 + image: frappe/erpnext:v14 platform: linux/amd64 deploy: restart_policy: @@ -160,7 +142,7 @@ services: - logs:/home/frappe/frappe-bench/logs queue-short: - image: frappe/erpnext:v14.27.1 + image: frappe/erpnext:v14 platform: linux/amd64 deploy: restart_policy: @@ -192,17 +174,8 @@ services: volumes: - redis-cache-data:/data - redis-socketio: - image: redis:6.2-alpine - platform: linux/amd64 - deploy: - restart_policy: - condition: on-failure - volumes: - - redis-socketio-data:/data - scheduler: - image: frappe/erpnext:v14.27.1 + image: frappe/erpnext:v14 platform: linux/amd64 deploy: restart_policy: @@ -215,7 +188,7 @@ services: - logs:/home/frappe/frappe-bench/logs websocket: - image: frappe/erpnext:v14.27.1 + image: frappe/erpnext:v14 platform: linux/amd64 deploy: restart_policy: @@ -231,13 +204,16 @@ volumes: db-data: redis-queue-data: redis-cache-data: - redis-socketio-data: sites: logs: ``` step3: run the docker +``` +cd frappe_docker +``` + ``` docker-compose -f ./pwd.yml up ``` diff --git a/docs/single-compose-setup.md b/docs/single-compose-setup.md index 59bf4312..aea2914c 100644 --- a/docs/single-compose-setup.md +++ b/docs/single-compose-setup.md @@ -8,9 +8,8 @@ This setup is a very simple single compose file that does everything to start re - backend, serves gunicorn backend - frontend, serves static assets through nginx frontend reverse proxies websocket and gunicorn. -- queue-default, default rq worker. -- queue-long, long rq worker. -- queue-short, short rq worker. +- queue-long, long default and short rq worker. +- queue-short, default and short rq worker. - schedule, event scheduler. - websocket, socketio websocket for realtime communication. @@ -23,8 +22,7 @@ This setup is a very simple single compose file that does everything to start re - db, mariadb, container with frappe specific configuration. - redis-cache, redis for cache data. -- redis-queue, redis for rq data. -- redis-socketio, redis for socketio pubsub. +- redis-queue, redis for rq data and pub/sub. ## Volumes diff --git a/docs/single-server-example.md b/docs/single-server-example.md index 1b617109..419d8766 100644 --- a/docs/single-server-example.md +++ b/docs/single-server-example.md @@ -41,7 +41,7 @@ chmod +x $DOCKER_CONFIG/cli-plugins/docker-compose ### Prepare -Clone `frappe_docker` repo for the needed YAMLs and change the current working director of you shell to the cloned repo. +Clone `frappe_docker` repo for the needed YAMLs and change the current working directory of your shell to the cloned repo. ```shell git clone https://github.com/frappe/frappe_docker @@ -175,7 +175,7 @@ Create sites `one.example.com` and `two.example.com`: ```shell # one.example.com docker compose --project-name erpnext-one exec backend \ - bench new-site one.example.com --no-mariadb-socket --mariadb-root-password changeit --install-app erpnext --admin-password changeit + bench new-site --no-mariadb-socket --mariadb-root-password changeit --install-app erpnext --admin-password changeit one.example.com ``` You can stop here and have a single bench single site setup complete. Continue to add one more site to the current bench. @@ -183,7 +183,7 @@ You can stop here and have a single bench single site setup complete. Continue t ```shell # two.example.com docker compose --project-name erpnext-one exec backend \ - bench new-site two.example.com --no-mariadb-socket --mariadb-root-password changeit --install-app erpnext --admin-password changeit + bench new-site --no-mariadb-socket --mariadb-root-password changeit --install-app erpnext --admin-password changeit two.example.com ``` #### Create second bench @@ -234,10 +234,10 @@ Create sites `three.example.com` and `four.example.com`: ```shell # three.example.com docker compose --project-name erpnext-two exec backend \ - bench new-site three.example.com --no-mariadb-socket --mariadb-root-password changeit --install-app erpnext --admin-password changeit + bench new-site --no-mariadb-socket --mariadb-root-password changeit --install-app erpnext --admin-password changeit three.example.com # four.example.com docker compose --project-name erpnext-two exec backend \ - bench new-site four.example.com --no-mariadb-socket --mariadb-root-password changeit --install-app erpnext --admin-password changeit + bench new-site --no-mariadb-socket --mariadb-root-password changeit --install-app erpnext --admin-password changeit four.example.com ``` #### Create custom domain to existing site diff --git a/docs/site-operations.md b/docs/site-operations.md index fc81add4..793dfef5 100644 --- a/docs/site-operations.md +++ b/docs/site-operations.md @@ -9,7 +9,7 @@ Note: - Wait for the `db` service to start and `configurator` to exit before trying to create a new site. Usually this takes up to 10 seconds. ```sh -docker-compose exec backend bench new-site --no-mariadb-socket --mariadb-root-password --admin-password +docker-compose exec backend bench new-site --no-mariadb-socket --mariadb-root-password --admin-password ``` If you need to install some app, specify `--install-app`. To see all options, just run `bench new-site --help`. @@ -24,7 +24,7 @@ docker-compose exec backend bench set-config -g root_password Also command is slightly different: ```sh -docker-compose exec backend bench new-site --no-mariadb-socket --db-type postgres --admin-password +docker-compose exec backend bench new-site --no-mariadb-socket --db-type postgres --admin-password ``` ## Push backup to S3 storage diff --git a/docs/troubleshoot.md b/docs/troubleshoot.md index a43ed13c..68718280 100644 --- a/docs/troubleshoot.md +++ b/docs/troubleshoot.md @@ -45,3 +45,11 @@ If you are using old version of `docker-compose` the .env file needs to be locat - Set environment variable `COMPOSE_CONVERT_WINDOWS_PATHS` e.g. `set COMPOSE_CONVERT_WINDOWS_PATHS=1` - While using docker machine, port-forward the ports of VM to ports of host machine. (ports 8080/8000/9000) - Name all the sites ending with `.localhost`. and access it via browser locally. e.g. `http://site1.localhost` + +### Redo installation + +- If you have made changes and just want to start over again (abandoning all changes), remove all docker + - containers + - images + - volumes +- Install a fresh diff --git a/example.env b/example.env index fe979047..3a0f1226 100644 --- a/example.env +++ b/example.env @@ -1,6 +1,6 @@ # Reference: https://github.com/frappe/frappe_docker/blob/main/docs/images-and-compose-files.md -ERPNEXT_VERSION=v14.33.2 +ERPNEXT_VERSION=v15.5.0 DB_PASSWORD=123 @@ -11,7 +11,6 @@ DB_PORT= # Only if you use external Redis REDIS_CACHE= REDIS_QUEUE= -REDIS_SOCKETIO= # Only with HTTPS override LETSENCRYPT_EMAIL=mail@example.com diff --git a/images/bench/Dockerfile b/images/bench/Dockerfile index cc5ade6e..291e4256 100644 --- a/images/bench/Dockerfile +++ b/images/bench/Dockerfile @@ -95,21 +95,18 @@ USER frappe WORKDIR /home/frappe # Install Python via pyenv -ENV PYTHON_VERSION_V13=3.9.17 -ENV PYTHON_VERSION_DEVELOP=3.11.4 -ENV PYTHON_VERSION=3.10.12 +ENV PYTHON_VERSION_V14=3.10.13 +ENV PYTHON_VERSION=3.11.6 ENV PYENV_ROOT /home/frappe/.pyenv ENV PATH $PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH # From https://github.com/pyenv/pyenv#basic-github-checkout RUN git clone --depth 1 https://github.com/pyenv/pyenv.git .pyenv \ - && pyenv install $PYTHON_VERSION_V13 \ - && pyenv install $PYTHON_VERSION_DEVELOP \ + && pyenv install $PYTHON_VERSION_V14 \ && pyenv install $PYTHON_VERSION \ - && PYENV_VERSION=$PYTHON_VERSION_V13 pip install --no-cache-dir virtualenv \ - && PYENV_VERSION=$PYTHON_VERSION_DEVELOP pip install --no-cache-dir virtualenv \ + && PYENV_VERSION=$PYTHON_VERSION_V14 pip install --no-cache-dir virtualenv \ && PYENV_VERSION=$PYTHON_VERSION pip install --no-cache-dir virtualenv \ - && pyenv global $PYTHON_VERSION $PYTHON_VERSION_v13 \ + && pyenv global $PYTHON_VERSION $PYTHON_VERSION_v14 \ && sed -Ei -e '/^([^#]|$)/ {a export PYENV_ROOT="/home/frappe/.pyenv" a export PATH="$PYENV_ROOT/bin:$PATH" a ' -e ':a' -e '$!{n;ba};}' ~/.profile \ && echo 'eval "$(pyenv init --path)"' >>~/.profile \ && echo 'eval "$(pyenv init -)"' >>~/.bashrc @@ -125,19 +122,15 @@ RUN git clone ${GIT_REPO} --depth 1 -b ${GIT_BRANCH} .bench \ && echo "export BENCH_DEVELOPER=1" >>/home/frappe/.bashrc # Install Node via nvm -ENV NODE_VERSION_13=14.21.3 -ENV NODE_VERSION_DEVELOP=18.12.0 -ENV NODE_VERSION=16.20.1 +ENV NODE_VERSION_14=16.20.2 +ENV NODE_VERSION=18.18.2 ENV NVM_DIR /home/frappe/.nvm ENV PATH ${NVM_DIR}/versions/node/v${NODE_VERSION}/bin/:${PATH} -RUN wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash \ +RUN wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash \ && . ${NVM_DIR}/nvm.sh \ - && nvm install ${NODE_VERSION_13} \ - && nvm use v${NODE_VERSION_13} \ - && npm install -g yarn \ - && nvm install ${NODE_VERSION_DEVELOP} \ - && nvm use v${NODE_VERSION_DEVELOP} \ + && nvm install ${NODE_VERSION_14} \ + && nvm use v${NODE_VERSION_14} \ && npm install -g yarn \ && nvm install ${NODE_VERSION} \ && nvm use v${NODE_VERSION} \ diff --git a/images/custom/Containerfile b/images/custom/Containerfile index e9200833..9aeecaa8 100644 --- a/images/custom/Containerfile +++ b/images/custom/Containerfile @@ -1,4 +1,4 @@ -ARG PYTHON_VERSION=3.11.4 +ARG PYTHON_VERSION=3.11.6 ARG DEBIAN_BASE=bookworm FROM python:${PYTHON_VERSION}-slim-${DEBIAN_BASE} AS base @@ -7,7 +7,7 @@ COPY resources/nginx-entrypoint.sh /usr/local/bin/nginx-entrypoint.sh ARG WKHTMLTOPDF_VERSION=0.12.6.1-3 ARG WKHTMLTOPDF_DISTRO=bookworm -ARG NODE_VERSION=18.16.1 +ARG NODE_VERSION=18.18.2 ENV NVM_DIR=/home/frappe/.nvm ENV PATH ${NVM_DIR}/versions/node/v${NODE_VERSION}/bin/:${PATH} @@ -36,7 +36,7 @@ RUN useradd -ms /bin/bash frappe \ jq \ # NodeJS && mkdir -p ${NVM_DIR} \ - && curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh | bash \ + && curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash \ && . ${NVM_DIR}/nvm.sh \ && nvm install ${NODE_VERSION} \ && nvm use v${NODE_VERSION} \ @@ -103,7 +103,7 @@ RUN if [ -n "${APPS_JSON_BASE64}" ]; then \ USER frappe -ARG FRAPPE_BRANCH=version-14 +ARG FRAPPE_BRANCH=version-15 ARG FRAPPE_PATH=https://github.com/frappe/frappe RUN export APP_INSTALL_ARGS="" && \ if [ -n "${APPS_JSON_BASE64}" ]; then \ diff --git a/images/production/Containerfile b/images/production/Containerfile index 2add02a0..ac5d77af 100644 --- a/images/production/Containerfile +++ b/images/production/Containerfile @@ -1,10 +1,10 @@ -ARG PYTHON_VERSION=3.11.4 +ARG PYTHON_VERSION=3.11.6 ARG DEBIAN_BASE=bookworm FROM python:${PYTHON_VERSION}-slim-${DEBIAN_BASE} AS base ARG WKHTMLTOPDF_VERSION=0.12.6.1-3 ARG WKHTMLTOPDF_DISTRO=bookworm -ARG NODE_VERSION=18.16.1 +ARG NODE_VERSION=18.18.2 ENV NVM_DIR=/home/frappe/.nvm ENV PATH ${NVM_DIR}/versions/node/v${NODE_VERSION}/bin/:${PATH} @@ -33,7 +33,7 @@ RUN useradd -ms /bin/bash frappe \ jq \ # NodeJS && mkdir -p ${NVM_DIR} \ - && curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh | bash \ + && curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash \ && . ${NVM_DIR}/nvm.sh \ && nvm install ${NODE_VERSION} \ && nvm use v${NODE_VERSION} \ @@ -95,10 +95,10 @@ RUN apt-get update \ USER frappe -ARG FRAPPE_BRANCH=version-14 +ARG FRAPPE_BRANCH=version-15 ARG FRAPPE_PATH=https://github.com/frappe/frappe ARG ERPNEXT_REPO=https://github.com/frappe/erpnext -ARG ERPNEXT_BRANCH=version-14 +ARG ERPNEXT_BRANCH=version-15 RUN bench init \ --frappe-branch=${FRAPPE_BRANCH} \ --frappe-path=${FRAPPE_PATH} \ diff --git a/install_x11_deps.sh b/install_x11_deps.sh new file mode 100755 index 00000000..a66b2042 --- /dev/null +++ b/install_x11_deps.sh @@ -0,0 +1,104 @@ +#!/bin/bash +set -e +# This script configures X11 forwarding for Linux and macOS systems. +# It installs X11, Openbox (on Linux), and checks for XQuartz (on macOS). +# It also updates the sshd_config file to enable X11Forwarding and restarts the SSH service. + +# Check if the script is running with root privileges +if [ "$EUID" -ne 0 ]; then + echo "Error: This script requires root privileges. Please run it as a superuser" + exit 1 +fi + +# Function to restart SSH service (Linux) +restart_ssh_linux() { + if command -v service >/dev/null 2>&1; then + sudo service ssh restart + else + sudo systemctl restart ssh + fi +} + +# Function to restart SSH service (macOS) +restart_ssh_macos() { + launchctl stop com.openssh.sshd + launchctl start com.openssh.sshd +} + +update_x11_forwarding() { + if grep -q "X11Forwarding yes" /etc/ssh/sshd_config; then + echo "X11Forwarding is already set to 'yes' in ssh_config." + else + if [[ "$OSTYPE" == "linux-gnu" ]]; then + # Linux: Use sed for Linux + sudo sed -i 's/#\?X11Forwarding.*/X11Forwarding yes/' /etc/ssh/sshd_config + elif [[ "$OSTYPE" == "darwin"* ]]; then + # macOS: Use sed for macOS + sudo sed -i -E 's/#X11Forwarding.*/X11Forwarding yes/' /etc/ssh/sshd_config + restart_ssh_macos + fi + if [[ "$OSTYPE" == "linux-gnu" ]]; then + restart_ssh_linux + fi + fi +} + +# Determine the operating system +if [[ "$OSTYPE" == "linux-gnu" ]]; then + # Linux + if command -v startx >/dev/null 2>&1; then + echo "X11 is already installed." + else + # Check which package manager is available + if command -v apt-get >/dev/null 2>&1; then + install_command="sudo apt-get update && sudo apt-get install xorg openbox" + elif command -v dnf >/dev/null 2>&1; then + install_command="sudo dnf install xorg-x11-server-Xorg openbox" + else + echo "Error: Unable to determine the package manager. Manual installation required." + exit 1 + fi + fi + # Check if the installation command is defined + if [ -n "$install_command" ]; then + # Execute the installation command + if $install_command; then + echo "X11 and Openbox have been successfully installed." + else + echo "Error: Failed to install X11 and Openbox." + exit 1 + fi + else + echo "Error: Unsupported package manager." + exit 1 + fi + + # Call the function to update X11Forwarding + update_x11_forwarding + + # Get the IP address of the host dynamically + host_ip=$(hostname -I | awk '{print $1}') + xhost + "$host_ip" && xhost + local: + # Set the DISPLAY variable to the host IP + export DISPLAY="$host_ip:0.0" + echo "DISPLAY variable set to $DISPLAY" + +elif [[ "$OSTYPE" == "darwin"* ]]; then + # macOS + if command -v xquartz >/dev/null 2>&1; then + echo "XQuartz is already installed." + else + echo "Error: XQuartz is required for X11 forwarding on macOS. Please install XQuartz manually." + exit 1 + fi + + # Call the function to update X11Forwarding + update_x11_forwarding + + # Export the DISPLAY variable for macOS + export DISPLAY=:0 + echo "DISPLAY variable set to $DISPLAY" +else + echo "Error: Unsupported operating system." + exit 1 +fi diff --git a/overrides/compose.multi-bench.yaml b/overrides/compose.multi-bench.yaml index 0e91a2f8..7e681a18 100644 --- a/overrides/compose.multi-bench.yaml +++ b/overrides/compose.multi-bench.yaml @@ -26,10 +26,6 @@ services: networks: - bench-network - mariadb-network - queue-default: - networks: - - bench-network - - mariadb-network queue-short: networks: - bench-network @@ -48,11 +44,6 @@ services: - bench-network - mariadb-network - redis-socketio: - networks: - - bench-network - - mariadb-network - networks: traefik-public: external: true diff --git a/overrides/compose.redis.yaml b/overrides/compose.redis.yaml index 2be6386d..1c625247 100644 --- a/overrides/compose.redis.yaml +++ b/overrides/compose.redis.yaml @@ -3,11 +3,9 @@ services: environment: REDIS_CACHE: redis-cache:6379 REDIS_QUEUE: redis-queue:6379 - REDIS_SOCKETIO: redis-socketio:6379 depends_on: - redis-cache - redis-queue - - redis-socketio redis-cache: image: redis:6.2-alpine @@ -19,12 +17,6 @@ services: volumes: - redis-queue-data:/data - redis-socketio: - image: redis:6.2-alpine - volumes: - - redis-socketio-data:/data - volumes: redis-cache-data: redis-queue-data: - redis-socketio-data: diff --git a/pwd.yml b/pwd.yml index f77e87a4..45d5ae8b 100644 --- a/pwd.yml +++ b/pwd.yml @@ -2,7 +2,7 @@ version: "3" services: backend: - image: frappe/erpnext:v14.33.2 + image: frappe/erpnext:v15.5.0 deploy: restart_policy: condition: on-failure @@ -11,13 +11,14 @@ services: - logs:/home/frappe/frappe-bench/logs configurator: - image: frappe/erpnext:v14.33.2 + image: frappe/erpnext:v15.5.0 deploy: restart_policy: condition: none entrypoint: - bash - -c + # add redis_socketio for backward compatibility command: - > ls -1 apps > sites/apps.txt; @@ -25,21 +26,20 @@ services: bench set-config -gp db_port $$DB_PORT; bench set-config -g redis_cache "redis://$$REDIS_CACHE"; bench set-config -g redis_queue "redis://$$REDIS_QUEUE"; - bench set-config -g redis_socketio "redis://$$REDIS_SOCKETIO"; + bench set-config -g redis_socketio "redis://$$REDIS_QUEUE"; bench set-config -gp socketio_port $$SOCKETIO_PORT; environment: DB_HOST: db DB_PORT: "3306" 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 - logs:/home/frappe/frappe-bench/logs create-site: - image: frappe/erpnext:v14.33.2 + image: frappe/erpnext:v15.5.0 deploy: restart_policy: condition: none @@ -54,7 +54,6 @@ services: wait-for-it -t 120 db:3306; wait-for-it -t 120 redis-cache:6379; wait-for-it -t 120 redis-queue:6379; - wait-for-it -t 120 redis-socketio:6379; export start=`date +%s`; until [[ -n `grep -hs ^ sites/common_site_config.json | jq -r ".db_host // empty"` ]] && \ [[ -n `grep -hs ^ sites/common_site_config.json | jq -r ".redis_cache // empty"` ]] && \ @@ -68,7 +67,7 @@ services: fi done; echo "sites/common_site_config.json found"; - bench new-site frontend --no-mariadb-socket --admin-password=admin --db-root-password=admin --install-app erpnext --set-default; + bench new-site --no-mariadb-socket --admin-password=admin --db-root-password=admin --install-app erpnext --set-default frontend; db: image: mariadb:10.6 @@ -90,7 +89,7 @@ services: - db-data:/var/lib/mysql frontend: - image: frappe/erpnext:v14.33.2 + image: frappe/erpnext:v15.5.0 deploy: restart_policy: condition: on-failure @@ -111,22 +110,8 @@ services: ports: - "8080:8080" - queue-default: - image: frappe/erpnext:v14.33.2 - deploy: - restart_policy: - condition: on-failure - command: - - bench - - worker - - --queue - - default - volumes: - - sites:/home/frappe/frappe-bench/sites - - logs:/home/frappe/frappe-bench/logs - queue-long: - image: frappe/erpnext:v14.33.2 + image: frappe/erpnext:v15.5.0 deploy: restart_policy: condition: on-failure @@ -134,13 +119,13 @@ services: - bench - worker - --queue - - long + - long,default,short volumes: - sites:/home/frappe/frappe-bench/sites - logs:/home/frappe/frappe-bench/logs queue-short: - image: frappe/erpnext:v14.33.2 + image: frappe/erpnext:v15.5.0 deploy: restart_policy: condition: on-failure @@ -148,7 +133,7 @@ services: - bench - worker - --queue - - short + - short,default volumes: - sites:/home/frappe/frappe-bench/sites - logs:/home/frappe/frappe-bench/logs @@ -169,16 +154,8 @@ services: volumes: - redis-cache-data:/data - redis-socketio: - image: redis:6.2-alpine - deploy: - restart_policy: - condition: on-failure - volumes: - - redis-socketio-data:/data - scheduler: - image: frappe/erpnext:v14.33.2 + image: frappe/erpnext:v15.5.0 deploy: restart_policy: condition: on-failure @@ -190,7 +167,7 @@ services: - logs:/home/frappe/frappe-bench/logs websocket: - image: frappe/erpnext:v14.33.2 + image: frappe/erpnext:v15.5.0 deploy: restart_policy: condition: on-failure @@ -205,6 +182,5 @@ volumes: db-data: redis-queue-data: redis-cache-data: - redis-socketio-data: sites: logs: diff --git a/requirements-test.txt b/requirements-test.txt index 70613be0..f9708e4b 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -1 +1 @@ -pytest==7.4.0 +pytest==7.4.3 diff --git a/resources/nginx-template.conf b/resources/nginx-template.conf index 944bce3c..e6d796a3 100644 --- a/resources/nginx-template.conf +++ b/resources/nginx-template.conf @@ -6,12 +6,6 @@ upstream socketio-server { server ${SOCKETIO} fail_timeout=0; } -# Parse the X-Forwarded-Proto header - if set - defaulting to $scheme. -map $http_x_forwarded_proto $proxy_x_forwarded_proto { - default $scheme; - https https; -} - server { listen 8080; server_name ${FRAPPE_SITE_NAME_HEADER}; @@ -42,8 +36,6 @@ server { location /socket.io { proxy_http_version 1.1; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $proxy_x_forwarded_proto; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header X-Frappe-Site-Name ${FRAPPE_SITE_NAME_HEADER}; @@ -54,9 +46,9 @@ server { } location / { - rewrite ^(.+)/$ $proxy_x_forwarded_proto://${FRAPPE_SITE_NAME_HEADER}$1 permanent; - rewrite ^(.+)/index\.html$ $proxy_x_forwarded_proto://${FRAPPE_SITE_NAME_HEADER}$1 permanent; - rewrite ^(.+)\.html$ $proxy_x_forwarded_proto://${FRAPPE_SITE_NAME_HEADER}$1 permanent; + rewrite ^(.+)/$ $1 permanent; + rewrite ^(.+)/index\.html$ $1 permanent; + rewrite ^(.+)\.html$ $1 permanent; location ~ ^/files/.*.(htm|html|svg|xml) { add_header Content-disposition "attachment"; @@ -67,8 +59,9 @@ server { } location @webserver { - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $proxy_x_forwarded_proto; + proxy_http_version 1.1; + proxy_set_header X-Forwarded-For $remote_addr; + proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Frappe-Site-Name ${FRAPPE_SITE_NAME_HEADER}; proxy_set_header Host $host; proxy_set_header X-Use-X-Accel-Redirect True; diff --git a/tests/_check_connections.py b/tests/_check_connections.py index e54d3b95..85ce87fc 100644 --- a/tests/_check_connections.py +++ b/tests/_check_connections.py @@ -31,7 +31,7 @@ def get_redis_url(addr: str) -> Address: def get_addresses(config: dict[str, Any]) -> Iterable[Address]: yield (config["db_host"], config["db_port"]) - for key in ("redis_cache", "redis_queue", "redis_socketio"): + for key in ("redis_cache", "redis_queue"): yield get_redis_url(config[key]) diff --git a/tests/compose.ci.yaml b/tests/compose.ci.yaml index 156c9018..81c952a5 100644 --- a/tests/compose.ci.yaml +++ b/tests/compose.ci.yaml @@ -14,9 +14,6 @@ services: queue-short: image: localhost:5000/frappe/erpnext:${ERPNEXT_VERSION} - queue-default: - image: localhost:5000/frappe/erpnext:${ERPNEXT_VERSION} - queue-long: image: localhost:5000/frappe/erpnext:${ERPNEXT_VERSION} diff --git a/tests/test_frappe_docker.py b/tests/test_frappe_docker.py index e8fcad0d..85e6f1e8 100644 --- a/tests/test_frappe_docker.py +++ b/tests/test_frappe_docker.py @@ -10,7 +10,6 @@ from tests.utils import Compose, check_url_content BACKEND_SERVICES = ( "backend", "queue-short", - "queue-default", "queue-long", "scheduler", ) @@ -127,7 +126,7 @@ class TestErpnext: ("url", "callback"), ( ( - "/api/method/erpnext.templates.pages.product_search.get_product_list", + "/api/method/erpnext.templates.pages.search_help.get_help_results_sections?text=help", api_cb, ), ("/assets/erpnext/js/setup_wizard.js", assets_cb),