2
0
mirror of https://github.com/frappe/frappe_docker.git synced 2025-01-11 01:32:10 +00:00
frappe_docker/docs/custom-apps.md
Revant Nandgaonkar e6088af885
refactor: build only one frappe/erpnext image (#1032)
* ci: skip frappe builds

* refactor: build only one frappe/erpnext image

* fix: lint nginx entrypoint script

* docs: update and organize docs

* docs: fix lint errors

* fix(custom): pass base64 encoded apps json

* ci: update dependabot

* docs: update contributing

* docs: remove info about multi image setup

* fix: initiate empty common_site_config.json

default config has host keys set to localhost
causes connection errors

* docs: add details for pwd volumes

* fix: symlink assets instead of copy

* fix: nginx private files

* ci: skip docker compose v2 install for ubuntu-latest

* fix: organize layers

* feat: allow remove git remote for custom image

* docs: allow remove git remote for custom image

* fix: remove duplicate --apps_path
2023-01-16 04:20:09 +05:30

3.1 KiB

Clone frappe_docker and switch directory

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

Load custom apps through json

apps.json needs to be passed in as build arg environment variable.

export APPS_JSON='[
  {
    "url": "https://github.com/frappe/payments",
    "branch": "develop"
  },
  {
    "url": "https://github.com/frappe/erpnext",
    "branch": "version-14"
  },
  {
    "url": "https://user:password@git.example.com/project/repository.git",
    "branch": "main"
  }
]'
export APPS_JSON_BASE64=$(echo ${APPS_JSON} | base64 --wrap=0)

You can also generate base64 string from json file:

export APPS_JSON_BASE64=$(base64 --wrap=0 /path/to/apps.json)

Note:

  • url needs to be http(s) git url with token/auth in case of private repo.
  • add dependencies manually in apps.json e.g. add payments if you are installing erpnext
  • use fork repo or branch for ERPNext in case you need to use your fork or test a PR.

Build Image

buildah build \
  --build-arg=FRAPPE_PATH=https://github.com/frappe/frappe \
  --build-arg=FRAPPE_BRANCH=version-14 \
  --build-arg=PYTHON_VERSION=3.10.5 \
  --build-arg=NODE_VERSION=16.18.0 \
  --build-arg=APPS_JSON_BASE64=$APPS_JSON_BASE64 \
  --tag=ghcr.io/user/repo/custom:1.0.0 \
  --file=images/custom/Containerfile .

Note:

  • Use docker instead of buildah as per your setup.
  • FRAPPE_PATH and FRAPPE_BRANCH build args are optional and can be overridden in case of fork/branch or test a PR.
  • Make sure APPS_JSON_BASE64 variable has correct base64 encoded JSON string. It is consumed as build arg, base64 encoding ensures it to be friendly with environment variables. Use jq empty apps.json to validate apps.json file.
  • Make sure the --tag is valid image name that will be pushed to registry.
  • Change --build-arg as per version of Python, NodeJS, Frappe Framework repo and branch
  • Set --build-arg=REMOVE_GIT_REMOTE=true to remove git upstream remotes from all apps. Use this in case they have secrets or private tokens and you don't wish to ship them in final image.

Push image to use in yaml files

Login to docker or buildah

buildah login

Push image

buildah push ghcr.io/user/repo/custom:1.0.0

Use Kaniko

Following executor args are required. Example runs locally in docker container. You can run it part of CI/CD or part of your cluster.

podman run --rm -it \
  -v "$HOME"/.docker/config.json:/kaniko/.docker/config.json \
  gcr.io/kaniko-project/executor:latest \
  --dockerfile=images/custom/Containerfile \
  --context=git://github.com/frappe/frappe_docker \
  --build-arg=FRAPPE_PATH=https://github.com/frappe/frappe \
  --build-arg=FRAPPE_BRANCH=version-14 \
  --build-arg=PYTHON_VERSION=3.10.5 \
  --build-arg=NODE_VERSION=16.18.0 \
  --build-arg=APPS_JSON=$APPS_JSON \
  --destination=ghcr.io/user/repo/custom:1.0.0

More about kaniko

Use Images

Make sure image name is correct to be pushed to registry. After the images are pushed, you can pull them to servers to be deployed. If the registry is private, additional auth is needed.