Skip to content

Commit

Permalink
cleanup and documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Nj Subedi authored and Nj Subedi committed Jan 4, 2023
1 parent d23a90e commit f4b2e2d
Show file tree
Hide file tree
Showing 5 changed files with 127 additions and 168 deletions.
6 changes: 4 additions & 2 deletions CloudronManifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@
"changelog": "file://manifest/CHANGELOG.md",
"postInstallMessage": "file://manifest/POSTINSTALL.md",
"healthCheckPath": "/",
"configurePath": "/app/",
"httpPort": 8888,
"memoryLimit": 4294967296,
"multiDomain": true,
"addons": {
"localstorage": {},
"recvmail": {},
"sendmail": { "supportsDisplayName": true },
"sendmail": {
"supportsDisplayName": true
},
"ldap": {},
"redis": {
"noPassword": true
Expand Down
39 changes: 14 additions & 25 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
FROM cloudron/base:4.0.0@sha256:31b195ed0662bdb06a6e8a5ddbedb6f191ce92e8bee04c03fb02dd4e9d0286df

# Create all necessary directories

RUN mkdir -p /app/code /app/data/{frappe-bench,mariadb} \
&& chown -R cloudron:cloudron /app/code /app/data

WORKDIR /app/code/frappe-bench

# Remove unnecessary database and php packages (takes some time)
# install mariadb (10.6 default), python (3.10 default) and required python3 packages
RUN apt-get remove -y --purge mongodb-* postgresql-* *mysql* *mariadb* \
Expand All @@ -21,41 +14,39 @@ RUN apt-get remove -y --purge mongodb-* postgresql-* *mysql* *mariadb* \
mariadb-server mariadb-backup\
&& pip3 install frappe-bench

ARG FRAPPE_VERSION=v14.21.0
ENV FRAPPE_VERSION=v14.21.1 ERPNEXT_VERSION=v14.12.0

RUN chown -R 1000:1000 /app/code
RUN mkdir -p /app/code/frappe-bench /app/pkg && \
chown -R 1000:1000 /app/code

WORKDIR /app/code/frappe-bench

# Initialize frappe-bench, whatever it means.
RUN /usr/local/bin/gosu cloudron:cloudron bench init --verbose \
RUN gosu cloudron:cloudron bench init --verbose \
--frappe-branch ${FRAPPE_VERSION} \
--skip-redis-config-generation \
--ignore-exist \
--python /usr/bin/python3 \
/app/code/frappe-bench

# [1]This is a standard procedure for Cloudron to move existing "data" somewhere else,
# and put a symlink to /app/data from the original location; on first run, we copy
# files from <dir>-orig to /app/data/<dir>, which in turn points to the actual files.
# anyone who has packaged an app would know this practice.

# Move the folders that frappe would pollute with writes at runtime.
RUN mkdir -p /app/data/frappe \
&& mv /app/code/frappe-bench/sites /app/code/frappe-bench/sites-orig \
RUN mkdir -p /app/pkg/frappe-bench-orig \
&& mv /app/code/frappe-bench/sites /app/pkg/frappe-bench-orig/sites \
&& ln -sf /app/data/frappe/sites /app/code/frappe-bench/sites \
\
&& mv /app/code/frappe-bench/env /app/code/frappe-bench/env-orig \
&& mv /app/code/frappe-bench/env /app/pkg/frappe-bench-orig/env \
&& ln -sf /app/data/frappe/env /app/code/frappe-bench/env \
\
&& mv /app/code/frappe-bench/config /app/code/frappe-bench/config-orig \
&& mv /app/code/frappe-bench/config /app/pkg/frappe-bench-orig/config \
&& ln -sf /app/data/frappe/config /app/code/frappe-bench/config \
\
&& mv /app/code/frappe-bench/apps /app/code/frappe-bench/apps-orig \
&& mv /app/code/frappe-bench/apps /app/pkg/frappe-bench-orig/apps \
&& ln -sf /app/data/frappe/apps /app/code/frappe-bench/apps \
\
&& mv /app/code/frappe-bench/logs /app/code/frappe-bench/logs-orig \
&& mv /app/code/frappe-bench/logs /app/pkg/frappe-bench-orig/logs \
&& ln -sf /run/frappe/logs /app/code/frappe-bench/logs \
\
&& mv /app/code/frappe-bench/patches.txt /app/code/frappe-bench/patches-orig.txt \
&& mv /app/code/frappe-bench/patches.txt /app/pkg/frappe-bench-orig/patches.txt \
&& ln -sf /app/data/frappe/patches.txt /app/code/frappe-bench/patches.txt


Expand All @@ -82,7 +73,7 @@ RUN sudo mysqld_safe & \

COPY supervisor/ /etc/supervisor/

RUN mkdir -p /run/supervisor/{logs} \
RUN mkdir -p /run/supervisor/logs \
&& sudo ln -s /run/supervisor/logs/supervisord.log /var/log/supervisor/supervisord.log \
\
&& rm /etc/nginx/sites-enabled/* \
Expand All @@ -94,6 +85,4 @@ RUN ln -sf /run/.yarnrc /home/cloudron/.yarnrc

COPY nginx.conf setup-ldap.sh start.sh /app/pkg/

ENV ERPNEXT_VERSION=v14.11.1

CMD [ "/app/pkg/start.sh" ]
56 changes: 32 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Refer to the [Cloudron Docs](https://docs.cloudron.io/packaging/cli) for more in
Please refer to `docker-run.sh` file for some commands handy for you to test this setup.

## Logging in

Look for credentials in the file `<your-site-name>-credentials.txt` from the file manager.sd

## LDAP Connection [WIP]
Expand All @@ -37,73 +38,80 @@ LDAP Group sync or custom group mapping could also be possible, but I haven't tr
For now, look at the `/app/pkg/setup-ldap.sh` and make necessary changes. Run the command to add LDAP settings. The
script is configured to use your cloudron's LDAP addon.

- add : adds LDAP settings to the site
- disable: disables LDAP settings (required before deleting)
- delete: deletes the LDAP settings for the site
- `/app/pkg/setup-ldap.sh add` : adds LDAP settings to the site
- `/app/pkg/setup-ldap.sh disable`: disables LDAP settings (required before deleting)
- `/app/pkg/setup-ldap.sh delete`: deletes the LDAP settings for the site

## Installing Apps

You can install new frappe apps. To install the apps, simply follow these steps, and restart the app.
Also refer to the [Official Documentation](https://frappeframework.com/docs/v14/user/en/bench/bench-commands#add-apps)
You can install new frappe apps. To install the apps, simply follow these steps.

```shell
# Make sure you are in the /app/code/frappe-bench directory.
cd /app/code/frappe-bench
gosu cloudron bench get-app <app-name>
gosu cloudron bench install-app <app-name>
gosu cloudron bench restart

gosu cloudron bench get-app --branch <branch> <appname>
# EXAMPLE 1: install the hrms app
gosu cloudron bench get-app hrms
gosu cloudron bench install-app hrms
gosu cloudron bench restart

# Example: install the hrms app for HR Management
# EXAMPLE 2: install a specific version of the hrms
gosu cloudron bench get-app --branch v1.0.0 hrms
gosu cloudron bench install-app hrms
gosu cloudron bench restart

# EXAMPLE 3: install a specific version of the frappedesk
gosu cloudron bench get-app --branch develop frappedesk
gosu cloudron bench install-app frappedesk
gosu cloudron bench restart

```

Note: Restart the app using the Restart button on top of the terminal, or simply run `supervisorctl restart all` to
ensure the apps are properly configured.
Also refer to the [Official Documentation](https://frappeframework.com/docs/v14/user/en/bench/bench-commands#add-apps)

## Updating ErpNext
## Updating Apps

### Important Notes

- **MAKE SURE TO BACKUP BEFORE TRYING TO UPDATE. IF THE UPDATE FAILS, THE APP MAY STOP RESPONDING, AND YOU MAY LOSE
DATA.**

- **Run the `git` and `bench` commands with `gosu cloudron` as the user `cloudron` instead of the root user.**'

- **Put the app in Recovery Mode from the dashboard before running updates and turn it off later.**
- MAKE SURE TO TAKE A BACKUP USING CLOUDRON BEFORE TRYING TO UPDATE.
- IF THE UPDATE FAILS, THE APP MAY STOP RESPONDING, AND YOU MAY LOSE DATA.

```shell
# Put the app in maintenance mode
gosu cloudron bench set-maintenance-mode on

# Run the update commands

# Turn off maintenance mode
gosu cloudron bench set-maintenance-mode off
```

### 1. Update with Cloudron CLI

You can update this package normally by pulling the latest version of this repository, then running `cloudron update`
You can update this package normally by pulling the latest version of this repository, then running `cloudron build`
and `cloudron update --app your-app-domain`. This is the safest way to update the app.

**After updating, make sure to run `gosu cloudron bench migrate` from the terminal while the app is running.**

### 2. Automatic updates with bench

Set the application to Recovery Mode. Then update normally. Refer to
the [Official Documentation](https://frappeframework.com/docs/v14/user/en/production-setup#updating)
You don't need to update this cloudron package. You can update Frappe, ErpNext and other apps from the cloudron
dashboard itself.

```shell
# switch frappe and erpnext app version to version-14
# switch frappe and erpnext app branch to version-14 or any other branch.
gosu cloudron bench switch-to-branch version-14 frappe erpnext

#if you have more apps, switch to the respective versions for those apps as well
# gosu cloudron bench switch-to-branch version-xxx app1 app2 app3 ...

# update frappe and all apps, then run migration
gosu cloudron bench update
# gosu cloudron bench switch-to-branch v1.0.0 hrms
# gosu cloudron bench switch-to-branch develop frappedesk
# etc...

# update frappe and all apps, then run migration. Note: backups are handled by cloudron (if you have set it up)
gosu cloudron bench update --reset --no-backup
```

You can also run each steps one at a time as needed.
Expand Down
6 changes: 5 additions & 1 deletion mysql_custom.cnf
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@ innodb_use_native_aio=0
character-set-client-handshake=FALSE
character-set-server=utf8mb4
collation-server=utf8mb4_unicode_ci
max_allowed_packet=107374182
max_allowed_packet=107374182

# these settings did not work while put in config, so they should be passed as runtime parameters to mysqld_safe
# --character-set-server
# --collation-server
Loading

0 comments on commit f4b2e2d

Please sign in to comment.