erpNEXT deploy, conventional way

System Update & Prerequisites

sudo apt update && sudo apt upgrade -y

sudo apt install -y git python3-dev python3-pip python3-setuptools python3-venv python3-full build-essential libmysqlclient-dev libssl-dev libffi-dev redis-server curl software-properties-common pkg-config

Install MariaDBate & Prerequisites

因為 host Ubuntu 巳有安裝mairadb,改用docker 佈署mariadb

# 建立mariadb directory
mkdir /path/to/mariadb/folder
cd  /path/to/mariadb/folder

# copy 建立setup.sh
chmod +x setup.sh
./setup.sh

# 啟動dokcer mairadb
docker compose up -d

# 確認mariadb 是否運行正常
docker compose ps
mysql -h 127.0.0.1 -P 3406 -u root -p
# setup.sh

#!/usr/bin/env bash

# Get the directory where the script is located
BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

echo "Setting up Frappe MariaDB environment in $BASE_DIR..."

# 1. Create Data Directory in the current path
mkdir -p "$BASE_DIR/data"

# 2. Create .env File
cat <<EOF > "$BASE_DIR/.env"
# Database Credentials
MYSQL_ROOT_PASSWORD=frappe_admin_123

# Host Port Configuration
DB_HOST_PORT=3306
# 如果 host 巳有佈署mariadb,必需變更port以避免衝宊

EOF

# 3. Create docker-compose.yml
cat <<EOF > "$BASE_DIR/docker-compose.yml"
services:
  mariadb:
    image: mariadb:10.6
    container_name: frappe-mariadb
    command:
      - --character-set-server=utf8mb4
      - --collation-server=utf8mb4_unicode_ci
      - --skip-character-set-client-handshake
      - --innodb-file-format=barracuda
      - --innodb-file-per-table=1
      - --innodb-large-prefix=1
      - --innodb-read-only-compressed=OFF
    environment:
      - MYSQL_ROOT_PASSWORD=\${MYSQL_ROOT_PASSWORD}
    volumes:
      - ./data:/var/lib/mysql
    ports:
      - "\${DB_HOST_PORT}:3306"
    restart: always
EOF

# 4. Set Permissions
chmod -R 775 "$BASE_DIR/data"

echo "-------------------------------------------------------"
echo "SUCCESS: Configuration files and data folder created in:"
echo "$BASE_DIR"
echo ""
echo "ATTENTION: Please revise the PORT and ADMIN PASSWORD in .env before running 'docker compose up -d'"
echo "-------------------------------------------------------"

Install Node.js and Yarn

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
source ~/.bashrc
nvm install 20
npm install -g yarn

Install Frappe Bench

sudo apt update
sudo apt install -y pipx
pipx ensurepath
pipx install uv

# you may need to restart your terminal or run source ~/.bashrc

Install Frappe Bench via pipx

pipx install frappe-bench
bench --version

Initialize Bench

bench init frappeBENCH --frappe-branch version-15
cd my-frappe-bench


# Generate the missing config file
bench setup supervisor

# Link it (if not already linked)
sudo ln -sf $(pwd)/config/supervisor.conf /etc/supervisor/conf.d/frappe-bench.conf

# Load it into Supervisor
sudo supervisorctl reread
sudo supervisorctl update

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *