diff options
| author | nsfisis <nsfisis@gmail.com> | 2023-10-02 01:27:55 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2023-10-02 01:27:55 +0900 |
| commit | 7e9c65507f2ba51ff7c13cfc18cf29722b89c973 (patch) | |
| tree | ad4a566a5bf9e225b212c033608188b31735d6fb /Dockerfile | |
| parent | fcf36b3c9e42ab9fa0ed0e037c6492d0d496f954 (diff) | |
| download | tiny-php.wasm-7e9c65507f2ba51ff7c13cfc18cf29722b89c973.tar.gz tiny-php.wasm-7e9c65507f2ba51ff7c13cfc18cf29722b89c973.tar.zst tiny-php.wasm-7e9c65507f2ba51ff7c13cfc18cf29722b89c973.zip | |
commit files
Diffstat (limited to 'Dockerfile')
| -rw-r--r-- | Dockerfile | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..1ffc8d3 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,75 @@ +FROM emscripten/emsdk:3.1.46 AS wasm-builder + +RUN git clone --depth=1 --branch=php-8.2.10 https://github.com/php/php-src + +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + autoconf \ + bison \ + pkg-config \ + re2c \ + && \ + : + +RUN cd php-src && \ + ./buildconf --force && \ + emconfigure ./configure \ + --disable-all \ + --disable-mbregex \ + --disable-fiber-asm \ + --disable-cli \ + --disable-cgi \ + --disable-phpdbg \ + --enable-embed=static \ + --enable-mbstring \ + --without-iconv \ + --without-libxml \ + --without-pcre-jit \ + --without-pdo-sqlite \ + --without-sqlite3 \ + && \ + EMCC_CFLAGS='-s ERROR_ON_UNDEFINED_SYMBOLS=0' emmake make -j$(nproc) && \ + mv libs/libphp.a .. && \ + make clean && \ + git clean -fd && \ + : + +COPY php-wasm.c /src/ + +RUN cd php-src && \ + emcc \ + -c \ + -o php-wasm.o \ + -I . \ + -I TSRM \ + -I Zend \ + -I main \ + ../php-wasm.c \ + && \ + mv php-wasm.o .. && \ + make clean && \ + git clean -fd && \ + : + +RUN emcc \ + -s ENVIRONMENT=node \ + -s ERROR_ON_UNDEFINED_SYMBOLS=0 \ + -s EXPORTED_RUNTIME_METHODS='["ccall"]' \ + -s EXPORT_ES6=1 \ + -s INITIAL_MEMORY=16777216 \ + -s INVOKE_RUN=0 \ + -s MODULARIZE=1 \ + -o php-wasm.js \ + php-wasm.o \ + libphp.a \ + ; + + +FROM node:20.7 + +WORKDIR /app +COPY --from=wasm-builder /src/php-wasm.js /app/php-wasm.mjs +COPY --from=wasm-builder /src/php-wasm.wasm /app/php-wasm.wasm +COPY index.mjs /app/ + +ENTRYPOINT ["node", "index.mjs"] |
