From 869de6218b5c16c76caa0885e19238a673c924bf Mon Sep 17 00:00:00 2001 From: Amanuel Elhanan <69236638+elhananjair@users.noreply.github.com> Date: Sun, 5 Jan 2025 15:45:40 +0300 Subject: [PATCH 1/2] Create custom-apps-podman This is a full guide on building an image with custom apps using Podman. --- docs/custom-apps-podman.md | 91 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 docs/custom-apps-podman.md diff --git a/docs/custom-apps-podman.md b/docs/custom-apps-podman.md new file mode 100644 index 00000000..50ed67c3 --- /dev/null +++ b/docs/custom-apps-podman.md @@ -0,0 +1,91 @@ +## Prerequisites +- podman +- podman-compose +- docker-compose + +Podman (the POD MANager) is a tool for managing containers and images, volumes mounted into those containers, and pods made from groups of containers. It is available on the official repositories of many Linux distributions. + +## Step 1 +- Clone this repository and change the current directory to the downloaded folder + ```cmd + git clone https://github.com/frappe/frappe_docker + cd frappe_docker + ``` +## Step 2 +- Create `apps.json` file with custom apps listed in it + ```json + [ + { + "url": "https://github.com/frappe/erpnext", + "branch": "version-15" + }, + { + "url": "https://github.com/frappe/hrms", + "branch": "version-15" + }, + { + "url": "https://github.com/frappe/helpdesk", + "branch": "main" + } + ] + ``` + Check the syntax of the file using `jq empty apps.json` + ### Generate base64 string from JSON file: + `cmd export APPS_JSON_BASE64=$(base64 -w 0 apps.json)` + +## Step 3 + - Building the custom image using podman + ```ruby + podman build \ + --build-arg=FRAPPE_PATH=https://github.com/frappe/frappe \ + --build-arg=FRAPPE_BRANCH=version-15 \ + --build-arg=APPS_JSON_BASE64=$APPS_JSON_BASE64 \ + --tag=custom:15 \ + --file=images/layered/Containerfile . + ``` + ### Note + - Make sure to use the same tag when you export a variable on the next step + + ## Step 4 + - Using the image + - Export environment variables with image name, tag and pull_policy + ```ruby + export CUSTOM_IMAGE=custom + export CUSTOM_TAG=15 + export PULL_POLICY=never + ``` + - Configuration of parameters used when starting the containers + - create `.env` file copying from example.env (Read more on setting up environemnt variables [here](https://github.com/frappe/frappe_docker/blob/main/docs/environment-variables.md) + + ## Final step + - Creating a compose file + - ```ruby + podman compose -f compose.yaml \ + -f overrides/compose.mariadb.yaml \ + -f overrides/compose.redis.yaml \ + -f overrides/compose.noproxy.yaml \ + config > ./docker-compose.yml + ``` + ### NOTE + - podman compose is just a wrapper, it uses docker-compose if it is available or podman-compose if not. podman-compose have an issue reading .env files ([Issue](https://github.com/containers/podman-compose/issues/475)) and might create an issue when running the containers. + - Creating pod and starting the containers + - `podman-compose --in-pod=1 --project-name erpnext -f ./docker-compose.yml up -d` + +## Creating sites and installing apps + - You can create sites from the backend container + - `podman exec -ti erpnext_backend_1 /bin/bash` + - `bench new-site myerp.net --mariadb-root-password 123456 --admin-password 123123` + - `bench --site myerp.net install-app erpnext` + +## Troubleshoot +- If there is a network issue while building the image, you need to remove caches and restart again + - `podman system reset` + - `sudo rm -rf ~/.local/share/containers/ /var/lib/container ~/.caches/containers` + +- Database issue when restarting the container + - Execute the following commands from **backend** container + - `mysql -uroot -padmin -hdb` (Note: put your db password in place of *admin*). + - `SELECT User, Host FROM mysql.user;` + - Change the IP address to %, e.g. `RENAME USER '_5e5899d8398b5f7b'@'172.18.0.7' TO '_5e5899d8398b5f7b'@'%'` + + From acb08c5179ecf3231b30462561b2c66ab29c89d3 Mon Sep 17 00:00:00 2001 From: Revant Nandgaonkar Date: Mon, 6 Jan 2025 17:47:10 +0530 Subject: [PATCH 2/2] docs: custom apps with podman --- README.md | 1 + docs/custom-apps-podman.md | 131 ++++++++++++++++++++----------------- 2 files changed, 72 insertions(+), 60 deletions(-) diff --git a/README.md b/README.md index 9f0c5c44..d08338ad 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,7 @@ If you ran in a Dev Docker environment, to view container logs: `docker compose ### [Custom Images](#custom-images) - [Custom Apps](docs/custom-apps.md) +- [Custom Apps with podman](docs/custom-apps-podman.md) - [Build Version 10 Images](docs/build-version-10-images.md) ### [Development](#development) diff --git a/docs/custom-apps-podman.md b/docs/custom-apps-podman.md index 50ed67c3..58717e64 100644 --- a/docs/custom-apps-podman.md +++ b/docs/custom-apps-podman.md @@ -1,91 +1,102 @@ ## Prerequisites + - podman - podman-compose - docker-compose -Podman (the POD MANager) is a tool for managing containers and images, volumes mounted into those containers, and pods made from groups of containers. It is available on the official repositories of many Linux distributions. +Podman (the POD MANager) is a tool for managing containers and images, volumes mounted into those containers, and pods made from groups of containers. It is available on the official repositories of many Linux distributions. ## Step 1 + - Clone this repository and change the current directory to the downloaded folder ```cmd git clone https://github.com/frappe/frappe_docker cd frappe_docker ``` + ## Step 2 + - Create `apps.json` file with custom apps listed in it ```json - [ - { - "url": "https://github.com/frappe/erpnext", - "branch": "version-15" - }, - { - "url": "https://github.com/frappe/hrms", - "branch": "version-15" - }, - { - "url": "https://github.com/frappe/helpdesk", - "branch": "main" - } - ] + [ + { + "url": "https://github.com/frappe/erpnext", + "branch": "version-15" + }, + { + "url": "https://github.com/frappe/hrms", + "branch": "version-15" + }, + { + "url": "https://github.com/frappe/helpdesk", + "branch": "main" + } + ] ``` Check the syntax of the file using `jq empty apps.json` ### Generate base64 string from JSON file: `cmd export APPS_JSON_BASE64=$(base64 -w 0 apps.json)` ## Step 3 - - Building the custom image using podman - ```ruby - podman build \ - --build-arg=FRAPPE_PATH=https://github.com/frappe/frappe \ - --build-arg=FRAPPE_BRANCH=version-15 \ - --build-arg=APPS_JSON_BASE64=$APPS_JSON_BASE64 \ - --tag=custom:15 \ - --file=images/layered/Containerfile . - ``` - ### Note - - Make sure to use the same tag when you export a variable on the next step - ## Step 4 - - Using the image - - Export environment variables with image name, tag and pull_policy - ```ruby - export CUSTOM_IMAGE=custom - export CUSTOM_TAG=15 - export PULL_POLICY=never - ``` - - Configuration of parameters used when starting the containers - - create `.env` file copying from example.env (Read more on setting up environemnt variables [here](https://github.com/frappe/frappe_docker/blob/main/docs/environment-variables.md) - - ## Final step - - Creating a compose file - - ```ruby - podman compose -f compose.yaml \ - -f overrides/compose.mariadb.yaml \ - -f overrides/compose.redis.yaml \ - -f overrides/compose.noproxy.yaml \ - config > ./docker-compose.yml - ``` - ### NOTE - - podman compose is just a wrapper, it uses docker-compose if it is available or podman-compose if not. podman-compose have an issue reading .env files ([Issue](https://github.com/containers/podman-compose/issues/475)) and might create an issue when running the containers. - - Creating pod and starting the containers - - `podman-compose --in-pod=1 --project-name erpnext -f ./docker-compose.yml up -d` +- Building the custom image using podman + +```ruby + podman build \ + --build-arg=FRAPPE_PATH=https://github.com/frappe/frappe \ + --build-arg=FRAPPE_BRANCH=version-15 \ + --build-arg=APPS_JSON_BASE64=$APPS_JSON_BASE64 \ + --tag=custom:15 \ + --file=images/layered/Containerfile . +``` + +### Note + +- Make sure to use the same tag when you export a variable on the next step + +## Step 4 + +- Using the image +- Export environment variables with image name, tag and pull_policy + ```ruby + export CUSTOM_IMAGE=custom + export CUSTOM_TAG=15 + export PULL_POLICY=never + ``` +- Configuration of parameters used when starting the containers + - create `.env` file copying from example.env (Read more on setting up environment variables [here](https://github.com/frappe/frappe_docker/blob/main/docs/environment-variables.md) + +## Final step + +- Creating a compose file +- ```ruby + podman compose -f compose.yaml \ + -f overrides/compose.mariadb.yaml \ + -f overrides/compose.redis.yaml \ + -f overrides/compose.noproxy.yaml \ + config > ./docker-compose.yml + ``` + ### NOTE + - podman compose is just a wrapper, it uses docker-compose if it is available or podman-compose if not. podman-compose have an issue reading .env files ([Issue](https://github.com/containers/podman-compose/issues/475)) and might create an issue when running the containers. +- Creating pod and starting the containers + - `podman-compose --in-pod=1 --project-name erpnext -f ./docker-compose.yml up -d` ## Creating sites and installing apps - - You can create sites from the backend container - - `podman exec -ti erpnext_backend_1 /bin/bash` - - `bench new-site myerp.net --mariadb-root-password 123456 --admin-password 123123` - - `bench --site myerp.net install-app erpnext` - + +- You can create sites from the backend container + - `podman exec -ti erpnext_backend_1 /bin/bash` + - `bench new-site myerp.net --mariadb-root-password 123456 --admin-password 123123` + - `bench --site myerp.net install-app erpnext` + ## Troubleshoot + - If there is a network issue while building the image, you need to remove caches and restart again + - `podman system reset` - `sudo rm -rf ~/.local/share/containers/ /var/lib/container ~/.caches/containers` - + - Database issue when restarting the container - Execute the following commands from **backend** container - - `mysql -uroot -padmin -hdb` (Note: put your db password in place of *admin*). - - `SELECT User, Host FROM mysql.user;` + - `mysql -uroot -padmin -hdb` (Note: put your db password in place of _admin_). + - `SELECT User, Host FROM mysql.user;` - Change the IP address to %, e.g. `RENAME USER '_5e5899d8398b5f7b'@'172.18.0.7' TO '_5e5899d8398b5f7b'@'%'` - -