├── Dockerfile ├── LICENSE ├── README.md ├── build.sh ├── resource ├── apache.server.conf ├── configure.sh └── supervisord.conf └── run.sh /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:16.04 2 | LABEL maintainer="Peter Mescalchin " 3 | 4 | ENV W3C_VALIDATOR_SHA1 31cf48c79ccc4c2648125a9606073d013cb107e2 5 | ENV VNU_VALIDATOR_VERSION 17.11.1 6 | 7 | RUN apt-get update && apt-get upgrade --yes && \ 8 | apt-get install --yes \ 9 | apache2 build-essential \ 10 | libapache2-mod-perl2 libhtml-tidy-perl libosp-dev libxml-libxml-perl libxml2-dev \ 11 | openjdk-8-jre-headless opensp supervisor unzip zlib1g-dev && \ 12 | apt-get clean 13 | 14 | ADD ./resource/apache.server.conf /etc/apache2/conf-available/server.conf 15 | ADD ./resource/supervisord.conf /etc/supervisor/conf.d/ 16 | ADD "https://github.com/w3c/markup-validator/archive/$W3C_VALIDATOR_SHA1.zip" "/root/build/markup-validator-$W3C_VALIDATOR_SHA1.zip" 17 | ADD "https://github.com/validator/validator/releases/download/$VNU_VALIDATOR_VERSION/vnu.jar_$VNU_VALIDATOR_VERSION.zip" /root/build/ 18 | 19 | ADD ./resource/configure.sh /root/build/ 20 | WORKDIR /root/build 21 | RUN chmod u+x configure.sh 22 | RUN ./configure.sh "$W3C_VALIDATOR_SHA1" "$VNU_VALIDATOR_VERSION" 23 | 24 | EXPOSE 80 25 | 26 | CMD ["/usr/bin/supervisord","-c","/etc/supervisor/supervisord.conf"] 27 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2014 Peter Mescalchin 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Docker W3C/HTML5 validator instance 2 | 3 | Dockerfile for the creation of a self contained W3C Markup validator (with HTML5 validation) instance for fast/offline validation of authored HTML documents. 4 | 5 | Setup of such a configuration can be tricky and a little messy so having all this in an isolated and automated way seemed like a good idea. 6 | 7 | ## Building 8 | 9 | To build the Docker image, run the following: 10 | 11 | ```sh 12 | $ ./build.sh 13 | ``` 14 | 15 | This will take some time - performing the following tasks: 16 | 17 | - Install Ubuntu base (16.04 LTS), Apache HTTP server, OpenJDK 8, [supervisord](http://supervisord.org/) and a few others. 18 | - Download latest W3C validator source and [Validator.nu](https://validator.github.io/validator/) `vnu.jar` portable HTML5 validator jar. 19 | - Configure Perl/CPAN. 20 | - Install and configure W3C validator (including Validator.nu setup). 21 | - Start Apache and Validator.nu under `supervisord`. 22 | 23 | That's the boring/messy stuff out of the way - your new Docker image should now be built. 24 | 25 | Alternatively you can pull this image directly from Docker Hub: 26 | 27 | ```sh 28 | $ docker pull magnetikonline/html5-validator 29 | ``` 30 | 31 | ## Running 32 | 33 | To start the image, run the following: 34 | 35 | ```sh 36 | $ ./run.sh 37 | ``` 38 | 39 | This will start the image in a new backgrounded container, exposing the following ports: 40 | 41 | - Port `80` (Apache2) presented to host on `8080`. 42 | - Port `8888` (Validator.nu Java server) presented to host on `8888`. 43 | 44 | Running the container on alternative local ports is controlled via [`docker run --publish`](run.sh#L8-L9) arguments. 45 | 46 | With this complete you should now be able to browse to http://localhost:8080/ and be presented with a working W3C validator instance. 47 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | DIRNAME=$(dirname "$0") 4 | DOCKER_IMAGE_NAME="magnetikonline/html5-validator" 5 | 6 | 7 | docker build \ 8 | --tag "$DOCKER_IMAGE_NAME" \ 9 | "$DIRNAME" 10 | -------------------------------------------------------------------------------- /resource/apache.server.conf: -------------------------------------------------------------------------------- 1 | ServerName localhost 2 | StartServers 1 3 | -------------------------------------------------------------------------------- /resource/configure.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | W3C_VALIDATOR_TARGET_BASE_DIR="/usr/local/validator" 4 | W3C_VALIDATOR_CONF="/etc/w3c/validator.conf" 5 | W3C_VALIDATOR_APACHE_CONF="/etc/apache2/conf-available/w3c-validator.conf" 6 | VALIDATOR_NU_BASE_DIR="/root/build/validator.nu" 7 | 8 | 9 | # read arguments 10 | w3cValidatorSHA1=$1 11 | vnuValidatorVersion=$2 12 | 13 | # configure Perl 14 | PERL_MM_USE_DEFAULT=1 \ 15 | perl -MCPAN \ 16 | -e "my \$c = \"CPAN::HandleConfig\";" \ 17 | -e "\$c->load(doit => 1,autoconfig => 1);" \ 18 | -e "\$c->edit(prerequisites_policy => \"follow\");\$c->edit(build_requires_install_policy => \"yes\");" \ 19 | -e "\$c->commit();" \ 20 | -e "install Bundle::W3C::Validator;" 21 | 22 | 23 | # install W3C validator source into place 24 | unzip "markup-validator-$w3cValidatorSHA1.zip" 25 | 26 | mkdir --parents /usr/local/validator 27 | mkdir --parents /etc/w3c 28 | 29 | w3cValidatorSourceBaseDir="/root/build/markup-validator-$w3cValidatorSHA1" 30 | mv "$w3cValidatorSourceBaseDir/htdocs" "$W3C_VALIDATOR_TARGET_BASE_DIR" 31 | mv "$w3cValidatorSourceBaseDir/share" "$W3C_VALIDATOR_TARGET_BASE_DIR" 32 | mv "$w3cValidatorSourceBaseDir/httpd/cgi-bin" "$W3C_VALIDATOR_TARGET_BASE_DIR" 33 | cp "$w3cValidatorSourceBaseDir/httpd/conf/httpd.conf" "$W3C_VALIDATOR_APACHE_CONF" 34 | cp "$W3C_VALIDATOR_TARGET_BASE_DIR/htdocs/config/"* /etc/w3c 35 | 36 | # configure w3c validator and Apache HTTP server 37 | 38 | # modify $W3C_VALIDATOR_CONF to allow validation of private IP addresses 39 | cat "$W3C_VALIDATOR_CONF" | \ 40 | sed --regexp-extended "s/(Allow Private IPs =) no/\1 yes/" \ 41 | >"$W3C_VALIDATOR_CONF.tmp" 42 | 43 | mv "$W3C_VALIDATOR_CONF.tmp" "$W3C_VALIDATOR_CONF" 44 | 45 | # modify $W3C_VALIDATOR_APACHE_CONF to enable SSILegacyExprParser for Apache 2.4.x web server (a requirement for the W3C validator app) 46 | cat "$W3C_VALIDATOR_APACHE_CONF" | \ 47 | sed --regexp-extended "s/()/\1\n SSILegacyExprParser on\n/" \ 48 | >"$W3C_VALIDATOR_APACHE_CONF.tmp" 49 | 50 | mv "$W3C_VALIDATOR_APACHE_CONF.tmp" "$W3C_VALIDATOR_APACHE_CONF" 51 | 52 | # modify $W3C_VALIDATOR_APACHE_CONF to open access for HTTP requests 53 | cat "$W3C_VALIDATOR_APACHE_CONF" | \ 54 | sed --regexp-extended "s/()/\1\n Require all granted\n/" | \ 55 | sed --regexp-extended "s/()/\1\n Require all granted\n/" \ 56 | >"$W3C_VALIDATOR_APACHE_CONF.tmp" 57 | 58 | mv "$W3C_VALIDATOR_APACHE_CONF.tmp" "$W3C_VALIDATOR_APACHE_CONF" 59 | 60 | # modify $W3C_VALIDATOR_APACHE_CONF so validator is accessible from http://[server]:[port]/, not http://[server]:[port]/w3c-validator/ 61 | cat "$W3C_VALIDATOR_APACHE_CONF" | \ 62 | sed --regexp-extended "s/(Alias) \/w3c-validator\//\1 \//" | \ 63 | sed --regexp-extended "s/(RewriteBase) \/w3c-validator\//\1 \//" | \ 64 | sed --regexp-extended "s/(Redirect) \/w3c-validator\//\1 \//" | \ 65 | sed --regexp-extended "s/w3c-validator\/\+//" | \ 66 | sed --regexp-extended "s/\/w3c-validator(\/check)/\1/" \ 67 | >"$W3C_VALIDATOR_APACHE_CONF.tmp" 68 | 69 | mv "$W3C_VALIDATOR_APACHE_CONF.tmp" "$W3C_VALIDATOR_APACHE_CONF" 70 | 71 | a2enmod cgid 72 | a2enmod expires 73 | a2enmod include 74 | a2enmod rewrite 75 | a2dismod perl 76 | 77 | a2enconf server 78 | a2enconf w3c-validator 79 | 80 | 81 | # install standalone validator.nu jar to $VALIDATOR_NU_BASE_DIR/vnu.jar 82 | mkdir --parents "$VALIDATOR_NU_BASE_DIR" 83 | unzip -j "vnu.jar_$vnuValidatorVersion.zip" -d "$VALIDATOR_NU_BASE_DIR" 84 | 85 | # enable validator.nu within W3C validator $W3C_VALIDATOR_CONF file 86 | cat "$W3C_VALIDATOR_CONF" | \ 87 | sed --regexp-extended "s/#(HTML5 =)/\1/" \ 88 | >"$W3C_VALIDATOR_CONF.tmp" 89 | 90 | mv "$W3C_VALIDATOR_CONF.tmp" "$W3C_VALIDATOR_CONF" 91 | -------------------------------------------------------------------------------- /resource/supervisord.conf: -------------------------------------------------------------------------------- 1 | [supervisord] 2 | nodaemon=true 3 | 4 | [program:apache2] 5 | command=/bin/bash -c ". /etc/apache2/envvars && /usr/sbin/apache2 -DFOREGROUND" 6 | 7 | [program:validatornu] 8 | command=java -cp /root/build/validator.nu/vnu.jar nu.validator.servlet.Main 8888 9 | -------------------------------------------------------------------------------- /run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -e 2 | 3 | DOCKER_IMAGE_NAME="magnetikonline/html5-validator" 4 | 5 | 6 | # expose container port 80 (original W3C validator) and port 8888 (Nu Html Checker) 7 | docker run --detach \ 8 | --publish 8080:80 \ 9 | --publish 8888:8888 \ 10 | "$DOCKER_IMAGE_NAME" 11 | --------------------------------------------------------------------------------