The base frappe image creates a frappe application container with a bench init
ed folder and a site configured when container instance first starts. The applications can create their own containers using this as the base image. Dockerfile
provides the default behaviour as implemented in the base image.
The base image provides customizations through entrypoints
directory. The numbered files in this directory are executed in same order as returned by 'ls' at the time of container initialization/startup. These scripts can be updated for installation of more frappe applications in the existing bench instance in the container, to execeute bench migrate or to perform some other activity at the time of container startup. By default, the entrypoints are already defined for following tasks -
- Set OS level flags
- Set permissions on sites and logs directories
- Set configuration values for the bench instance created
- Create new site, if not already created, and mark it as current site
- Run
bench migrate
andbench build
for the configured site.
For any customizations in the base image itself, Dockerfile
needs to be updated in a forked repository.
Base image of frappe as created by the Dockerfile
in this folder, implements following at build time -
- Installs
bench
in python 3.7 (on Ubuntu 16.04 Linux) base image from default github repository frommaster
branch. URL for the git rpository can be overridden using build argumentGIT_BENCH_URL
. Example: --build-arg GIT_BENCH_URL=engg.elasticrun.in/tredrun/tredrun-core/bench.git. By defaultmaster
branch is used for bench Git repository. This can be overridden using the build argumentBENCH_BRANCH
e.g. --build-arg BENCH_BRANCH=v4.2. If the git repository needs authentication, same can be provided using build argumentsBENCH_AUTH_USER
andBENCH_AUTH_PASSWORD
. - Installs
frappe
from github repository from master branch by default. This can be overridden usingGIT_FRAPPE_URL
build argument. Example: --build-arg GIT_FRAPPE_URL=engg.elasticrun.in/tredrun/tredrun-core/frappe.git. By defaultmaster
branch is used for frappe Git repository as well. This can be overridden using the build argumentFRAPPE_BRANCH
e.g. --build-arg FRAPPE_BRANCH=v11.x.x. If the git repository needs authentication, same can be provided using build argumentsFRAPPE_AUTH_USER
andFRAPPE_AUTH_PASSWORD
. - Executes
bench init
to create an instance ofbench
in directory/home/frappe/docker-bench
. - Copy
common_site_config_docker.json
,entrypoint.sh
,start.sh
,Procfile
and all.sh
files fromentrypoints
directory into the new bench instance created. - Provides an optional (must be uncommented)
ONBUILD
hook to copy customizations ofentrypoints
scripts having.sh
as extension - Default entry point for the image is
entrypoint.sh
file with working directory as the bench directory (created above). By default,entrypoint.sh
script loops through all.sh
files inentrypoints
directories and executes them one after the other, in same order as returned by thels
command.
The file build.sh
provides a sample build command that can be used to create a tagged image of the application.
To add more applications (e.g. erpnext) into the image, either update the Dockerfile and build a fresh image, or use image created by this Dockerfile as base image and install more applications as part of the application-specific Dockerfile
.
The later option is preferred way to create application-specific images, as it ensures that any changes to the base image are automatically inherited in future.
00_entry.sh
- Sets up OS parameters required by frappe10_mkdirs.sh
- Sets up permissions for thesite
andlogs
directories under bench instance20_setvalues.sh
- Updates values incommon_site_config.json
that is used as global configuration file for all sites installed in the bench instance.30_setup_site.sh
- Creates new site if it is not already created. Skips site creation, if existing site folder is detected containingsite_config.json
file.40_install_apps.sh
- Does not perform any action - placeholder for images to override. Ideally, all applications added to image inDockerfile
should beinstall
ed (usingbench install-app
) as part of this script.50_prepare_bench.sh
- Executesbench migrate
andbench build
as part of preparation just before starting the bench processes.
Any application that wishes to override functionality of each of the scripts above, can include only that script under entrypoints
folder with exact same name. This will override the base image copy of the script as part of the build process. If any additional functonality needs to be introduced in the image, include a new script with appropriate name, such that ls
command returns it in correct position for execution. Any script that is added to the image under entrypoints
folder must ensure that it returns a non-zero exit code only in case of real errors. For any errors that can be ignored, the scripts must handle those errors so that their exit code remains zero (indicating successful execution). If any of the entrypoints
scripts returns a non-zero exit code, the site initialization will abort and container will not start bench process. Container will still be started and can be used for debugging purposes. No other changes are required by the child image.
The script is part of the base image and should not be overridden as part of the child images. It provides checks to ensure that site creation and bench initialization occurs only once for the given deployment. Subsequent executions of the container will re-use the same configurations.
If the site is already created/initialized, this script ony starts the bench processes within the container.
If the site is not already initialized, this script loops through all the .sh
files under entrypoints
folder and executes them sequentially - in the same order as returned by ls
command.