diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..245ce21 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,21 @@ +{ + "name": "Frappe Bench", + "forwardPorts": [8000, 9000, 6787], + "remoteUser": "frappe", + "settings": { + "terminal.integrated.defaultProfile.linux": "bash", + "debug.node.autoAttach": "disabled" + }, + "dockerComposeFile": "./docker-compose.yml", + "service": "frappe", + "workspaceFolder": "/workspace/frappe-bench", + "postCreateCommand": "bash /workspace/scripts/init.sh", + "shutdownAction": "stopCompose", + "extensions": [ + "ms-python.python", + "ms-vscode.live-server", + "grapecity.gc-excelviewer", + "mtxr.sqltools", + "visualstudioexptteam.vscodeintellicode" + ] +} \ No newline at end of file diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml new file mode 100644 index 0000000..e18f84b --- /dev/null +++ b/.devcontainer/docker-compose.yml @@ -0,0 +1,46 @@ +version: "3.7" +services: + mariadb: + image: mariadb:10.6 + command: + - --character-set-server=utf8mb4 + - --collation-server=utf8mb4_unicode_ci + - --skip-character-set-client-handshake + - --skip-innodb-read-only-compressed # Temporary fix for MariaDB 10.6 + environment: + MYSQL_ROOT_PASSWORD: 123 + volumes: + - mariadb-data:/var/lib/mysql + + # Enable PostgreSQL only if you use it, see development/README.md for more information. + # postgresql: + # image: postgres:11.8 + # environment: + # POSTGRES_PASSWORD: 123 + # volumes: + # - postgresql-data:/var/lib/postgresql/data + + redis-cache: + image: redis:alpine + + redis-queue: + image: redis:alpine + + redis-socketio: + image: redis:alpine + + frappe: + image: frappe/bench:latest + command: sleep infinity + environment: + - SHELL=/bin/bash + volumes: + - ..:/workspace:cached + working_dir: /workspace/frappe-bench + ports: + - 8000-8005:8000-8005 + - 9000-9005:9000-9005 + +volumes: + mariadb-data: + postgresql-data: \ No newline at end of file diff --git a/scripts/init.sh b/scripts/init.sh new file mode 100644 index 0000000..6e30880 --- /dev/null +++ b/scripts/init.sh @@ -0,0 +1,46 @@ +#!bin/bash + +set -e + +if [[ -f "/workspaces/frappe_codespace/frappe-bench/apps/frappe" ]] +then + echo "Bench already exists, skipping init" + exit 0 +fi + +rm -rf /workspaces/frappe_codespace/.git + +source /home/frappe/.nvm/nvm.sh +nvm alias default 18 +nvm use 18 + +echo "nvm use 18" >> ~/.bashrc +cd /workspace + +bench init \ +--ignore-exist \ +--skip-redis-config-generation \ +frappe-bench + +cd frappe-bench + +# Use containers instead of localhost +bench set-mariadb-host mariadb +bench set-redis-cache-host redis-cache:6379 +bench set-redis-queue-host redis-queue:6379 +bench set-redis-socketio-host redis-socketio:6379 + +# Remove redis from Procfile +sed -i '/redis/d' ./Procfile + + +bench new-site dev.localhost \ +--mariadb-root-password 123 \ +--admin-password admin \ +--no-mariadb-socket + +bench --site dev.localhost set-config developer_mode 1 +bench --site dev.localhost clear-cache +bench use dev.localhost +bench get-app print_designer +bench --site dev.localhost install-app print_designer \ No newline at end of file