mirror of
https://github.com/frappe/frappe_docker.git
synced 2026-06-21 23:35:09 +00:00
Merge pull request #6 from chabad360/develop
Merge in some random improvements
This commit is contained in:
commit
4a89f7f54b
8 changed files with 78 additions and 89 deletions
|
|
@ -2,6 +2,9 @@
|
||||||
|
|
||||||
conf/*
|
conf/*
|
||||||
.travis.yml
|
.travis.yml
|
||||||
test.py
|
test.sh
|
||||||
|
README.md
|
||||||
|
LICENSE.md
|
||||||
|
.gitignore
|
||||||
dbench
|
dbench
|
||||||
docker-*.yml
|
docker-*.yml
|
||||||
15
.travis.yml
15
.travis.yml
|
|
@ -1,9 +1,9 @@
|
||||||
language: python
|
dist: xenial
|
||||||
python:
|
|
||||||
- "2.7"
|
|
||||||
env:
|
env:
|
||||||
- DOCKER_COMPOSE_VERSION: 1.23.1
|
- DOCKER_COMPOSE_VERSION: 1.23.1
|
||||||
|
|
||||||
|
|
||||||
services:
|
services:
|
||||||
- docker
|
- docker
|
||||||
|
|
||||||
|
|
@ -19,14 +19,11 @@ before_install:
|
||||||
|
|
||||||
install:
|
install:
|
||||||
- chmod ugo+x ./dbench
|
- chmod ugo+x ./dbench
|
||||||
|
- chmod ugo+x ./test.sh
|
||||||
- ./dbench setup docker
|
- ./dbench setup docker
|
||||||
- ./dbench init frappe-bench
|
- ./dbench init frappe-bench
|
||||||
- ./dbench new-site site1.local
|
- ./dbench new-site site1.local
|
||||||
- ./dbench setup hosts
|
- ./dbench setup hosts
|
||||||
- pip install --upgrade virtualenv
|
|
||||||
- virtualenv -p python3 testenv
|
|
||||||
- source testenv/bin/activate
|
|
||||||
- pip install requests
|
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- docker-compose ps | grep -i frappe
|
- docker-compose ps | grep -i frappe
|
||||||
|
|
@ -34,5 +31,5 @@ script:
|
||||||
- docker-compose ps | grep -i redis-queue
|
- docker-compose ps | grep -i redis-queue
|
||||||
- docker-compose ps | grep -i redis-socketio
|
- docker-compose ps | grep -i redis-socketio
|
||||||
- docker-compose ps | grep -i mariadb
|
- docker-compose ps | grep -i mariadb
|
||||||
- python test.py
|
- ./test.sh
|
||||||
- docker-compose stop
|
- ./dbench setup docker stop
|
||||||
|
|
|
||||||
34
Dockerfile
34
Dockerfile
|
|
@ -1,21 +1,19 @@
|
||||||
# Frappe Bench Dockerfile
|
# Frappe Bench Dockerfile
|
||||||
|
|
||||||
FROM ubuntu:16.04
|
FROM debian:9.6-slim
|
||||||
LABEL author=frappé
|
LABEL author=frappé
|
||||||
|
|
||||||
# Set locale C.UTF-8 for mariadb and general locale data
|
# Set locale C.UTF-8 for mariadb and general locale data
|
||||||
ENV LANG C.UTF-8
|
ENV LANG C.UTF-8
|
||||||
|
|
||||||
# Install all neccesary packages
|
# Install all neccesary packages
|
||||||
RUN apt-get update && apt-get install -y --no-install-recommends iputils-ping git build-essential \
|
RUN apt-get update && apt-get install -y --no-install-suggests --no-install-recommends build-essential cron curl git iputils-ping libffi-dev \
|
||||||
libffi-dev libssl-dev libjpeg8-dev redis-tools software-properties-common libxext6 xfonts-75dpi xfonts-base \
|
liblcms2-dev libldap2-dev libmariadbclient-dev libsasl2-dev libssl-dev libtiff5-dev libwebp-dev mariadb-client \
|
||||||
python-dev libfreetype6-dev liblcms2-dev libwebp-dev python-tk libsasl2-dev libldap2-dev libtiff5-dev \
|
python-dev python-pip python-setuptools python-tk redis-tools rlwrap software-properties-common sudo tk8.6-dev \
|
||||||
python-setuptools tk8.6-dev wget libmysqlclient-dev mariadb-client curl rlwrap wkhtmltopdf python-pip sudo \
|
vim xfonts-75dpi xfonts-base wget wkhtmltopdf \
|
||||||
&& apt-get clean && rm -rf /var/lib/apt/lists/*
|
&& apt-get clean && rm -rf /var/lib/apt/lists/* \
|
||||||
RUN pip install --upgrade setuptools pip && rm -rf ~/.cache/pip
|
&& pip install --upgrade setuptools pip --no-cache \
|
||||||
|
&& curl https://deb.nodesource.com/node_10.x/pool/main/n/nodejs/nodejs_10.10.0-1nodesource1_amd64.deb > node.deb \
|
||||||
# Install Node.js and yarn
|
|
||||||
RUN curl https://deb.nodesource.com/node_10.x/pool/main/n/nodejs/nodejs_10.10.0-1nodesource1_amd64.deb > node.deb \
|
|
||||||
&& dpkg -i node.deb \
|
&& dpkg -i node.deb \
|
||||||
&& rm node.deb \
|
&& rm node.deb \
|
||||||
&& npm install -g yarn
|
&& npm install -g yarn
|
||||||
|
|
@ -24,21 +22,15 @@ RUN curl https://deb.nodesource.com/node_10.x/pool/main/n/nodejs/nodejs_10.10.0-
|
||||||
RUN useradd -ms /bin/bash -G sudo frappe \
|
RUN useradd -ms /bin/bash -G sudo frappe \
|
||||||
&& printf '# Sudo rules for frappe\nfrappe ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers.d/frappe
|
&& printf '# Sudo rules for frappe\nfrappe ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers.d/frappe
|
||||||
|
|
||||||
USER frappe
|
|
||||||
WORKDIR /home/frappe
|
WORKDIR /home/frappe
|
||||||
|
# Install bench
|
||||||
|
RUN pip install -e git+https://github.com/frappe/bench.git#egg=bench --no-cache
|
||||||
|
|
||||||
|
USER frappe
|
||||||
# Add some bench files
|
# Add some bench files
|
||||||
COPY --chown=frappe:frappe ./frappe-bench /home/frappe/frappe-bench
|
COPY --chown=frappe:frappe ./frappe-bench /home/frappe/frappe-bench
|
||||||
|
|
||||||
USER root
|
|
||||||
# Install bench
|
|
||||||
RUN pip install -e git+https://github.com/frappe/bench.git#egg=bench \
|
|
||||||
&& rm -rf ~/.cache/pip
|
|
||||||
|
|
||||||
USER frappe
|
|
||||||
WORKDIR /home/frappe/frappe-bench
|
WORKDIR /home/frappe/frappe-bench
|
||||||
|
|
||||||
EXPOSE 8000
|
EXPOSE 8000 9000 6787
|
||||||
EXPOSE 9000
|
|
||||||
EXPOSE 6787
|
|
||||||
|
|
||||||
VOLUME [ "/home/frappe/frappe-bench" ]
|
VOLUME [ "/home/frappe/frappe-bench" ]
|
||||||
49
README.md
49
README.md
|
|
@ -1,69 +1,72 @@
|
||||||
# Frappe on Docker
|
# Frappe on Docker
|
||||||
|
|
||||||
[](https://travis-ci.org/frappe/frappe_docker)
|
[](https://travis-ci.org/frappe/frappe_docker)
|
||||||
|
|
||||||
This is a repo designed to aide setting up frappe/ERPNext on docker.
|
This is a repo designed to aide setting up frappe/ERPNext on docker.
|
||||||
|
|
||||||
## Getting Started
|
## Getting Started
|
||||||
|
|
||||||
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. Unfortunetly, this container is not curently suited for a production enviorment.
|
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
|
||||||
|
|
||||||
### 1. Installation Pre-requisites
|
Unfortunetly, this container is not curently suited for a production enviorment (but we're working towards that goal!).
|
||||||
|
|
||||||
- Install [Docker](https://docs.docker.com/engine/installation) Community Edition
|
### Build the container and initialize the bench
|
||||||
|
|
||||||
- Install [Docker Compose](https://docs.docker.com/compose/install/) (only for Linux users. Docker for Mac, Docker for Windows, and Docker Toolbox already include Docker Compose).
|
**Note:** These instructions assume you have both [Docker](https://docs.docker.com/engine/installation) and [Docker Compose](https://docs.docker.com/compose/install/) installed on your system.
|
||||||
|
|
||||||
### 2. Build the container and initialize the bench
|
1. Clone this repo and change your working directory to it:
|
||||||
|
|
||||||
1. Clone this repo and change your working directory to frappe_docker
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git clone https://github.com/frappe/frappe_docker.git
|
git clone https://github.com/frappe/frappe_docker.git
|
||||||
cd frappe_docker
|
cd frappe_docker/
|
||||||
```
|
```
|
||||||
|
|
||||||
2. Build and start the container, and initialize the bench
|
2. Build and start the container, and initialize the bench:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
./dbench setup docker
|
./dbench setup docker
|
||||||
./dbench init
|
./dbench init
|
||||||
```
|
```
|
||||||
|
|
||||||
Note: This will take a while, as docker will now build the container.
|
**Note:** This will take a while, as docker will now build the container.
|
||||||
|
|
||||||
3. Add a new site and start frappe
|
3. Add a new site and start Frappe:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
./dbench new-site site1.local
|
./dbench new-site site1.local
|
||||||
./dbench setup hosts
|
./dbench setup hosts
|
||||||
./dbench start
|
./dbench start
|
||||||
```
|
```
|
||||||
4. To use frappe: Open your browser to `localhost:8000`.
|
|
||||||
Username: `Administrator` Password: `admin`
|
|
||||||
|
|
||||||
### Basic Usage*
|
4. Use Frappe:
|
||||||
|
Open your browser to `localhost:8000/login`. Then login using the username `Administrator` and the password `admin`.
|
||||||
|
|
||||||
- `./dbench`: Launches you into an interactive shell in the container as user frappe
|
### Basic Usage of `./dbench`
|
||||||
|
|
||||||
- `./dbench setup docker [ stop | down ]`: Starts and builds the docker containers using `docker-compose up -d`
|
**IMPORTANT: Always make sure that your current directory is the root directory of the repo (i.e. `frappe_docker/`)**
|
||||||
|
|
||||||
|
- `./dbench`: Launches you into an interactive shell in the container as the user `frappe`.
|
||||||
|
|
||||||
|
- `./dbench setup docker [ stop | down ]`: Starts and builds the docker containers using `docker-compose up -d`.
|
||||||
|
- `stop`: Stops the containers with `docker-compose stop`.
|
||||||
|
- `down`: Deletes the containers and the coresponding volumes with `docker-compose down`.
|
||||||
|
|
||||||
- `./dbench setup hosts`: Adds all sites to the containers hosts file.
|
- `./dbench setup hosts`: Adds all sites to the containers hosts file.
|
||||||
Do this after you've added a new site to avoid errors.
|
**Note:** Run this after you've added a new site to avoid errors.
|
||||||
|
|
||||||
- `./dbench -c frappe | root <command to run>`: Runs a command in the container, as the selected user
|
- `./dbench -c frappe | root <command to run>`: Runs a command in the container, as the selected user.
|
||||||
|
|
||||||
- `./dbench -h`: Shows this help message
|
- `./dbench -h`: Shows this help message.
|
||||||
|
|
||||||
- `./dbench <bench command>`: Runs a command in bench, (Running `./dbench new-site site1.local` will run in the conatiner as `bench new-site site1.local`)
|
- `./dbench <bench command>`: Runs a command in bench (i.e. Running `./dbench new-site site1.local`, will run `bench new-site site1.local` in the container).
|
||||||
|
|
||||||
*Always make sure that your current directory is the root directory of the repo (i.e. `frappe_docker/`)
|
## For More Info
|
||||||
|
|
||||||
For more info on building 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 building this docker container refer to this [Wiki](https://github.com/frappe/frappe_docker/wiki/Hitchhiker's-guide-to-building-this-frappe_docker-image)
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
Feel free to contribute to this project and make the container better
|
Feel free to contribute to this project and make it better.
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,8 @@
|
||||||
#collation-server = utf8_general_ci
|
#collation-server = utf8_general_ci
|
||||||
#character_set_server = utf8
|
#character_set_server = utf8
|
||||||
#collation_server = utf8_general_ci
|
#collation_server = utf8_general_ci
|
||||||
# Import all .cnf files from configuration directory
|
|
||||||
bind-address = 0.0.0.0
|
bind-address = 0.0.0.0
|
||||||
|
# Import all .cnf files from configuration directory
|
||||||
!includedir /etc/mysql/mariadb.conf.d/
|
!includedir /etc/mysql/mariadb.conf.d/
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ services:
|
||||||
- /var/lib/mysql
|
- /var/lib/mysql
|
||||||
|
|
||||||
ports:
|
ports:
|
||||||
- "3307:3306" #mariadb-port
|
- "3307:3306" # MariaDB Port
|
||||||
|
|
||||||
container_name: mariadb
|
container_name: mariadb
|
||||||
|
|
||||||
|
|
@ -49,26 +49,32 @@ services:
|
||||||
|
|
||||||
|
|
||||||
frappe:
|
frappe:
|
||||||
|
build: .
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
- ./frappe-bench:/home/frappe/frappe-bench
|
- ./frappe-bench:/home/frappe/frappe-bench
|
||||||
- ./conf/redis-conf.d/redis_cache.conf:/home/frappe/frappe-bench/config/redis_cache.conf
|
- ./conf/redis-conf.d/redis_cache.conf:/home/frappe/frappe-bench/config/redis_cache.conf
|
||||||
- ./conf/redis-conf.d/redis_queue.conf:/home/frappe/frappe-bench/config/redis_queue.conf
|
- ./conf/redis-conf.d/redis_queue.conf:/home/frappe/frappe-bench/config/redis_queue.conf
|
||||||
- ./conf/redis-conf.d/redis_socketio.conf:/home/frappe/frappe-bench/config/redis_socketio.conf
|
- ./conf/redis-conf.d/redis_socketio.conf:/home/frappe/frappe-bench/config/redis_socketio.conf
|
||||||
build: .
|
|
||||||
ports:
|
ports:
|
||||||
- "8000:8000" #webserver_port
|
- "8000:8000" # Webserver Port
|
||||||
- "9000:9000" #socketio_port
|
- "9000:9000" # Socketio Port
|
||||||
- "6787:6787" #file_watcher_port
|
- "6787:6787" # File Watcher Port
|
||||||
|
|
||||||
stdin_open: true
|
stdin_open: true
|
||||||
tty: true
|
tty: true
|
||||||
|
|
||||||
links:
|
links:
|
||||||
- redis-cache
|
- redis-cache
|
||||||
- redis-queue
|
- redis-queue
|
||||||
- redis-socketio
|
- redis-socketio
|
||||||
- mariadb
|
- mariadb
|
||||||
|
|
||||||
depends_on:
|
depends_on:
|
||||||
- mariadb
|
- mariadb
|
||||||
- redis-cache
|
- redis-cache
|
||||||
- redis-queue
|
- redis-queue
|
||||||
- redis-socketio
|
- redis-socketio
|
||||||
|
|
||||||
container_name: frappe
|
container_name: frappe
|
||||||
|
|
|
||||||
29
test.py
29
test.py
|
|
@ -1,29 +0,0 @@
|
||||||
import subprocess, requests, datetime, _thread, time, os, signal
|
|
||||||
start_time = datetime.datetime.now().time()
|
|
||||||
bench_start = 'docker exec -i frappe bash -c "bench start"'
|
|
||||||
process = subprocess.Popen(bench_start, stdout=subprocess.PIPE , shell=True)
|
|
||||||
|
|
||||||
|
|
||||||
def print_out(val,delay):
|
|
||||||
while 1:
|
|
||||||
time.sleep(delay)
|
|
||||||
if val == 1:
|
|
||||||
result,error = process.communicate()
|
|
||||||
print(result)
|
|
||||||
elif val == 2:
|
|
||||||
try:
|
|
||||||
global r
|
|
||||||
r = requests.get("http://localhost:8000")
|
|
||||||
print(r)
|
|
||||||
except requests.exceptions.ConnectionError as e:
|
|
||||||
print(e)
|
|
||||||
|
|
||||||
_thread.start_new_thread(print_out, (1, 1))
|
|
||||||
#result, error = process.communicate()
|
|
||||||
_thread.start_new_thread(print_out, (2, 1))
|
|
||||||
|
|
||||||
time.sleep(30)
|
|
||||||
|
|
||||||
process.kill()
|
|
||||||
|
|
||||||
assert '<title> Login </title>' in str(r.content)
|
|
||||||
17
test.sh
Normal file
17
test.sh
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
cat <(./dbench start) &
|
||||||
|
|
||||||
|
sleep 5
|
||||||
|
|
||||||
|
while ! [[ $i == 20 ]]
|
||||||
|
do
|
||||||
|
output=$( curl "http://localhost:8000" )
|
||||||
|
{ echo "Exit status of curl: $?"
|
||||||
|
} 1>&2
|
||||||
|
sleep 2
|
||||||
|
i=$((i + 1))
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
|
echo "${output}" | grep '<title> Login </title>' || exit 1
|
||||||
Loading…
Reference in a new issue