Last active
April 12, 2025 05:43
-
-
Save mlow/7ca814bfec1615791c23aa8cbd34dd0b to your computer and use it in GitHub Desktop.
Simple ERPNext setup script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This script helps with getting Frappe/ERPNext running quickly using | |
# the upstream Compose specifications. Not intended for production. | |
# | |
# Usage: | |
# | |
# $ git clone https://github.com/frappe/frappe_docker | |
# $ cd frappe_docker | |
# $ curl -Lo erpnext.sh <URL to this raw gist> | |
# | |
# You can either make the script executable and run it to get ERPNext | |
# going, or you can simply source the script (`. erpnext.sh`) which will | |
# give your shell access to the internal `erpnext` function to easily | |
# interact with the compose service(s): | |
# | |
# $ erpnext exec backend bench list-apps | |
# $ erpnext exec backend bench get-app <app> | |
# $ erpnext exec backend bench --site <site> install-app <app> | |
# $ erpnext exec backend bash | |
# $ erpnext exec db mariadb -p # or: exec backend bench mariadb | |
# $ erpnext logs -tf | |
# $ erpnext stop | |
# $ erpnext down -v | |
# | |
# etc. | |
# | |
# Dependencies: | |
# - a container frontend that supports Compose specification (default: | |
# `docker compose`. See COMPOSE_FRONTEND. Other frontends may not support | |
# all required compose features.) | |
# - curl (only if ERPNEXT_VERSION is not supplied) | |
# Override the following with environment variables if desired | |
ERPNEXT_VERSION=${ERPNEXT_VERSION:-""} | |
SITE=${SITE:-mysite} | |
MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD:-123} | |
ADMIN_PASSWORD=${ADMIN_PASSWORD:-admin} | |
COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME:-erpnext-dev} | |
COMPOSE_FRONTEND=${COMPOSE_FRONTEND:-"docker compose"} | |
PROJECT_DIR=${1:-$PWD} | |
PROJECT_DIR=${PROJECT_DIR%/} | |
if [ -z "$ERPNEXT_VERSION" ]; then | |
ERPNEXT_VERSION=$(curl -s https://api.github.com/repos/frappe/erpnext/releases/latest | grep tag_name | cut -d'"' -f4) | |
fi | |
echo "Setting up ERPNext ${ERPNEXT_VERSION}" | |
echo "Writing environment file to ${PROJECT_DIR}/erpnext.env" | |
cat << EOF > ${PROJECT_DIR}/erpnext.env | |
FRAPPE_SITE_NAME_HEADER=${SITE} | |
ERPNEXT_VERSION=${ERPNEXT_VERSION} | |
DB_HOST=mariadb | |
DB_PORT=3306 | |
DB_PASSWORD=${MYSQL_ROOT_PASSWORD} | |
REDIS_CACHE=redis-cache | |
REDIS_QUEUE=redis-queue | |
REDIS_SOCKETIO=redis-socketio | |
EOF | |
function erpnext() { | |
${COMPOSE_FRONTEND} \ | |
-f "${PROJECT_DIR}/compose.yaml" \ | |
-f "${PROJECT_DIR}/overrides/compose.mariadb.yaml" \ | |
-f "${PROJECT_DIR}/overrides/compose.redis.yaml" \ | |
-f "${PROJECT_DIR}/overrides/compose.noproxy.yaml" \ | |
--env-file "${PROJECT_DIR}/erpnext.env" \ | |
--project-name ${COMPOSE_PROJECT_NAME} \ | |
--project-directory "${PROJECT_DIR}" \ | |
"$@" | |
} | |
# Fire up containers | |
erpnext up -d | |
# Create our site (does nothing if it already exists) | |
erpnext exec backend bench new-site ${SITE} \ | |
--no-mariadb-socket \ | |
--db-root-password "${MYSQL_ROOT_PASSWORD}" \ | |
--admin-password "${ADMIN_PASSWORD}" \ | |
--install-app erpnext \ | |
--set-default | |
echo | |
echo "Done! If you sourced this script, run 'erpnext ps' to see running containers." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment