diff --git a/.docker/Dockerfile b/.docker/Dockerfile new file mode 100644 index 0000000000..eb5de63e13 --- /dev/null +++ b/.docker/Dockerfile @@ -0,0 +1,22 @@ +FROM php:8.2-cli + +RUN apt-get update && \ + apt-get install -y git + +WORKDIR /var/www + +ADD https://api.github.com/repos/php/phd/git/refs/heads/master version-phd.json +ADD https://api.github.com/repos/php/doc-base/git/refs/heads/master version-doc-base.json +ADD https://api.github.com/repos/php/doc-en/git/refs/heads/master version-doc-en.json + +RUN git clone --depth 1 https://github.com/php/phd.git && \ + git clone --depth 1 https://github.com/php/doc-base.git && \ + git clone --depth 1 https://github.com/php/doc-en.git en + +RUN echo 'memory_limit = 512M' >> /usr/local/etc/php/conf.d/local.ini + +ENV FORMAT=xhtml +ENV LANG=en + +CMD php doc-base/configure.php --disable-segfault-error --with-lang=${LANG} && \ + php phd/render.php --docbook doc-base/.manual.xml --output=/var/www/${LANG}/output --package PHP --format ${FORMAT} diff --git a/.gitignore b/.gitignore index fd26deaceb..c31e6b8b13 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ entities.*.xml /en/ /doc-base/ +output +.docker/built diff --git a/Makefile b/Makefile new file mode 100644 index 0000000000..e3213c9b47 --- /dev/null +++ b/Makefile @@ -0,0 +1,40 @@ +.PHONY: * + +SHELL = /bin/sh + +CURRENT_UID := $(shell id -u) +CURRENT_GID := $(shell id -g) + +LANG := $(subst doc-,,$(shell basename ${PWD})) + +# +# If doc-base, en, or phd exist as siblings to the current directory, +# add those as volumes to our Docker runs. +# + +PATHS := -v .:/var/www/${LANG} +ifneq ($(wildcard ../doc-base/LICENSE),) + PATHS += -v ${PWD}/../doc-base:/var/www/doc-base +endif +ifneq ($(wildcard ../phd/LICENSE),) + PATHS += -v ${PWD}/../phd:/var/www/phd +endif +ifneq (${LANG},en) + ifneq ($(wildcard ../en/README.md),) + PATHS += -v ${PWD}/../en:/var/www/en + endif +endif + +xhtml: .docker/built + docker run ${PATHS} -w /var/www -u ${CURRENT_UID}:${CURRENT_GID} \ + -e LANG=${LANG} php/doc-build + +php: .docker/built + docker run ${PATHS} -w /var/www -u ${CURRENT_UID}:${CURRENT_GID} \ + -e LANG=${LANG} -e FORMAT=php php/doc-build + +build: .docker/built + +.docker/built: + docker build .docker -t php/doc-build + touch .docker/built