Skip to content

Instantly share code, notes, and snippets.

@nielsdos
Last active November 27, 2023 11:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nielsdos/139099c54ddc4a43bc66f4c0b7ef02fc to your computer and use it in GitHub Desktop.
Save nielsdos/139099c54ddc4a43bc66f4c0b7ef02fc to your computer and use it in GitHub Desktop.
Dockerfile for HTML5 branch

Building the following Dockerfile will give you the latest version of my ext/dom HTML5 branch:

FROM ubuntu:22.04

ENV DEBIAN_FRONTEND=noninteractive

RUN apt update
RUN apt install -y binutils gcc re2c flex bison libxml2-dev libsqlite3-dev vim git autoconf pkg-config make libonig-dev

WORKDIR /

ADD https://api.github.com/repos/nielsdos/php-src/git/refs/heads/dom-bridge-lexbor version.json
RUN git clone -b dom-bridge-lexbor https://github.com/nielsdos/php-src.git
WORKDIR /php-src
RUN ./buildconf --force
RUN apt install -y libreadline-dev libssl-dev
RUN ./configure --enable-mbstring --with-readline --with-openssl
RUN make -j4
RUN make install

ENTRYPOINT ["/bin/bash"]

Save it as "Dockerfile" in an empty directory, enter that directory and execute the following command to build it:

$ docker build -t extdomhtml5 .

After the building is done, you can enter the container using:

$ docker run --rm -it extdomhtml5

You can use the php -a command to try it out. Or you can create a PHP script to try it out, or share a directory with your host.

Examples:

<?php
$dom = DOM\HTMLDocument::createFromString("<p>foo</p>");
// Or files
$dom = DOM\HTMLDocument::createFromFile("myfile.html");

// Any method you're used to will work fine with documents parsed using the HTML5 parser.
echo $dom->saveHTML();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment