2017-07-20 07:21:33 +00:00
# frappe_docker
2017-10-09 04:08:54 +00:00
[![Build Status ](https://travis-ci.org/frappe/frappe_docker.svg?branch=develop )](https://travis-ci.org/frappe/frappe_docker)
2017-07-18 09:26:31 +00:00
2017-08-03 10:42:46 +00:00
- [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.
- Docker makes it much easier to deploy [frappe ](https://github.com/frappe/frappe ) on your servers.
2017-08-14 11:46:10 +00:00
- This container uses [bench ](https://github.com/frappe/bench ) to install frappe.
2017-07-18 09:26:31 +00:00
## Getting Started
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
### Prerequisites
2017-07-24 12:21:38 +00:00
[Docker ](https://www.docker.com/ )
2017-07-24 12:22:30 +00:00
2017-07-24 12:21:38 +00:00
[Docker Compose ](https://docs.docker.com/compose/overview/ )
2017-07-24 12:11:20 +00:00
2017-07-24 12:21:38 +00:00
### Container Configuration
#### ports:
```
ports:
2017-08-14 11:46:10 +00:00
- "3307:3307" mariadb-port
- "8000:8000" webserver-port
- "11000:11000" redis-cache
- "12000:12000" redis-queue
- "13000:13000" redis-socketio
- "9000:9000" socketio-port
- "6787:6787" file-watcher-port
2017-07-24 12:21:38 +00:00
```
2017-08-14 11:46:10 +00:00
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.
2017-07-24 12:21:38 +00:00
#### volumes:
```
volumes:
2017-08-03 10:42:46 +00:00
- ./frappe-bench:/home/frappe/frappe-bench
2017-07-24 12:21:38 +00:00
- ./conf/mariadb-conf.d:/etc/mysql/conf.d
2017-08-03 10:42:46 +00:00
- ./redis-conf/redis_socketio.conf:/etc/conf.d/redis.conf
- ./redis-conf/redis_queue.conf:/etc/conf.d/redis.conf
- ./redis-conf/redis_cache.conf:/etc/conf.d/redis.conf
2017-07-24 12:21:38 +00:00
```
2017-07-24 12:48:09 +00:00
Exposes a directory inside the host to the container.
2017-07-24 12:21:38 +00:00
#### links:
```
links:
2017-08-03 10:42:46 +00:00
- redis-cache
- redis-queue
- redis-socketio
2017-07-24 12:21:38 +00:00
- mariadb
```
2017-08-03 10:42:46 +00:00
Links allow you to define extra aliases by which a service is reachable from another service.
2017-07-24 12:21:38 +00:00
#### depends_on:
```
depends_on:
- mariadb
2017-08-03 10:42:46 +00:00
- redis-cache
- redis-queue
- redis-socketio
2017-07-24 12:21:38 +00:00
```
2017-07-24 12:22:30 +00:00
Express dependency between services, which has two effects:
2017-07-24 12:21:38 +00:00
2017-07-25 04:02:59 +00:00
1. docker-compose up will start services in dependency order. In the following example, mariadb and redis will be started before frappe.
2017-07-24 12:21:38 +00:00
2017-07-25 04:02:59 +00:00
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.
2017-07-18 09:26:31 +00:00
2017-07-24 12:48:09 +00:00
### Installation
2017-07-18 09:26:31 +00:00
2017-07-24 09:49:32 +00:00
#### 1. Installation Pre-requisites
2017-07-18 09:26:31 +00:00
2017-08-14 11:46:10 +00:00
- Install [Docker ](https://docs.docker.com/engine/installation ) Community Edition
2017-07-18 09:26:31 +00:00
2017-08-03 10:42:46 +00:00
- 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
2017-07-24 10:04:28 +00:00
2017-07-24 09:49:32 +00:00
#### 2. Build the container and install bench
2017-09-18 06:14:56 +00:00
* 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
2017-08-03 10:42:46 +00:00
* Build the container and install bench inside the container.
2017-08-14 11:46:10 +00:00
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.
2017-08-03 10:42:46 +00:00
It creates a user, frappe inside the frappe container, whose working directory is /home/frappe. It also clones
2017-07-24 11:11:51 +00:00
the bench-repo from [here ](https://github.com/frappe/bench )
2017-08-14 11:46:10 +00:00
2017-08-03 10:42:46 +00:00
docker-compose up -d
2017-07-24 10:09:04 +00:00
2017-07-24 11:22:21 +00:00
Note: Please do not remove the bench-repo directory the above commands will create
2017-08-14 11:46:10 +00:00
2017-07-24 09:49:32 +00:00
#### Basic Usage
2017-07-24 11:11:51 +00:00
1. Starting docker containers
2017-07-24 10:00:18 +00:00
This command can be used to start containers
2017-08-14 11:46:10 +00:00
2017-08-03 10:42:46 +00:00
docker-compose start
2017-07-24 09:49:32 +00:00
2017-07-24 11:11:51 +00:00
2. Accessing the frappe container via CLI
2017-07-24 10:00:18 +00:00
2017-08-31 09:13:51 +00:00
docker exec -i -u root frappe bash -c "cd /home/frappe & & chown -R frappe:frappe ./*"
2017-08-03 10:42:46 +00:00
docker exec -it frappe bash
2017-08-14 11:46:10 +00:00
2017-07-24 11:11:51 +00:00
3. Create a new bench
2017-07-24 09:49:32 +00:00
The init command will create a bench directory with frappe framework
installed. It will be setup for periodic backups and auto updates once
a day.
2017-08-31 09:13:51 +00:00
cd .. & & bench init frappe-bench --skip-bench-mkdir --skip-redis-config-generation & & cd frappe-bench
mv Procfile_docker Procfile & & mv sites/common_site_config_docker.json sites/common_site_config.json
2017-07-24 10:41:20 +00:00
2017-08-14 11:46:10 +00:00
4. Set the db host for bench (points bench to the mariadb container) since the 3 containers are linked
2017-07-24 10:41:20 +00:00
bench set-mariadb-host mariadb
2017-07-24 09:49:32 +00:00
2017-07-24 12:48:09 +00:00
5. Add a site (make sure your current path is /home/frappe/frappe-bench)
2017-07-24 09:49:32 +00:00
Frappe apps are run by frappe sites and you will have to create at least one
site. The new-site command allows you to do that.
bench new-site site1.local
2017-07-24 12:48:09 +00:00
6. Add apps (make sure your current path is /home/frappe/frappe-bench)
2017-07-24 09:49:32 +00:00
The get-app command gets remote frappe apps from a remote git repository and installs them. Example: [erpnext ](https://github.com/frappe/erpnext )
bench get-app erpnext https://github.com/frappe/erpnext
2017-07-24 12:48:09 +00:00
7. Install apps (make sure your current path is /home/frappe/frappe-bench)
2017-07-24 09:49:32 +00:00
To install an app on your new site, use the bench `install-app` command.
bench --site site1.local install-app erpnext
2017-07-24 12:48:09 +00:00
8. Start bench (make sure your current path is /home/frappe/frappe-bench)
2017-07-24 10:47:10 +00:00
To start using the bench, use the `bench start` command
bench start
2017-08-14 11:46:10 +00:00
2017-07-24 12:48:09 +00:00
9. Exiting the frappe container and stopping all the containers gracefully.
2017-08-14 11:46:10 +00:00
2017-07-24 10:47:10 +00:00
exit
2017-08-03 10:42:46 +00:00
docker-compose stop
2017-07-24 09:49:32 +00:00
2017-07-24 11:11:51 +00:00
10. Removing docker containers
2017-07-24 10:00:18 +00:00
2017-08-03 10:42:46 +00:00
docker-compose rm
2017-07-24 09:49:32 +00:00
2017-07-24 11:11:51 +00:00
11. Removing dangling volumes
2017-08-14 11:46:10 +00:00
2017-07-24 10:00:18 +00:00
The volume frappe on your local machine is shared by the host(your local machine) and the frappe container.
Please do not delete this volume from your local machine. Any changes made in this directory will reflect on both
the container and the host. The below command specifies how to remain dangling volumes which may be taking up
unecessary space on your host.
2017-08-14 11:46:10 +00:00
2017-08-03 10:42:46 +00:00
docker volume rm $(docker volume ls -f dangling=true -q)
2017-07-24 09:49:32 +00:00
To login to Frappe / ERPNext, open your browser and go to `[your-external-ip]:8000` , probably `localhost:8000`
2017-07-24 12:21:38 +00:00
The default username is "Administrator" and password is what you set when you created the new site.
2017-07-24 09:49:32 +00:00
2017-07-18 09:26:31 +00:00
## Built With
* [Docker ](https://www.docker.com/ )
## Contributing
2017-07-24 12:48:09 +00:00
Feel free to contribute to this project and make the container better
2017-07-18 09:26:31 +00:00
## License
This project is licensed under the MIT License - see the [LICENSE.md ](LICENSE.md ) file for details