mirror of
https://github.com/frappe/frappe_docker.git
synced 2026-06-26 09:05:10 +00:00
parent
ad4c2fac22
commit
8a94a45120
4 changed files with 110 additions and 113 deletions
|
|
@ -39,31 +39,33 @@ services:
|
||||||
ports:
|
ports:
|
||||||
- 8000-8005:8000-8005
|
- 8000-8005:8000-8005
|
||||||
- 9000-9005:9000-9005
|
- 9000-9005:9000-9005
|
||||||
ui-tester:
|
# enable the below service if you need Cypress UI Tests to be executed
|
||||||
# pass custom command to start Cypress otherwise it will use the entrypoint
|
# Before enabling ensure install_x11_deps.sh has been executed and display variable is exported.
|
||||||
# specified in the Cypress Docker image.
|
# Run install_x11_deps.sh again if DISPLAY is not set
|
||||||
# also pass "--project <folder>" so that when Cypress opens
|
# ui-tester:
|
||||||
# it can find file "cypress.json" and show integration specs
|
# # pass custom command to start Cypress otherwise it will use the entrypoint
|
||||||
# https://on.cypress.io/command-line#cypress-open
|
# # specified in the Cypress Docker image.
|
||||||
entrypoint: 'sleep infinity'
|
# # also pass "--project <folder>" so that when Cypress opens
|
||||||
image: "docker.io/cypress/included:latest"
|
# # it can find file "cypress.json" and show integration specs
|
||||||
#command: sleep infinity
|
# # https://on.cypress.io/command-line#cypress-open
|
||||||
environment:
|
# entrypoint: 'sleep infinity'
|
||||||
- SHELL=/bin/bash
|
# image: "docker.io/cypress/included:latest"
|
||||||
# get the IP address of the host machine and allow X11 to accept
|
# environment:
|
||||||
# incoming connections from that IP address
|
# - SHELL=/bin/bash
|
||||||
# IP=$(ipconfig getifaddr en0) or mac or \
|
# # get the IP address of the host machine and allow X11 to accept
|
||||||
# IP=$($(hostname -I | awk '{print $1}') ) for Ubuntu
|
# # incoming connections from that IP address
|
||||||
# /usr/X11/bin/xhost + $IP
|
# # IP=$(ipconfig getifaddr en0) or mac or \
|
||||||
# then pass the environment variable DISPLAY to show Cypress GUI on the host system
|
# # IP=$($(hostname -I | awk '{print $1}') ) for Ubuntu
|
||||||
# DISPLAY=$IP:0
|
# # /usr/X11/bin/xhost + $IP
|
||||||
- DISPLAY
|
# # then pass the environment variable DISPLAY to show Cypress GUI on the host system
|
||||||
volumes:
|
# # DISPLAY=$IP:0
|
||||||
# for Cypress to communicate with the X11 server pass this socket file
|
# - DISPLAY
|
||||||
# in addition to any other mapped volumes
|
# volumes:
|
||||||
- /tmp/.X11-unix:/tmp/.X11-unix
|
# # for Cypress to communicate with the X11 server pass this socket file
|
||||||
- ..:/workspace:z,cached
|
# # in addition to any other mapped volumes
|
||||||
network_mode: "host"
|
# - /tmp/.X11-unix:/tmp/.X11-unix
|
||||||
|
# - ..:/workspace:z,cached
|
||||||
|
# network_mode: "host"
|
||||||
volumes:
|
volumes:
|
||||||
mariadb-data:
|
mariadb-data:
|
||||||
#postgresql-data:
|
#postgresql-data:
|
||||||
|
|
|
||||||
|
|
@ -106,6 +106,7 @@ def get_args_parser():
|
||||||
default="admin",
|
default="admin",
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
|
"-d",
|
||||||
"--db-type",
|
"--db-type",
|
||||||
action="store",
|
action="store",
|
||||||
type=str,
|
type=str,
|
||||||
|
|
@ -119,7 +120,6 @@ def init_bench_if_not_exist(args):
|
||||||
if os.path.exists(args.bench_name):
|
if os.path.exists(args.bench_name):
|
||||||
cprint("Bench already exists. Only site will be created", level=3)
|
cprint("Bench already exists. Only site will be created", level=3)
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
env = os.environ.copy()
|
env = os.environ.copy()
|
||||||
if args.py_version:
|
if args.py_version:
|
||||||
|
|
@ -135,7 +135,6 @@ def init_bench_if_not_exist(args):
|
||||||
init_command += f"--frappe-path={args.frappe_repo} "
|
init_command += f"--frappe-path={args.frappe_repo} "
|
||||||
init_command += f"--frappe-branch={args.frappe_branch} "
|
init_command += f"--frappe-branch={args.frappe_branch} "
|
||||||
init_command += f"--apps_path={args.apps_json} "
|
init_command += f"--apps_path={args.apps_json} "
|
||||||
#init_command += f"--db_type={args.db_type} " #--db-type postgres
|
|
||||||
init_command += args.bench_name
|
init_command += args.bench_name
|
||||||
print(init_command)
|
print(init_command)
|
||||||
command = [
|
command = [
|
||||||
|
|
@ -200,7 +199,7 @@ def init_bench_if_not_exist(args):
|
||||||
|
|
||||||
|
|
||||||
def create_site_in_bench(args):
|
def create_site_in_bench(args):
|
||||||
mariadb_socket_option=""
|
mariadb_socket_option = ""
|
||||||
if "mariadb" == args.db_type:
|
if "mariadb" == args.db_type:
|
||||||
cprint("Set db_host", level=3)
|
cprint("Set db_host", level=3)
|
||||||
subprocess.call(
|
subprocess.call(
|
||||||
|
|
@ -235,9 +234,7 @@ def create_site_in_bench(args):
|
||||||
apps.remove("frappe")
|
apps.remove("frappe")
|
||||||
for app in apps:
|
for app in apps:
|
||||||
new_site_cmd.append(f"--install-app={app}")
|
new_site_cmd.append(f"--install-app={app}")
|
||||||
|
|
||||||
new_site_cmd.append(args.site_name)
|
new_site_cmd.append(args.site_name)
|
||||||
|
|
||||||
cprint(f"Creating Site {args.site_name} ...", level=2)
|
cprint(f"Creating Site {args.site_name} ...", level=2)
|
||||||
subprocess.call(
|
subprocess.call(
|
||||||
new_site_cmd,
|
new_site_cmd,
|
||||||
|
|
|
||||||
|
|
@ -393,15 +393,15 @@ To run cypress based UI tests in a docker environment, follow the below steps:
|
||||||
```shell
|
```shell
|
||||||
sudo ./install_x11_deps.sh
|
sudo ./install_x11_deps.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
This script will install required deps, enable X11Forwarding and restart SSH daemon and export `DISPLAY` variable.
|
This script will install required deps, enable X11Forwarding and restart SSH daemon and export `DISPLAY` variable.
|
||||||
|
|
||||||
2. Run X11 service `startx` or `xquartz`
|
2. Run X11 service `startx` or `xquartz`
|
||||||
3. Start docker compose services.
|
3. Start docker compose services.
|
||||||
4. SSH into ui-tester service using `docker exec.. ` command
|
4. SSH into ui-tester service using `docker exec..` command
|
||||||
5. Export CYPRESS_baseUrl and other required env variables
|
5. Export CYPRESS_baseUrl and other required env variables
|
||||||
6. Start Cypress UI console by issuing `cypress run command`
|
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)
|
> More references : [Cypress Official Documentation](https://www.cypress.io/blog/2019/05/02/run-cypress-with-a-single-docker-command)
|
||||||
|
|
||||||
> Ensure DISPLAY enviroment is always exported.
|
> Ensure DISPLAY environment is always exported.
|
||||||
|
|
||||||
|
|
@ -51,29 +51,26 @@ if [[ "$OSTYPE" == "linux-gnu" ]]; then
|
||||||
else
|
else
|
||||||
# Check which package manager is available
|
# Check which package manager is available
|
||||||
if command -v apt-get >/dev/null 2>&1; then
|
if command -v apt-get >/dev/null 2>&1; then
|
||||||
package_manager="apt"
|
install_command="sudo apt-get update && sudo apt-get install xorg openbox"
|
||||||
elif command -v dnf >/dev/null 2>&1; then
|
elif command -v dnf >/dev/null 2>&1; then
|
||||||
package_manager="dnf"
|
install_command="sudo dnf install xorg-x11-server-Xorg openbox"
|
||||||
else
|
else
|
||||||
echo "Error: Unable to determine the package manager. Manual installation required."
|
echo "Error: Unable to determine the package manager. Manual installation required."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Install X11 and Openbox based on the package manager
|
|
||||||
if [ "$package_manager" = "apt" ]; then
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install xorg openbox
|
|
||||||
elif [ "$package_manager" = "dnf" ]; then
|
|
||||||
sudo dnf install xorg-x11-server-Xorg openbox
|
|
||||||
fi
|
fi
|
||||||
|
# Check if the installation command is defined
|
||||||
# Check if X11 and Openbox were installed successfully
|
if [ -n "$install_command" ]; then
|
||||||
if [ $? -eq 0 ]; then
|
# Execute the installation command
|
||||||
|
if $install_command; then
|
||||||
echo "X11 and Openbox have been successfully installed."
|
echo "X11 and Openbox have been successfully installed."
|
||||||
else
|
else
|
||||||
echo "Error: Failed to install X11 and Openbox."
|
echo "Error: Failed to install X11 and Openbox."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
echo "Error: Unsupported package manager."
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Call the function to update X11Forwarding
|
# Call the function to update X11Forwarding
|
||||||
|
|
@ -81,10 +78,11 @@ if [[ "$OSTYPE" == "linux-gnu" ]]; then
|
||||||
|
|
||||||
# Get the IP address of the host dynamically
|
# Get the IP address of the host dynamically
|
||||||
host_ip=$(hostname -I | awk '{print $1}')
|
host_ip=$(hostname -I | awk '{print $1}')
|
||||||
xhost + $host_ip && xhost + local:
|
xhost + "$host_ip" && xhost + local:
|
||||||
# Set the DISPLAY variable to the host IP
|
# Set the DISPLAY variable to the host IP
|
||||||
export DISPLAY="$host_ip:0.0"
|
export DISPLAY="$host_ip:0.0"
|
||||||
echo "DISPLAY variable set to $DISPLAY"
|
echo "DISPLAY variable set to $DISPLAY"
|
||||||
|
|
||||||
elif [[ "$OSTYPE" == "darwin"* ]]; then
|
elif [[ "$OSTYPE" == "darwin"* ]]; then
|
||||||
# macOS
|
# macOS
|
||||||
if command -v xquartz >/dev/null 2>&1; then
|
if command -v xquartz >/dev/null 2>&1; then
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue