Merge pull request #43 from sc0Vu/docker-develop

Docker develop
This commit is contained in:
Kuan-Cheng,Lai 2018-02-08 17:05:12 +08:00 committed by GitHub
commit b9cf0edc27
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 87 additions and 0 deletions

View File

@ -4,6 +4,7 @@ language: php
php:
- 7.1
- 7.2
before_install:
- nvm install 8

View File

@ -208,6 +208,42 @@ To run examples, you need to run ethereum blockchain local (testrpc).
If you are using docker as development machain, you can try [ethdock](https://github.com/sc0vu/ethdock) to run local ethereum blockchain, just simply run `docker-compose up -d testrpc` and expose the `8545` port.
# Develop
### Local php cli installed
1. Clone the repo and install packages.
```
git clone https://github.com/sc0Vu/web3.php.git && cd web3.php && composer install
```
2. Run test script.
```
vendor/bin/phpunit
```
### Docker container
1. Clone the repo and run docker container.
```
git clone https://github.com/sc0Vu/web3.php.git
```
2. Copy web3.php to web3.php/docker/app directory and start container.
```
cp files docker/app && docker-compose up -d php
```
3. Enter php container and install packages.
```
docker-compose exec php ash
```
4. Run test script
```
vendor/bin/phpunit
```
# API
Todo.

11
docker/docker-compose.yml Normal file
View File

@ -0,0 +1,11 @@
version: '2'
services:
php:
build:
context: ./php
dockerfile: Dockerfile-72
volumes:
- ./app:/app
tty: true

17
docker/php/Dockerfile-71 Normal file
View File

@ -0,0 +1,17 @@
FROM php:7.1.14-alpine
MAINTAINER Peter Lai <alk03073135@gmail.com>
ADD composer-setup.php composer-setup.php
RUN apk update && \
apk add git
# Install nodejs
# Run apk add --update nodejs nodejs-npm
# Install composer
RUN php composer-setup.php && \
php composer-setup.php --install-dir=/usr/bin --filename=composer
WORKDIR /app

17
docker/php/Dockerfile-72 Normal file
View File

@ -0,0 +1,17 @@
FROM php:7.2.2-alpine
MAINTAINER Peter Lai <alk03073135@gmail.com>
ADD composer-setup.php composer-setup.php
RUN apk update && \
apk add git
# Install nodejs
# Run apk add --update nodejs nodejs-npm
# Install composer
RUN php composer-setup.php && \
php composer-setup.php --install-dir=/usr/bin --filename=composer
WORKDIR /app

View File

@ -0,0 +1,5 @@
<?php
copy('https://getcomposer.org/installer', 'composer-setup.php');
if (hash_file('SHA384', 'composer-setup.php') === '544e09ee996cdf60ece3804abc52599c22b1f40f4323403c44d44fdfdd586475ca9813a858088ffbc1f233e9b180f061') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;