From 8d263bcce504530d665287a2524e69e67265e3af Mon Sep 17 00:00:00 2001 From: suhanyujie Date: Thu, 2 Apr 2020 19:21:50 +0800 Subject: [PATCH 1/2] add docker env --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index cf9f67e..eb294e7 100644 --- a/README.md +++ b/README.md @@ -165,6 +165,9 @@ please try running `just build-runtime` first. (Yes, you need [`just`](https://github.com/casey/just/)). +### Docker +* `docker run -it --rm --name phpwasm1 suhanyujie/phpwasm:0.0.1 bash` + ## Testing Once the extension is compiled and installed (just run `just rust && just php`), run the following commands: From b2ede49f9ec23458e0cffedc2f128ce2af2d2666 Mon Sep 17 00:00:00 2001 From: suhanyujie Date: Tue, 28 Apr 2020 09:51:34 +0800 Subject: [PATCH 2/2] add Dockerfile --- .gitignore | 3 ++- Dockerfile | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 Dockerfile diff --git a/.gitignore b/.gitignore index 31b3fbd..08f53b5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ /composer.lock /doc /target/ -/vendor/ \ No newline at end of file +/vendor/ +.idea \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..902b8ae --- /dev/null +++ b/Dockerfile @@ -0,0 +1,36 @@ +# docker env for php-ext-wasm +## reference +# * https://circleci.com/gh/wasmerio/php-ext-wasm + +FROM circleci/php:latest + +RUN git clone https://github.com/wasmerio/php-ext-wasm.git $HOME/project \ + && cd $HOME/project && git checkout trying && cd $HOME \ + && test -d /usr/local/cargo || curl https://sh.rustup.rs -sSf | sh -s -- -y \ + && export PATH="$HOME/.cargo/bin:$PATH" \ + && test -f $HOME/.cargo/bin/just || cargo install just \ + && php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \ + && php composer-setup.php \ + && php -r "unlink('composer-setup.php');" \ + && mv composer.phar composer \ + && export PATH="$HOME/.cargo/bin:$PATH" \ + && export CXX="gcc" \ + && EXTENSION="$HOME/project/src" \ + && cd $EXTENSION \ + && PHP_PREFIX=$(php-config --prefix) \ + && PHP_PREFIX_BIN=$PHP_PREFIX/bin \ + && $PHP_PREFIX_BIN/phpize --clean \ + && $PHP_PREFIX_BIN/phpize \ + && ./configure --with-php-config=$PHP_PREFIX_BIN/php-config \ + && /bin/bash $EXTENSION/libtool --mode=compile $CXX -I. -I$EXTENSION -DPHP_ATOM_INC -I$EXTENSION/include -I$EXTENSION/main -I$EXTENSION -I$PHP_PREFIX/include/php -I$PHP_PREFIX/include/php/main -I$PHP_PREFIX/include/php/TSRM -I$PHP_PREFIX/include/php/Zend -I$PHP_PREFIX/include/php/ext -I$PHP_PREFIX/include/php/ext/date/lib -DHAVE_CONFIG_H -c $EXTENSION/wasm.cc -o wasm.lo -fPIC \ + && $CXX -I. -I$EXTENSION -DPHP_ATOM_INC -I$EXTENSION/include -I$EXTENSION/main -I$EXTENSION -I$PHP_PREFIX/include/php -I$PHP_PREFIX/include/php/main -I$PHP_PREFIX/include/php/TSRM -I$PHP_PREFIX/include/php/Zend -I$PHP_PREFIX/include/php/ext -I$PHP_PREFIX/include/php/ext/date/lib -DHAVE_CONFIG_H -c $EXTENSION/wasm.cc -DPIC -o .libs/wasm.o -fPIC \ + && /bin/bash $EXTENSION/libtool --mode=link cc -DPHP_ATOM_INC -I$EXTENSION/include -I$EXTENSION/main -I$EXTENSION -I$PHP_PREFIX/include/php -I$PHP_PREFIX/include/php/main -I$PHP_PREFIX/include/php/TSRM -I$PHP_PREFIX/include/php/Zend -I$PHP_PREFIX/include/php/ext -I$PHP_PREFIX/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -o wasm.la -export-dynamic -avoid-version -prefer-pic -module -rpath $EXTENSION/modules wasm.lo -Wl,-rpath,$EXTENSION/. -L$EXTENSION/. -lwasmer_runtime_c_api -fPIC \ + && cc -shared .libs/wasm.o -L$EXTENSION/. -lwasmer_runtime_c_api -Wl,-rpath -Wl,$EXTENSION/. -Wl,-soname -Wl,wasm.so -o .libs/wasm.so -fPIC \ + && sudo make install-modules \ + && export PATH="$HOME/.cargo/bin:$PATH" \ + && cd $HOME/project \ + && composer config repo.packagist composer https://mirrors.aliyun.com/composer/ && composer install --no-progress \ + && cd /usr/local/etc/php/conf.d && sudo touch docker-php-ext-wasm.ini && sudo chmod 777 docker-php-ext-wasm.ini \ + && echo 'extension=wasm.so' > docker-php-ext-wasm.ini + +CMD ["/bin/sh"]