Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add docker env #115

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/composer.lock
/doc
/target/
/vendor/
/vendor/
.idea
36 changes: 36 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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 \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is better to checkout the master branch rather than the trying branch. The latter is used by Bors to run the tests.

Copy link
Author

@suhanyujie suhanyujie May 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Hywan Hi, I'm having some problems. When I checkout the master branch, I can't build the docker env(docker build -t phpwasm:0.0.3 .), it prompt error like this:

...
checking whether the gcc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking dynamic linker characteristics... GNU/Linux ld.so
(cached) (cached) checking how to hardcode library paths into programs... unsupported
configure: patching config.h.in
configure: creating ./config.status
config.status: creating config.h
mkdir .libs
 gcc -I. -I/home/circleci/project/src -DPHP_ATOM_INC -I/home/circleci/project/src/include -I/home/circleci/project/src/main -I/home/circleci/project/src -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -DHAVE_CONFIG_H -c /home/circleci/project/src/wasm.cc -fPIC  -DPIC -o .libs/wasm.o
cc -shared  .libs/wasm.o  -L/home/circleci/project/src/. -lwasmer_runtime_c_api  -Wl,-rpath -Wl,/home/circleci/project/src/. -Wl,-soname -Wl,wasm.so -o .libs/wasm.so
/usr/bin/ld: cannot find -lwasmer_runtime_c_api
collect2: error: ld returned 1 exit status

...

And I don't know how to resolve it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should use -L instead of -l, but as a short-term solution, did you try to set the LD_LIBRARY_PATH environment variable?

&& 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 \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it a workaround for China? Do we want to keep this in the general Dockerfile?

&& 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"]
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we update since we have our own Dockerfile file?


## Testing

Once the extension is compiled and installed (just run `just rust && just php`), run the following commands:
Expand Down