Everything about Frappe and ERPNext in containers.
To get started you need Docker, docker-compose, and git setup on your machine. For Docker basics and best practices refer to Docker's documentation.
This section explains how to deploy your own custom Frappe app using Docker.
Build a Docker image that includes your custom Frappe app by following the steps below.
Base64 encoded string of apps.json file needs to be passed in as build arg environment variable.
Create the following ./resources/apps.json file:
[
{
"url": "https://{{username}}:{{personal-access-token}}@git.example.com/project/repository.git",
"branch": "main"
}
]Note:
- The
urlneeds to be http(s) git url with personal access tokens in case of private repo. - Add dependencies manually in
apps.jsone.g. adderpnextif you are installinghrms. - Use fork repo or branch for ERPNext in case you need to use your fork or test a PR.
Generate base64 string from json file:
export APPS_JSON_BASE64=$(base64 -w 0 ./resources/apps.json)Test the Previous Step: Decode the Base64-encoded Environment Variable
To verify the previous step, decode the APPS_JSON_BASE64 environment variable (which is Base64-encoded) into a JSON file. Follow the steps below:
- Use the following command to decode and save the output into a JSON file named apps-test-output.json:
echo -n ${APPS_JSON_BASE64} | base64 -d > apps-test-output.json- Open the apps-test-output.json file to review the JSON output and ensure that the content is correct.
Put service account to ./resources/google-cloud-storage.json
Common build args.
FRAPPE_PATH, customize the source repo for frappe framework. Defaults tohttps://github.com/frappe/frappeFRAPPE_BRANCH, customize the source repo branch for frappe framework. Defaults toversion-15.APPS_JSON_BASE64, correct base64 encoded JSON string generated fromapps.jsonfile.
Notes
- Use
buildahordockeras per your setup. - Make sure
APPS_JSON_BASE64variable has correct base64 encoded JSON string. It is consumed as build arg, base64 encoding ensures it to be friendly with environment variables. Usejq empty apps.jsonto validateapps.jsonfile. - Make sure the
--tagis valid image name that will be pushed to registry. See section below for remarks about its use. .gitdirectories for all apps are removed from the image.
This method builds the base and build layer every time, it allows to customize Python and NodeJS runtime versions. It takes more time to build.
It uses images/custom/Containerfile.
docker build \
--build-arg=FRAPPE_PATH=https://github.com/frappe/frappe \
--build-arg BUILD_NO_CACHE=$(date +%s) \
--build-arg=FRAPPE_BRANCH=version-15 \
--build-arg=PYTHON_VERSION=3.11.9 \
--build-arg=NODE_VERSION=18.20.2 \
--build-arg=APPS_JSON_BASE64=$APPS_JSON_BASE64 \
--tag=frappe-bio-ga \
--file=images/custom/Containerfile .Custom build args,
PYTHON_VERSION, use the specified python version for base image. Default is3.11.6.NODE_VERSION, use the specified nodejs version, Default18.18.2.DEBIAN_BASEuse the base Debian version, defaults tobookworm.WKHTMLTOPDF_VERSION, use the specified qt patchedwkhtmltopdfversion. Default is0.12.6.1-3.WKHTMLTOPDF_DISTRO, use the specified distro for debian package. Default isbookworm.
This section provides the basic Docker command to run your custom Frappe image.
docker compose -f pwd.yml up -ddocker logs frappe_docker-create-site-1 -fdocker compose -f pwd.yml downdocker exec -it frappe_docker-backend-1 bash