2
0
mirror of https://github.com/frappe/frappe_docker.git synced 2024-09-20 11:09:01 +00:00

Merge pull request #194 from frappe/develop

ERPNext v12.7.0 and Frappe v12.5.0
This commit is contained in:
Revant Nandgaonkar 2020-04-17 13:00:54 +05:30 committed by GitHub
commit c54d29fd62
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 132 additions and 13 deletions

34
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View File

@ -0,0 +1,34 @@
---
name: Bug report
about: Report a bug encountered while using the Frappe_docker
labels: bug
---
<!--
Welcome to the frappe_docker issue tracker! Before creating an issue, please heed the following:
1. Is your issue relevant to the frappe_docker or the main Frappe framework? https://github.com/frappe/frappe . if It's the latter, publish the issue there.
2. Use the search function before creating a new issue. Duplicates will be closed and directed to the original discussion.
3. When making a bug report, make sure you provide all the required information. The easier it is for maintainers to reproduce, the faster it'll be fixed.
4. If you think you know what the reason for the bug is, share it with us. Maybe put in a PR 😉
-->
## Description of the issue
## Context information (for bug reports)
## Steps to reproduce the issue
1.
2.
3.
### Observed result
### Expected result
### Stacktrace / full error message if available
```
(paste here)
```

View File

@ -0,0 +1,23 @@
---
name: Feature request
about: Suggest an idea to improve frappe_docker
labels: enhancement
---
<!--
Welcome to the Frappe Framework issue tracker! Before creating an issue, please heed the following:
1. Use the search function before creating a new issue. Duplicates will be closed and directed to the original discussion.
2. When making a feature request, make sure to be as verbose as possible. The better you convey your message, the greater the drive to make it happen.
-->
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.

View File

@ -0,0 +1,12 @@
---
name: Question about using Frappe/Frappe Apps
about: Ask how to do something
labels: question
---
<!--
Welcome to the frappe_docker issue tracker! Before creating an issue, please heed the following:
1. Use the search function before creating a new issue. Duplicates will be closed and directed to the original discussion.
2. Please write extensively, clearly and in detail.
-->

7
.github/PULL_REQUEST_TEMPLATE.md vendored Normal file
View File

@ -0,0 +1,7 @@
> Please provide enough information so that others can review your pull request:
<!-- You can skip this if you're fixing a typo or updating existing documentation -->
> Explain the **details** for making this change. What existing problem does the pull request solve?
<!-- Example: When "Adding a function to do X", explain why it is necessary to have a way to do X. -->

View File

@ -101,6 +101,7 @@ Make sure to replace `<project-name>` with the desired name you wish to set for
Notes: Notes:
- New site (first site) needs to be added after starting the services.
- The local deployment is for testing and REST API development purpose only - The local deployment is for testing and REST API development purpose only
- A complete development environment is available [here](Development/README.md) - A complete development environment is available [here](Development/README.md)
- The site names are limited to patterns matching \*.localhost by default - The site names are limited to patterns matching \*.localhost by default
@ -140,7 +141,11 @@ docker-compose \
``` ```
Make sure to replace `<project-name>` with any desired name you wish to set for the project. Make sure to replace `<project-name>` with any desired name you wish to set for the project.
Note: use `docker-compose-frappe.yml` in case you need only Frappe without ERPNext.
Notes:
- Use `docker-compose-frappe.yml` in case you need only Frappe without ERPNext.
- New site (first site) needs to be added after starting the services.
### Docker containers ### Docker containers
@ -204,7 +209,9 @@ Environment Variables needed:
- `SITE_NAME`: name of the new site to create. - `SITE_NAME`: name of the new site to create.
- `DB_ROOT_USER`: MariaDB Root user. - `DB_ROOT_USER`: MariaDB Root user.
- `MYSQL_ROOT_PASSWORD`: In case of the MariaDB docker container use the one set in `MYSQL_ROOT_PASSWORD` in previous steps. In case of a managed database use the appropriate password. - `MYSQL_ROOT_PASSWORD`: In case of the MariaDB docker container use the one set in `MYSQL_ROOT_PASSWORD` in previous steps. In case of a managed database use the appropriate password.
- `MYSQL_ROOT_PASSWORD_FILE` - When the MariaDB root password is stored using docker secrets.
- `ADMIN_PASSWORD`: set the administrator password for the new site. - `ADMIN_PASSWORD`: set the administrator password for the new site.
- `ADMIN_PASSWORD_FILE`: set the administrator password for the new site using docker secrets.
- `INSTALL_APPS=erpnext`: available only in erpnext-worker and erpnext containers (or other containers with custom apps). Installs ERPNext (and/or the specified apps, comma-delinieated) on this new site. - `INSTALL_APPS=erpnext`: available only in erpnext-worker and erpnext containers (or other containers with custom apps). Installs ERPNext (and/or the specified apps, comma-delinieated) on this new site.
- `FORCE=1`: optional variable which force installation of the same site. - `FORCE=1`: optional variable which force installation of the same site.
@ -214,6 +221,9 @@ Environment Variables
- `SITES` is list of sites separated by `:` colon to migrate. e.g. `SITES=site1.domain.com` or `SITES=site1.domain.com:site2.domain.com` By default all sites in bench will be backed up. - `SITES` is list of sites separated by `:` colon to migrate. e.g. `SITES=site1.domain.com` or `SITES=site1.domain.com:site2.domain.com` By default all sites in bench will be backed up.
- `WITH_FILES` if set to 1, it will backup user-uploaded files. - `WITH_FILES` if set to 1, it will backup user-uploaded files.
- By default `backup` takes mariadb dump and gzips it. Example file, `20200325_221230-test_localhost-database.sql.gz`
- If `WITH_FILES` is set then it will also backup public and private files of each site as uncompressed tarball. Example files, `20200325_221230-test_localhost-files.tar` and `20200325_221230-test_localhost-private-files.tar`
- All the files generated by backup are placed at volume location `sites/{site-name}/private/backups/*`
```sh ```sh
docker exec -it \ docker exec -it \
@ -285,7 +295,7 @@ docker exec -it \
Environment Variables Environment Variables
- `MYSQL_ROOT_PASSWORD`, Required to restore mariadb backups. - `MYSQL_ROOT_PASSWORD` or `MYSQL_ROOT_PASSWORD_FILE`(when using docker secrets), Required to restore mariadb backups.
- `BUCKET_NAME`, Required to set bucket created on S3 compatible storage. - `BUCKET_NAME`, Required to set bucket created on S3 compatible storage.
- `ACCESS_KEY_ID`, Required to set access key. - `ACCESS_KEY_ID`, Required to set access key.
- `SECRET_ACCESS_KEY`, Required to set secret access key. - `SECRET_ACCESS_KEY`, Required to set secret access key.

View File

@ -3,10 +3,32 @@ import os, frappe, json
from frappe.commands.site import _new_site from frappe.commands.site import _new_site
from check_connection import get_config, get_site_config from check_connection import get_config, get_site_config
def get_password(env_var, default=None):
return os.environ.get(env_var) or _get_password_from_secret(f"{env_var}_FILE") or default
def _get_password_from_secret(env_var):
"""Fetches the secret value from the docker secret file
usually located inside /run/secrets/
Arguments:
env_var {str} -- Name of the environment variable
containing the path to the secret file.
Returns:
[str] -- Secret value
"""
passwd = None
secret_file_path = os.environ.get(env_var)
if secret_file_path:
with open(secret_file_path) as secret_file:
passwd = secret_file.read().strip()
return passwd
def main(): def main():
site_name = os.environ.get("SITE_NAME", 'site1.localhost') site_name = os.environ.get("SITE_NAME", 'site1.localhost')
mariadb_root_username = os.environ.get("DB_ROOT_USER", 'root') mariadb_root_username = os.environ.get("DB_ROOT_USER", 'root')
mariadb_root_password = os.environ.get("MYSQL_ROOT_PASSWORD", 'admin') mariadb_root_password = get_password("MYSQL_ROOT_PASSWORD", 'admin')
force = True if os.environ.get("FORCE", None) else False force = True if os.environ.get("FORCE", None) else False
install_apps = os.environ.get("INSTALL_APPS", None) install_apps = os.environ.get("INSTALL_APPS", None)
install_apps = install_apps.split(',') if install_apps else [] install_apps = install_apps.split(',') if install_apps else []
@ -17,7 +39,7 @@ def main():
site_name, site_name,
mariadb_root_username=mariadb_root_username, mariadb_root_username=mariadb_root_username,
mariadb_root_password=mariadb_root_password, mariadb_root_password=mariadb_root_password,
admin_password=os.environ.get("ADMIN_PASSWORD", 'admin'), admin_password=get_password("ADMIN_PASSWORD", 'admin'),
verbose=True, verbose=True,
install_apps=install_apps, install_apps=install_apps,
source_sql=None, source_sql=None,

View File

@ -5,6 +5,7 @@ import hashlib
import frappe import frappe
import boto3 import boto3
from new import get_password
from push_backup import DATE_FORMAT, check_environment_variables from push_backup import DATE_FORMAT, check_environment_variables
from frappe.utils import get_sites, random_string from frappe.utils import get_sites, random_string
from frappe.commands.site import _new_site from frappe.commands.site import _new_site
@ -38,7 +39,7 @@ def decompress_db(files_base, site):
os.system(command) os.system(command)
def restore_database(files_base, site): def restore_database(files_base, site):
db_root_password = os.environ.get('MYSQL_ROOT_PASSWORD') db_root_password = get_password('MYSQL_ROOT_PASSWORD')
if not db_root_password: if not db_root_password:
print('Variable MYSQL_ROOT_PASSWORD not set') print('Variable MYSQL_ROOT_PASSWORD not set')
exit(1) exit(1)
@ -158,7 +159,7 @@ def main():
restore_private_files(files_base) restore_private_files(files_base)
restore_files(files_base) restore_files(files_base)
else: else:
mariadb_root_password = os.environ.get('MYSQL_ROOT_PASSWORD') mariadb_root_password = get_password('MYSQL_ROOT_PASSWORD')
if not mariadb_root_password: if not mariadb_root_password:
print('Variable MYSQL_ROOT_PASSWORD not set') print('Variable MYSQL_ROOT_PASSWORD not set')
exit(1) exit(1)

View File

@ -29,9 +29,9 @@ server {
proxy_http_version 1.1; proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade; proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade"; proxy_set_header Connection "upgrade";
proxy_set_header X-Frappe-Site-Name $http_host; proxy_set_header X-Frappe-Site-Name $host;
proxy_set_header Origin $scheme://$http_host; proxy_set_header Origin $scheme://$http_host;
proxy_set_header Host $host; proxy_set_header Host $http_host;
proxy_pass http://socketio-server; proxy_pass http://socketio-server;
} }
@ -52,8 +52,8 @@ server {
location @webserver { location @webserver {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Frappe-Site-Name $http_host; proxy_set_header X-Frappe-Site-Name $host;
proxy_set_header Host $host; proxy_set_header Host $http_host;
proxy_set_header X-Use-X-Accel-Redirect True; proxy_set_header X-Use-X-Accel-Redirect True;
proxy_read_timeout 120; proxy_read_timeout 120;
proxy_redirect off; proxy_redirect off;

View File

@ -40,8 +40,8 @@ envsubst '${API_HOST}
echo "Waiting for frappe-python to be available on $FRAPPE_PY port $FRAPPE_PY_PORT" echo "Waiting for frappe-python to be available on $FRAPPE_PY port $FRAPPE_PY_PORT"
timeout 10 bash -c 'until printf "" 2>>/dev/null >>/dev/tcp/$0/$1; do sleep 1; done' $FRAPPE_PY $FRAPPE_PY_PORT timeout 10 bash -c 'until printf "" 2>>/dev/null >>/dev/tcp/$0/$1; do sleep 1; done' $FRAPPE_PY $FRAPPE_PY_PORT
echo "Frappe-python available on $FRAPPE_PY port $FRAPPE_PY_PORT" echo "Frappe-python available on $FRAPPE_PY port $FRAPPE_PY_PORT"
echo "Waiting for frappe-socketio to be available on $FRAPPE_PY port $FRAPPE_PY_PORT" echo "Waiting for frappe-socketio to be available on $FRAPPE_SOCKETIO port $SOCKETIO_PORT"
timeout 10 bash -c 'until printf "" 2>>/dev/null >>/dev/tcp/$0/$1; do sleep 1; done' $FRAPPE_SOCKETIO $SOCKETIO_PORT timeout 10 bash -c 'until printf "" 2>>/dev/null >>/dev/tcp/$0/$1; do sleep 1; done' $FRAPPE_SOCKETIO $SOCKETIO_PORT
echo "Frappe-socketio available on $FRAPPE_PY port $FRAPPE_PY_PORT" echo "Frappe-socketio available on $FRAPPE_SOCKETIO port $SOCKETIO_PORT"
exec "$@" exec "$@"

View File

@ -103,6 +103,16 @@ bench set-config developer_mode 1
bench clear-cache bench clear-cache
``` ```
### Start development
Execute following command from the `frappe-bench` directory.
```shell
bench start
```
Note: To start bench with debugger refer section for debugging.
### Fixing MariaDB issues after rebuilding the container ### Fixing MariaDB issues after rebuilding the container
The `bench new-site` command creates a user in MariaDB with container IP as host, for this reason after rebuilding the container there is a chance that you will not be able to access MariaDB correctly with the previous configuration The `bench new-site` command creates a user in MariaDB with container IP as host, for this reason after rebuilding the container there is a chance that you will not be able to access MariaDB correctly with the previous configuration