Skip to content

Commit

Permalink
Fetching W3C validator from new source home @ GitHub, exposing Valida…
Browse files Browse the repository at this point in the history
…tor.nu container port to host (as required by W3C validator), upgraded Validator.nu version, bash build/run scripts no longer sudo docker.
  • Loading branch information
magnetikonline committed Aug 8, 2015
1 parent 0b6dbf5 commit 5334c97
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 31 deletions.
7 changes: 3 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@ RUN apt-get clean

ADD ./resource/apache.server.conf /etc/apache2/conf-available/server.conf
ADD ./resource/supervisord.conf /etc/supervisor/conf.d/
ADD http://validator.w3.org/validator.tar.gz /root/build/
ADD http://validator.w3.org/sgml-lib.tar.gz /root/build/
ADD https://github.com/validator/validator/releases/download/15.4.12/vnu.jar_15.4.12.zip /root/build/
ADD https://github.com/w3c/markup-validator/archive/master.zip /root/build/markup-validator-master.zip
ADD https://github.com/validator/validator/releases/download/15.6.29/vnu.jar_15.6.29.zip /root/build/

ADD ./resource/configure.sh /root/build/
WORKDIR /root/build
RUN chmod a+x configure.sh
RUN chmod u+x configure.sh
RUN ./configure.sh

EXPOSE 80
Expand Down
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ $ ./build.sh
```

This will take some time (lots to download), performing the following tasks:
- Install Ubuntu base (14.04), Apache HTTP server, OpenJDK 7, [supervisord](http://supervisord.org/) and a few others.
- Download latest W3C validator source and [Validator.nu](http://validator.github.io/) `vnu.jar` portable HTML5 validator jar.
- Install Ubuntu base (14.04.2 LTS), Apache HTTP server, OpenJDK 7, [supervisord](http://supervisord.org/) and a few others.
- Download latest W3C validator source and [Validator.nu](http://validator.github.io/validator/) `vnu.jar` portable HTML5 validator jar.
- Configure Perl/CPAN.
- Install and configure W3C validator (including Validator.nu setup).
- Start Apache and Validator.nu under `supervisord`.
Expand All @@ -32,6 +32,10 @@ To start the image, run the following:
$ ./run.sh
```

This will start the image in a new detached container and expose port `80` (Apache2) to your host machine on port `8080`. You can of course run the container on an alternative local port if you desire by modifying the Docker `-p` switch to suit.
This will start the image in a new backgrounded container, exposing the following ports:
- Port `80` (Apache2) to host machine on port `8080`.
- Port `8888` (Validator.nu Java server) to host on port `8888`.

With this complete you should now be able to browse to `http://localhost:8080/` and be presented with a working W3C validator instance.
You can of course run the container on an alternative local port if you desire by modifying the `docker run -p` switches.

With this complete you should now be able to browse to http://localhost:8080/ and be presented with a working W3C validator instance.
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash

sudo docker build -t magnetikonline/html5validator .
docker build -t magnetikonline/html5validator .
46 changes: 25 additions & 21 deletions resource/configure.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

W3C_VALIDATOR_SOURCE_BASE_DIR="/root/build/markup-validator-master"
W3C_VALIDATOR_TARGET_BASE_DIR="/usr/local/validator"
W3C_VALIDATOR_CONF="/etc/w3c/validator.conf"
W3C_VALIDATOR_APACHE_CONF="/etc/apache2/conf-available/w3c-validator.conf"
VALIDATOR_NU_BASE_DIR="/root/build/validator.nu"
Expand All @@ -15,46 +17,47 @@ perl -MCPAN \
-e 'install Bundle::W3C::Validator;'


# configure W3C validator and Apache HTTP server
tar -xf validator.tar.gz
tar -xf sgml-lib.tar.gz
# install W3C validator source into place
unzip markup-validator-master.zip

mkdir -p /usr/local/validator
mkdir -p /etc/w3c

mv validator-1.3/htdocs /usr/local/validator
mv validator-1.3/share /usr/local/validator
mv validator-1.3/httpd/cgi-bin /usr/local/validator
cp validator-1.3/httpd/conf/httpd.conf $W3C_VALIDATOR_APACHE_CONF
mv validator-1.1/htdocs/sgml-lib /usr/local/validator/htdocs
cp /usr/local/validator/htdocs/config/* /etc/w3c
mv $W3C_VALIDATOR_SOURCE_BASE_DIR/htdocs $W3C_VALIDATOR_TARGET_BASE_DIR
mv $W3C_VALIDATOR_SOURCE_BASE_DIR/share $W3C_VALIDATOR_TARGET_BASE_DIR
mv $W3C_VALIDATOR_SOURCE_BASE_DIR/httpd/cgi-bin $W3C_VALIDATOR_TARGET_BASE_DIR
cp $W3C_VALIDATOR_SOURCE_BASE_DIR/httpd/conf/httpd.conf $W3C_VALIDATOR_APACHE_CONF
mv $W3C_VALIDATOR_TARGET_BASE_DIR/htdocs/sgml-lib $W3C_VALIDATOR_TARGET_BASE_DIR/htdocs
cp $W3C_VALIDATOR_TARGET_BASE_DIR/htdocs/config/* /etc/w3c

# configure w3c validator and Apache HTTP server

# modify $W3C_VALIDATOR_CONF to allow validation of private IP addresses
cat $W3C_VALIDATOR_CONF \
| sed -e 's/Allow Private IPs = no/Allow Private IPs = yes/' \
| sed 's/Allow Private IPs = no/Allow Private IPs = yes/' \
> $W3C_VALIDATOR_CONF.tmp
mv $W3C_VALIDATOR_CONF.tmp $W3C_VALIDATOR_CONF

# modify $W3C_VALIDATOR_APACHE_CONF to enable SSILegacyExprParser for Apache 2.4.x web server (needed for W3C validator app)
# modify $W3C_VALIDATOR_APACHE_CONF to enable SSILegacyExprParser for Apache 2.4.x web server (a requirement for the W3C validator app)
cat $W3C_VALIDATOR_APACHE_CONF \
| sed -e 's/<Directory \/usr\/local\/validator\/htdocs\/>/<Directory \/usr\/local\/validator\/htdocs\/>\n SSILegacyExprParser on\n/' \
| sed 's/<Directory \/usr\/local\/validator\/htdocs\/>/<Directory \/usr\/local\/validator\/htdocs\/>\n SSILegacyExprParser on\n/' \
> $W3C_VALIDATOR_APACHE_CONF.tmp
mv $W3C_VALIDATOR_APACHE_CONF.tmp $W3C_VALIDATOR_APACHE_CONF

# modify $W3C_VALIDATOR_APACHE_CONF to open access for HTTP requests
cat $W3C_VALIDATOR_APACHE_CONF \
| sed -e 's/<Directory \/usr\/local\/validator\/htdocs\/>/<Directory \/usr\/local\/validator\/htdocs\/>\n Require all granted\n/' \
| sed -e 's/<LocationMatch "^\/+w3c-validator\/+(check|feedback(\\.html)?)$">/<LocationMatch "^\/+w3c-validator\/+(check|feedback(\\.html)?)$">\n Require all granted\n/' \
| sed 's/<Directory \/usr\/local\/validator\/htdocs\/>/<Directory \/usr\/local\/validator\/htdocs\/>\n Require all granted\n/' \
| sed 's/<LocationMatch "^\/+w3c-validator\/+(check|feedback(\\.html)?)$">/<LocationMatch "^\/+w3c-validator\/+(check|feedback(\\.html)?)$">\n Require all granted\n/' \
> $W3C_VALIDATOR_APACHE_CONF.tmp
mv $W3C_VALIDATOR_APACHE_CONF.tmp $W3C_VALIDATOR_APACHE_CONF

# modify $W3C_VALIDATOR_APACHE_CONF so validator is accessible from http://[server]:[port]/, not http://[server]:[port]/w3c-validator/
cat $W3C_VALIDATOR_APACHE_CONF \
| sed -e 's/Alias \/w3c-validator\//Alias \//' \
| sed -e 's/RewriteBase \/w3c-validator\//RewriteBase \//' \
| sed -e 's/Redirect \/w3c-validator\//Redirect \//' \
| sed -e 's/w3c-validator\/+//' \
| sed -e 's/\/w3c-validator\/check/\/check/' \
| sed 's/Alias \/w3c-validator\//Alias \//' \
| sed 's/RewriteBase \/w3c-validator\//RewriteBase \//' \
| sed 's/Redirect \/w3c-validator\//Redirect \//' \
| sed 's/w3c-validator\/+//' \
| sed 's/\/w3c-validator\/check/\/check/' \
> $W3C_VALIDATOR_APACHE_CONF.tmp
mv $W3C_VALIDATOR_APACHE_CONF.tmp $W3C_VALIDATOR_APACHE_CONF

Expand All @@ -74,9 +77,10 @@ unzip -j vnu[-.]*.zip -d $VALIDATOR_NU_BASE_DIR

# enable validator.nu within W3C validator $W3C_VALIDATOR_CONF file
cat $W3C_VALIDATOR_CONF \
| sed -e 's/#HTML5 =/HTML5 =/' \
| sed -e 's/#CompoundXML =/CompoundXML/' \
| sed 's/#HTML5 =/HTML5 =/' \
| sed 's/#CompoundXML =/CompoundXML/' \
> $W3C_VALIDATOR_CONF.tmp
mv $W3C_VALIDATOR_CONF.tmp $W3C_VALIDATOR_CONF

# all done
exit 0
6 changes: 5 additions & 1 deletion run.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#!/bin/bash

sudo docker run -dp 8080:80 magnetikonline/html5validator
# expose container port 80 (original W3C validator engine) and port 8888 (Nu Html Checker)
docker run -d \
-p 8080:80 \
-p 8888:8888 \
magnetikonline/html5validator

0 comments on commit 5334c97

Please sign in to comment.