From 2ec174b68557ecb3cb595174b5793018283fbd1a Mon Sep 17 00:00:00 2001 From: Fabrizio Lungo Date: Wed, 5 Apr 2017 15:06:31 +0100 Subject: [PATCH] Added dev-docker.sh for developing with Docker Developing using Docker is now simple and avoids the need to install PHP on the developer's host machine. Common code from `dev.sh` and `dev-docker.sh` has been extracted into a `dev-prepare.sh`. README contains instructions on how to use both dev scripts - which the developer can choose based on their preference. --- README.md | 11 ++++++++++- dev-docker.sh | 11 +++++++++++ dev-prepare.sh | 3 +++ dev.sh | 4 +--- 4 files changed, 25 insertions(+), 4 deletions(-) create mode 100755 dev-docker.sh create mode 100644 dev-prepare.sh diff --git a/README.md b/README.md index 33256f58..0c3c6bdf 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,16 @@ It's very easy to have lbry.io running locally: - Install PHP7 - Checkout the project - Run `./dev.sh` from the project root -- Access `localhost:8000` in your browser +- Access [localhost:8000](http://localhost:8000) in your browser + +You can also run the development server using docker: + +- Install Docker +- Checkout the project +- Run `./dev-docker.sh` from the project root +- Access [localhost:8000](http://localhost:8000) in your browser + +Both the `dev.sh` and `dev-docker.sh` scripts will initialise a configuration based on `data/config.php.example` if `data/config.php` does not exist. To run remotely, simply install PHP and configure Apache or your server of choice to serve `web/index.php`. diff --git a/dev-docker.sh b/dev-docker.sh new file mode 100755 index 00000000..ef49fac1 --- /dev/null +++ b/dev-docker.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +source dev-prepare.sh + +docker run --rm -it --name "dev.lbry.io" \ + -v "$(readlink -f .):/usr/src/lbry.io" \ + -w "/usr/src/lbry.io" \ + -p "127.0.0.1:8000:8000" \ + -u "$(id -u):$(id -g)" \ + php:7-alpine \ + php --server "0.0.0.0:8000" --docroot "web/" "web/index.php" diff --git a/dev-prepare.sh b/dev-prepare.sh new file mode 100644 index 00000000..7c0d9186 --- /dev/null +++ b/dev-prepare.sh @@ -0,0 +1,3 @@ +if [ ! -e "data/config.php" ]; then + cp "data/config.php.example" "data/config.php" +fi diff --git a/dev.sh b/dev.sh index 1b3361ad..b48d5e02 100755 --- a/dev.sh +++ b/dev.sh @@ -1,7 +1,5 @@ #!/bin/bash -if [ ! -e "data/config.php" ]; then - cp "data/config.php.example" "data/config.php" -fi +source dev-prepare.sh php7.0 --server localhost:8000 --docroot web/ web/index.php