Skip to content

Instantly share code, notes, and snippets.

@NagariaHussain
Created September 20, 2023 09:12
Show Gist options
  • Save NagariaHussain/8ecfe34137669c2d43ed07935d9fe189 to your computer and use it in GitHub Desktop.
Save NagariaHussain/8ecfe34137669c2d43ed07935d9fe189 to your computer and use it in GitHub Desktop.
BuildWithHussain Episode 18: Docker with Revant

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

@sduenasg
Copy link

sduenasg commented May 15, 2024

Thanks for the excellent video.

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

Is not working anymore, 08:22:20 web.1 | Error: No such option: --host Did you mean --port?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment