mirror of
https://github.com/frappe/frappe_docker.git
synced 2026-06-17 13:55:08 +00:00
Merge 70d0d21f4f into 6e8bb9a142
This commit is contained in:
commit
95e5ef5ed8
8 changed files with 242 additions and 103 deletions
24
.travis.yml
24
.travis.yml
|
|
@ -1,21 +1,28 @@
|
|||
sudo: required
|
||||
|
||||
language: python
|
||||
|
||||
python:
|
||||
- "2.7"
|
||||
|
||||
env:
|
||||
- DOCKER_COMPOSE_VERSION: 1.8.0
|
||||
|
||||
services:
|
||||
- docker
|
||||
|
||||
before_install:
|
||||
- sudo rm /usr/local/bin/docker-compose
|
||||
- curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose
|
||||
- chmod +x docker-compose
|
||||
- sudo mv docker-compose /usr/local/bin
|
||||
- chmod ugo+x ./dbench
|
||||
- chmod ugo+x ./curl-travis
|
||||
|
||||
install:
|
||||
- docker-compose build
|
||||
- docker-compose up -d
|
||||
- docker exec -it -u root frappe bash -c "cd /home/frappe && chown -R frappe:frappe ./*"
|
||||
- docker exec -i frappe bash -c "cd .. && bench init frappe-bench --skip-bench-mkdir --skip-redis-config-generation && cd frappe-bench"
|
||||
- docker exec -i frappe bash -c "mv Procfile_docker Procfile && mv sites/common_site_config_docker.json sites/common_site_config.json"
|
||||
- docker exec -i frappe bash -c "bench new-site site1.local"
|
||||
- docker exec -i -u root frappe bash -c "echo 127.0.0.1 site1.local >> /etc/hosts"
|
||||
- sudo su -c 'echo 127.0.0.1 site1.local >> /etc/hosts'
|
||||
- ./dbench --setup -u
|
||||
- ./dbench --init
|
||||
- ./dbench --start
|
||||
- pip install --upgrade virtualenv
|
||||
- virtualenv -p python3 testenv
|
||||
- source testenv/bin/activate
|
||||
|
|
@ -29,3 +36,4 @@ script:
|
|||
- docker-compose ps | grep -i mariadb
|
||||
- python test.py
|
||||
- docker-compose stop
|
||||
- ./curl-travis
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
|
||||
|
||||
#bench Dockerfile
|
||||
|
||||
FROM ubuntu:16.04
|
||||
MAINTAINER frappé
|
||||
LABEL Author frappé
|
||||
|
||||
USER root
|
||||
RUN apt-get update
|
||||
|
|
@ -18,6 +18,7 @@ RUN apt-get install -y curl
|
|||
RUN apt-get install -y rlwrap
|
||||
RUN apt-get install redis-tools
|
||||
RUN apt-get install -y nano
|
||||
RUN apt-get install -y cron
|
||||
|
||||
# Generate locale C.UTF-8 for mariadb and general locale data
|
||||
ENV LANG C.UTF-8
|
||||
|
|
@ -37,7 +38,8 @@ USER root
|
|||
RUN pip install -e bench-repo
|
||||
RUN apt-get install -y libmysqlclient-dev mariadb-client mariadb-common
|
||||
RUN npm install -g yarn
|
||||
RUN chown -R frappe:frappe /home/frappe/*
|
||||
RUN chown -R frappe:frappe /home/frappe
|
||||
ENV PATH /home/frappe/.local/bin:$PATH
|
||||
|
||||
USER frappe
|
||||
WORKDIR /home/frappe/frappe-bench
|
||||
|
|
|
|||
78
README.md
78
README.md
|
|
@ -1,5 +1,8 @@
|
|||
# frappe_docker
|
||||
[](https://travis-ci.org/frappe/frappe_docker)
|
||||
|
||||
| `latest` | `develop` | `arm` |
|
||||
|:--------:|:---------:|:-----:|
|
||||
| [](https://travis-ci.org/chabad360/frappe_docker) | [](https://travis-ci.org/chabad360/frappe_docker) | [](https://travis-ci.org/chabad360/frappe_docker) |
|
||||
|
||||
- [Docker](https://docker.com/) is an open source project to pack, ship and run any Linux application in a lighter weight, faster container than a traditional virtual machine.
|
||||
|
||||
|
|
@ -19,9 +22,9 @@ These instructions will get you a copy of the project up and running on your loc
|
|||
|
||||
### Container Configuration
|
||||
|
||||
#### ports:
|
||||
#### Ports
|
||||
|
||||
```
|
||||
```bash
|
||||
ports:
|
||||
- "3307:3307" mariadb-port
|
||||
- "8000:8000" webserver-port
|
||||
|
|
@ -32,11 +35,11 @@ ports:
|
|||
- "6787:6787" file-watcher-port
|
||||
```
|
||||
|
||||
Expose port 3307 inside the container on port 3307 on ALL local host interfaces. In order to bind to only one interface, you may specify the host's IP address as `([<host_interface>:[host_port]])|(<host_port>):<container_port>[/udp]` as defined in the [docker port binding documentation](http://docs.docker.com/userguide/dockerlinks/). The port 3307 of the mariadb container and port 8000 of the frappe container is exposed to the host machine and other containers.
|
||||
Expose port `3307` inside the container on port `3307` on ALL local host interfaces. In order to bind to only one interface, you may specify the host's IP address as `([<host_interface>:[host_port]])|(<host_port>):<container_port>[/udp]` as defined in the [docker port binding documentation](http://docs.docker.com/userguide/dockerlinks/). The port `3307` of the mariadb container and port `8000` of the frappe container is exposed to the host machine and other containers.
|
||||
|
||||
#### volumes:
|
||||
#### Volumes
|
||||
|
||||
```
|
||||
```bash
|
||||
volumes:
|
||||
- ./frappe-bench:/home/frappe/frappe-bench
|
||||
- ./conf/mariadb-conf.d:/etc/mysql/conf.d
|
||||
|
|
@ -44,11 +47,12 @@ volumes:
|
|||
- ./redis-conf/redis_queue.conf:/etc/conf.d/redis.conf
|
||||
- ./redis-conf/redis_cache.conf:/etc/conf.d/redis.conf
|
||||
```
|
||||
|
||||
Exposes a directory inside the host to the container.
|
||||
|
||||
#### links:
|
||||
#### Links
|
||||
|
||||
```
|
||||
```bash
|
||||
links:
|
||||
- redis-cache
|
||||
- redis-queue
|
||||
|
|
@ -58,20 +62,21 @@ links:
|
|||
|
||||
Links allow you to define extra aliases by which a service is reachable from another service.
|
||||
|
||||
#### depends_on:
|
||||
#### Depends_on
|
||||
|
||||
```
|
||||
```bash
|
||||
depends_on:
|
||||
- mariadb
|
||||
- redis-cache
|
||||
- redis-queue
|
||||
- redis-socketio
|
||||
```
|
||||
|
||||
Express dependency between services, which has two effects:
|
||||
|
||||
1. docker-compose up will start services in dependency order. In the following example, mariadb and redis will be started before frappe.
|
||||
1. `docker-compose up -d` will start services in dependency order. In the following example, MariaDB and Redis will be started before Frappe.
|
||||
|
||||
2. docker-compose up SERVICE will automatically include SERVICE’s dependencies. In the following example, docker-compose up docker_frappe will also create and start mariadb and redis.
|
||||
2. `docker-compose up SERVICE` will automatically include `SERVICE`’s dependencies. In the following example, `docker-compose up -d frappe` will also create and start MariaDB and Redis.
|
||||
|
||||
### Installation
|
||||
|
||||
|
|
@ -81,54 +86,49 @@ Express dependency between services, which has two effects:
|
|||
|
||||
- Install [Docker Compose](https://docs.docker.com/compose/install/) (only for Linux users). Docker for Mac, Docker for Windows, and Docker Toolbox include Docker Compose
|
||||
|
||||
#### 2. Build the container and install bench
|
||||
#### 2. Build the container
|
||||
|
||||
* Clone this repo and change your working directory to frappe_docker
|
||||
|
||||
git clone --depth 1 https://github.com/frappe/frappe_docker.git
|
||||
cd frappe_docker
|
||||
- Clone this repo and change your working directory to frappe_docker
|
||||
|
||||
* Build the container and install bench inside the container.
|
||||
git clone --depth 1 https://github.com/chabad360/frappe_docker.git
|
||||
cd frappe_docker
|
||||
|
||||
1.Build the 5 linked containers frappe, mariadb, redis-cache, redis-queue and redis-socketio using this command. Make sure your current working directory is frappe_docker which contains the docker-compose.yml and Dockerfile.
|
||||
It creates a user, frappe inside the frappe container, whose working directory is /home/frappe. It also clones
|
||||
the bench-repo from [here](https://github.com/frappe/bench)
|
||||
- Build the container and install bench inside the container.
|
||||
|
||||
docker-compose up -d
|
||||
1. Build and start the 5 linked containers frappe, mariadb, redis-cache, redis-queue and redis-socketio using this command.
|
||||
|
||||
Note: Please do not remove the bench-repo directory the above commands will create
|
||||
./dbench --setup -u
|
||||
|
||||
Make sure your current working directory is frappe_docker which contains the docker-compose.yml and Dockerfile.
|
||||
It creates a user, frappe inside the frappe container, whose working directory is /home/frappe. It also clones the bench-repo from [here](https://github.com/frappe/bench)
|
||||
|
||||
Note: Please do not remove the bench-repo directory the above commands will create
|
||||
|
||||
#### Basic Usage
|
||||
##### Make sure your current directory is frappe_docker
|
||||
1. First time setup
|
||||
|
||||
./dbench init
|
||||
#### 3. Install and Start Bench
|
||||
|
||||
2. Command to start all the containers
|
||||
1. First time setup
|
||||
|
||||
docker-compose start
|
||||
./dbench --init
|
||||
|
||||
3. Command to be executed everytime after starting your containers
|
||||
2. Command to start all the containers
|
||||
|
||||
./dbench -s
|
||||
./dbench --start
|
||||
|
||||
4. Command to enter your container
|
||||
3. Command to enter your container
|
||||
|
||||
docker exec -it frappe bash
|
||||
./dbench
|
||||
|
||||
5. All bench commands can also be directly run from the host machine by using dbench. For instance ```bench start``` can be executed by running ```./dbench -c start```. Just preface the option with <b>./dbench -c</b>. For more information on dbench run the command ```./dbench -h```.
|
||||
- All bench commands can also be directly run from the host machine by using `dbench`. For instance `bench start` can be executed by running `./dbench -c start`. Just preface the option with `./dbench -c`. For more information on `dbench` run the command `./dbench -h`.
|
||||
|
||||
For more info on how to build this docker container refer to this [Wiki](https://github.com/frappe/frappe_docker/wiki/Hitchhiker's-guide-to-building-this-frappe_docker-image)
|
||||
For more info on how to build this docker container refer to this [Wiki](https://github.com/chabad360/frappe_docker/wiki/First-Timers-Manual)
|
||||
|
||||
To login to Frappe / ERPNext, open your browser and go to `[your-external-ip]:8000`, probably `localhost:8000`
|
||||
To login to Frappe / ERPNext, open your browser and go to `[your-external-ip]:8000`, or `localhost:8000`
|
||||
|
||||
The default username is "Administrator" and password is what you set when you created the new site. The default admin password is set in common_site_config.json, and is set to 'admin' in this docker image.
|
||||
The default username is `Administrator` and password is what you set when you created the new site. The default admin password is set in `common_site_config.json`, and is set to `admin` in this docker image.
|
||||
|
||||
## Built With
|
||||
|
||||
* [Docker](https://www.docker.com/)
|
||||
- [Docker](https://www.docker.com/)
|
||||
|
||||
## Contributing
|
||||
|
||||
|
|
|
|||
|
|
@ -21,9 +21,9 @@ bind-address = 0.0.0.0
|
|||
|
||||
|
||||
[mysqld]
|
||||
innodb-file-format=barracuda
|
||||
innodb-file-per-table=1
|
||||
innodb-large-prefix=1
|
||||
#innodb-file-format=barracuda
|
||||
#innodb-file-per-table=1
|
||||
#innodb-large-prefix=1
|
||||
character-set-client-handshake = FALSE
|
||||
character-set-server = utf8mb4
|
||||
collation-server = utf8mb4_unicode_ci
|
||||
|
|
|
|||
3
curl-travis
Normal file
3
curl-travis
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
#!/bin/bash
|
||||
|
||||
curl -H "Content-Type: application/json" --data '{"docker_tag": "latest"}' -X POST https://registry.hub.docker.com/u/chabad360/frappe/trigger/$hubkey/
|
||||
222
dbench
Executable file → Normal file
222
dbench
Executable file → Normal file
|
|
@ -1,57 +1,183 @@
|
|||
#!/bin/bash
|
||||
|
||||
display_usage() {
|
||||
echo "$(basename "$0") [-h] [-c \"<command to be executed inside container>\"]"
|
||||
function usage {
|
||||
echo "Usage: $(basename "$0") [ --setup [-u] | --init [-m -e -d] [sitename] | --start [-b] | -h (--help) | -d (--developer) [sitename] | -a (--add) | -c \"Command to be sent to Frappe Bench on Docker\""
|
||||
echo ''
|
||||
echo 'where:'
|
||||
echo ' -h show this help text'
|
||||
echo ' -c execute a command inside docker using docker exec'
|
||||
echo ' -s adds site-names to /etc/hosts file in the container to facilitate multisite access'
|
||||
echo ' init initializes frappe-bench adds a new-site bench-manager.local and installs the bench_manager app
|
||||
app onto it'
|
||||
echo ' dbench loads up container'
|
||||
echo ' -c "command" send a command to bench in the container'
|
||||
echo ' -h | --help show this help text'
|
||||
echo ' -d | --developer [sitename] enables developer mode for "sitename" (if not specified, it will default to site1.local)'
|
||||
echo ' -a | --add adds site-names to /etc/hosts file in the container to facilitate multisite access'
|
||||
echo ' --setup [-u] builds docker containers, NOTE: assumes you have docker installed'
|
||||
echo ' -u start up docker containers as well'
|
||||
echo ' --init [-m -e -d] [sitename] initializes frappe-bench in docker and adds a site "sitename" (if not specified, it will default to site1.local)'
|
||||
echo ' -e initializes frappe-bench and installs erpnext'
|
||||
echo ' --start [-b] starts frappe docker'
|
||||
echo ' -b starts bench as well'
|
||||
}
|
||||
|
||||
if [[ $# -eq 0 ]]; then
|
||||
docker exec -it frappe bash
|
||||
|
||||
elif [ $1 == 'init' ]
|
||||
then
|
||||
function frappe_installer {
|
||||
echo "starting frappe_docker setup"
|
||||
docker exec -i -u root frappe bash -c "cd /home/frappe && chown -R frappe:frappe ./*"
|
||||
docker exec -it frappe bash -c "cd .. && bench init frappe-bench --ignore-exist --skip-redis-config-generation && cd frappe-bench"
|
||||
docker exec -it frappe bash -c "mv Procfile_docker Procfile && mv sites/common_site_config_docker.json sites/common_site_config.json"
|
||||
docker exec -it -u root frappe bash -c "apt-get install vim && apt-get install sudo && usermod -aG sudo frappe && printf '# User rules for frappe\nfrappe ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers.d/frappe"
|
||||
docker exec -it frappe bash -c "bench set-mariadb-host mariadb"
|
||||
docker exec -it frappe bash -c "bench new-site site1.local"
|
||||
docker exec -it frappe bash -c "bench get-app erpnext"
|
||||
docker exec -it frappe bash -c "bench --site site1.local install-app erpnext"
|
||||
docker exec -i frappe bash -c "cd .. && bench init frappe-bench --ignore-exist --skip-redis-config-generation && cd frappe-bench"
|
||||
docker exec -i frappe bash -c "mv Procfile_docker Procfile && mv sites/common_site_config_docker.json sites/common_site_config.json"
|
||||
echo "frappe-bench folder setup"
|
||||
docker exec -i -u root frappe bash -c "apt-get install vim -y && apt-get install sudo -y && usermod -aG sudo frappe && printf '# User rules for frappe\nfrappe ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers.d/frappe"
|
||||
echo "adding $1"
|
||||
docker exec -i frappe bash -c "bench new-site $1"
|
||||
docker exec -i -u root frappe bash -c "echo 127.0.0.1 $1 >> /etc/hosts"
|
||||
sudo su -c 'echo 127.0.0.1 $1 >> /etc/hosts'
|
||||
echo "$1 added"
|
||||
}
|
||||
|
||||
else
|
||||
while getopts ':hsc:' option; do
|
||||
case "$option" in
|
||||
h)
|
||||
display_usage
|
||||
exit
|
||||
;;
|
||||
c)
|
||||
docker exec -it frappe bash -c "bench $OPTARG"
|
||||
;;
|
||||
s)
|
||||
a=$(cd frappe-bench && ls sites/*/site_config.json | grep -o '/.\+/')
|
||||
a="${a//$'\n'/ }"
|
||||
a=$(echo $a | tr -d / )
|
||||
result="127.0.0.1 ${a}"
|
||||
echo $result
|
||||
docker exec -u root -i frappe bash -c "echo ${result} | tee --append /etc/hosts"
|
||||
docker exec -itu root frappe bash -c "printf '# User rules for frappe\nfrappe ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers.d/frappe"
|
||||
;;
|
||||
\?)
|
||||
echo "Invalid option: -$OPTARG" >&2
|
||||
exit 1
|
||||
;;
|
||||
:)
|
||||
echo "Option -$OPTARG requires an argument." >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
add=0
|
||||
setup=0
|
||||
up=0
|
||||
start=0
|
||||
init=0
|
||||
dev=0
|
||||
erp=0
|
||||
mgr=0
|
||||
site=0
|
||||
bench=0
|
||||
cmd=0
|
||||
|
||||
positional=()
|
||||
|
||||
if [ $# == 0 ]; then
|
||||
docker exec -it frappe bash
|
||||
exit 0
|
||||
fi
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
key="$1"
|
||||
|
||||
case "$key" in
|
||||
-h | --help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
-a | --add)
|
||||
add=1
|
||||
;;
|
||||
-d | --developer)
|
||||
dev=1
|
||||
;;
|
||||
-c)
|
||||
cmd=1
|
||||
;;
|
||||
-e)
|
||||
erp=1
|
||||
;;
|
||||
-u)
|
||||
up=1
|
||||
;;
|
||||
-m)
|
||||
mgr=1
|
||||
;;
|
||||
-b)
|
||||
bench=1
|
||||
;;
|
||||
--setup)
|
||||
setup=1
|
||||
;;
|
||||
--init)
|
||||
init=1
|
||||
;;
|
||||
--start)
|
||||
start=1
|
||||
;;
|
||||
*)
|
||||
positional+=("$key")
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
set -- "${positional[@]}"
|
||||
|
||||
site="$1"
|
||||
if [ -z "$1" ]; then
|
||||
site="site1.local"
|
||||
fi
|
||||
|
||||
|
||||
if [ $setup == 1 ]; then
|
||||
docker-compose build
|
||||
if [ $up == 1 ]; then
|
||||
docker-compose up -d
|
||||
else
|
||||
docker-compose up
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ $init == 1 ]; then
|
||||
|
||||
frappe_installer "$site"
|
||||
|
||||
if [ $mgr == 1 ]; then
|
||||
echo "installing bench manager"
|
||||
docker exec -it frappe bash -c "bench setup manager"
|
||||
fi
|
||||
|
||||
if [ $erp == 1 ]; then
|
||||
echo "installing erpnext"
|
||||
docker exec -i frappe bash -c "bench get-app erpnext"
|
||||
docker exec -i frappe bash -c "bench --site $site install-app erpnext"
|
||||
docker exec -i -u root frappe bash -c "bench --site $site set-config \"developer_mode\" 1 && bench clear-cache"
|
||||
echo "finished"
|
||||
fi
|
||||
|
||||
if [ $dev == 1 ]; then
|
||||
docker exec -it -u root frappe bash -c "bench --site $site set-config \"developer_mode\" 1 && bench clear-cache"
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ $dev == 1 ]; then
|
||||
if [ "$site" == 0 ]; then
|
||||
site="site1.local"
|
||||
fi
|
||||
docker exec -it -u root frappe bash -c "bench --site $site set-config \"developer_mode\" 1 && bench clear-cache"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ $start == 1 ]; then
|
||||
docker-compose start
|
||||
./dbench -a
|
||||
if [ $bench == 1 ]; then
|
||||
docker exec -it frappe bash -c "bench start"
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ $dev == 1 ]; then
|
||||
docker exec -it -u root frappe bash -c "bench --site $site set-config \"developer_mode\" 1 && bench clear-cache"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ $cmd == 1 ]; then
|
||||
docker exec -it frappe bash -c "bench $*"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ $add == 1 ]; then
|
||||
a=$(docker exec -i frappe bash -c "cd ~/frappe-bench && ls sites/*/site_config.json" | grep -o '/.\+/')
|
||||
a="${a//$'\n'/ }"
|
||||
a=$(echo "$a" | tr -d / )
|
||||
result="127.0.0.1 ${a}"
|
||||
echo "$result"
|
||||
docker exec -u root -i frappe bash -c "echo ${result} | tee --append /etc/hosts"
|
||||
docker exec -itu root frappe bash -c "printf '# User rules for frappe\nfrappe ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers.d/frappe"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if "$*"; then
|
||||
echo "Incorrect option $*, please make sure you are entering the correct commands"
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
version: '2'
|
||||
services:
|
||||
mariadb:
|
||||
image: "mariadb"
|
||||
image: "mariadb:latest"
|
||||
environment:
|
||||
- MYSQL_ROOT_PASSWORD=123
|
||||
- MYSQL_USER=root
|
||||
|
|
|
|||
2
test.py
2
test.py
|
|
@ -13,7 +13,7 @@ def print_out(val,delay):
|
|||
elif val == 2:
|
||||
try:
|
||||
global r
|
||||
r = requests.get("http://site1.local:8000")
|
||||
r = requests.get("http://localhost:8000")
|
||||
print(r)
|
||||
except requests.exceptions.ConnectionError as e:
|
||||
print(e)
|
||||
|
|
|
|||
Loading…
Reference in a new issue