mirror of
https://github.com/frappe/frappe_docker.git
synced 2026-06-17 13:55:08 +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/*
|
||||
.travis.yml
|
||||
test.py
|
||||
test.sh
|
||||
README.md
|
||||
LICENSE.md
|
||||
.gitignore
|
||||
dbench
|
||||
docker-*.yml
|
||||
15
.travis.yml
15
.travis.yml
|
|
@ -1,9 +1,9 @@
|
|||
language: python
|
||||
python:
|
||||
- "2.7"
|
||||
dist: xenial
|
||||
|
||||
env:
|
||||
- DOCKER_COMPOSE_VERSION: 1.23.1
|
||||
|
||||
|
||||
services:
|
||||
- docker
|
||||
|
||||
|
|
@ -19,14 +19,11 @@ before_install:
|
|||
|
||||
install:
|
||||
- chmod ugo+x ./dbench
|
||||
- chmod ugo+x ./test.sh
|
||||
- ./dbench setup docker
|
||||
- ./dbench init frappe-bench
|
||||
- ./dbench new-site site1.local
|
||||
- ./dbench setup hosts
|
||||
- pip install --upgrade virtualenv
|
||||
- virtualenv -p python3 testenv
|
||||
- source testenv/bin/activate
|
||||
- pip install requests
|
||||
|
||||
script:
|
||||
- docker-compose ps | grep -i frappe
|
||||
|
|
@ -34,5 +31,5 @@ script:
|
|||
- docker-compose ps | grep -i redis-queue
|
||||
- docker-compose ps | grep -i redis-socketio
|
||||
- docker-compose ps | grep -i mariadb
|
||||
- python test.py
|
||||
- docker-compose stop
|
||||
- ./test.sh
|
||||
- ./dbench setup docker stop
|
||||
|
|
|
|||
34
Dockerfile
34
Dockerfile
|
|
@ -1,21 +1,19 @@
|
|||
# Frappe Bench Dockerfile
|
||||
|
||||
FROM ubuntu:16.04
|
||||
FROM debian:9.6-slim
|
||||
LABEL author=frappé
|
||||
|
||||
# Set locale C.UTF-8 for mariadb and general locale data
|
||||
ENV LANG C.UTF-8
|
||||
|
||||
# Install all neccesary packages
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends iputils-ping git build-essential \
|
||||
libffi-dev libssl-dev libjpeg8-dev redis-tools software-properties-common libxext6 xfonts-75dpi xfonts-base \
|
||||
python-dev libfreetype6-dev liblcms2-dev libwebp-dev python-tk libsasl2-dev libldap2-dev libtiff5-dev \
|
||||
python-setuptools tk8.6-dev wget libmysqlclient-dev mariadb-client curl rlwrap wkhtmltopdf python-pip sudo \
|
||||
&& apt-get clean && rm -rf /var/lib/apt/lists/*
|
||||
RUN pip install --upgrade setuptools pip && rm -rf ~/.cache/pip
|
||||
|
||||
# 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 \
|
||||
RUN apt-get update && apt-get install -y --no-install-suggests --no-install-recommends build-essential cron curl git iputils-ping libffi-dev \
|
||||
liblcms2-dev libldap2-dev libmariadbclient-dev libsasl2-dev libssl-dev libtiff5-dev libwebp-dev mariadb-client \
|
||||
python-dev python-pip python-setuptools python-tk redis-tools rlwrap software-properties-common sudo tk8.6-dev \
|
||||
vim xfonts-75dpi xfonts-base wget wkhtmltopdf \
|
||||
&& apt-get clean && rm -rf /var/lib/apt/lists/* \
|
||||
&& 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 \
|
||||
&& dpkg -i node.deb \
|
||||
&& rm node.deb \
|
||||
&& 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 \
|
||||
&& printf '# Sudo rules for frappe\nfrappe ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers.d/frappe
|
||||
|
||||
USER 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
|
||||
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
|
||||
|
||||
EXPOSE 8000
|
||||
EXPOSE 9000
|
||||
EXPOSE 6787
|
||||
EXPOSE 8000 9000 6787
|
||||
|
||||
VOLUME [ "/home/frappe/frappe-bench" ]
|
||||
49
README.md
49
README.md
|
|
@ -1,69 +1,72 @@
|
|||
# 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.
|
||||
|
||||
## 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 frappe_docker
|
||||
1. Clone this repo and change your working directory to it:
|
||||
|
||||
```bash
|
||||
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
|
||||
./dbench setup docker
|
||||
./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
|
||||
./dbench new-site site1.local
|
||||
./dbench setup hosts
|
||||
./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.
|
||||
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)
|
||||
|
||||
## 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
|
||||
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@
|
|||
#collation-server = utf8_general_ci
|
||||
#character_set_server = utf8
|
||||
#collation_server = utf8_general_ci
|
||||
# Import all .cnf files from configuration directory
|
||||
bind-address = 0.0.0.0
|
||||
# Import all .cnf files from configuration directory
|
||||
!includedir /etc/mysql/mariadb.conf.d/
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ services:
|
|||
- /var/lib/mysql
|
||||
|
||||
ports:
|
||||
- "3307:3306" #mariadb-port
|
||||
- "3307:3306" # MariaDB Port
|
||||
|
||||
container_name: mariadb
|
||||
|
||||
|
|
@ -49,26 +49,32 @@ services:
|
|||
|
||||
|
||||
frappe:
|
||||
build: .
|
||||
|
||||
volumes:
|
||||
- ./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_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
|
||||
build: .
|
||||
|
||||
ports:
|
||||
- "8000:8000" #webserver_port
|
||||
- "9000:9000" #socketio_port
|
||||
- "6787:6787" #file_watcher_port
|
||||
- "8000:8000" # Webserver Port
|
||||
- "9000:9000" # Socketio Port
|
||||
- "6787:6787" # File Watcher Port
|
||||
|
||||
stdin_open: true
|
||||
tty: true
|
||||
|
||||
links:
|
||||
- redis-cache
|
||||
- redis-queue
|
||||
- redis-socketio
|
||||
- mariadb
|
||||
|
||||
depends_on:
|
||||
- mariadb
|
||||
- redis-cache
|
||||
- redis-queue
|
||||
- redis-socketio
|
||||
|
||||
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