Overview Frappe, Docker, self-hosting

Topics to read through

Clone frappe_docker

git clone https://github.com/frappe/frappe_docker buildwithhussain
cd buildwithhussain

Development

cp -R devcontainer-example .devcontainer
cp -R development/vscode-example development/.vscode
code .

Snippet for mailhog

  # Mock SMTP
  mailhog:
    image: mailhog/mailhog:v1.0.1
    environment:
      - MH_STORAGE=maildir
    volumes:
      - mailhog-data:/maildir
    ports:
      - 1025:1025
      - 8025:8025

...
volumes:
  ...
  mailhog-data:

Reopen in devcontainer

code apps.json

Add following to apps.json:

[
  {
    "url": "https://github.com/frappe/gameplan",
    "branch": "main"
  }
]
./installer.py -t develop -p 3.11.4 -n v18 -j apps.json -v

cp ~/.u2net/u2net.onnx /workspace/development
cd frappe-bench
nvm use v18
bench start

Note: change bench serve command for develop branch in Procfile to bench serve --host=0.0.0.0 --port=8000.

Production

Reopen locally.

Add following in images/custom/Containerfile

COPY --chown=frappe:frappe ./development/u2net.onnx /home/frappe/.u2net/u2net.onnx
export APPS_JSON_BASE64=$(base64 -w 0 ./development/apps.json)
docker build \
  --build-arg=FRAPPE_PATH=https://github.com/frappe/frappe \
  --build-arg=FRAPPE_BRANCH=develop \
  --build-arg=PYTHON_VERSION=3.11.4 \
  --build-arg=NODE_VERSION=18.17.1 \
  --build-arg=APPS_JSON_BASE64=$APPS_JSON_BASE64 \
  --tag=registry.gitlab.com/castlecraft/cepl-erpnext-images/gameplan:latest \
  --file=images/custom/Containerfile .

Push image

docker push registry.gitlab.com/castlecraft/cepl-erpnext-images/gameplan:latest

Try image

Replace image and erpnext install command in pwd.yml.

sed -i 's|frappe/erpnext:v14.39.0|registry.gitlab.com/castlecraft/cepl-erpnext-images/gameplan:latest|g' pwd.yml
sed -i 's|--install-app erpnext|--install-app gameplan|g' pwd.yml

Start services

docker compose -p gameplan -f pwd.yml up -d

Check site logs

docker logs gameplan-create-site-1 -f

Open site http://localhost:8080

10 Likes

Hi @revant_one ,
These steps are very useful for running Docker based Frappe Framework Applications.

How can I run multiple Frappe Container with Domain in single server,
because these steps are for running single Container only.
Is there a way to achieve multiple container in a Single Server?

For MacOS:

export APPS_JSON_BASE64=$(openssl base64 -e -in development/apps.json)

single-server-example.md