From 1ef0cab7c2af732b9ad043e9faf68b080b7f1200 Mon Sep 17 00:00:00 2001 From: Jim Winstead Date: Tue, 3 Sep 2024 08:02:40 -0700 Subject: [PATCH] Use Makefile instead of docker-compose.yml (#3673) * Use environment variable for format to build * Use Makefile instead of docker-compose.yml This allows us to build different formats more easily, and use phd and doc-base from parallel checkouts, which is much easier for issues that span the repositories. --- .docker/Dockerfile | 4 +++- .gitignore | 1 + Makefile | 32 ++++++++++++++++++++++++++++++++ README.md | 14 ++++++++++++-- docker-compose.yml | 8 -------- 5 files changed, 48 insertions(+), 11 deletions(-) create mode 100644 Makefile delete mode 100644 docker-compose.yml diff --git a/.docker/Dockerfile b/.docker/Dockerfile index 5124ba39cef3..fe258efb545e 100644 --- a/.docker/Dockerfile +++ b/.docker/Dockerfile @@ -13,5 +13,7 @@ RUN git clone --depth 1 https://github.com/php/phd.git && \ RUN echo 'memory_limit = 512M' >> /usr/local/etc/php/conf.d/local.ini +ENV FORMAT=xhtml + CMD php doc-base/configure.php --disable-segfault-error && \ - php phd/render.php --docbook doc-base/.manual.xml --output=/var/www/en/output --package PHP --format xhtml + php phd/render.php --docbook doc-base/.manual.xml --output=/var/www/en/output --package PHP --format ${FORMAT} diff --git a/.gitignore b/.gitignore index 8e0450061c78..15671bf14950 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ entities.*.xml output +.docker/built diff --git a/Makefile b/Makefile new file mode 100644 index 000000000000..ef6219ccd6d7 --- /dev/null +++ b/Makefile @@ -0,0 +1,32 @@ +.PHONY: * + +SHELL = /bin/sh + +CURRENT_UID := $(shell id -u) +CURRENT_GID := $(shell id -g) + +# +# If doc-base or phd exist as siblings to the current directory, add those as +# volumes to our Docker runs. +# + +PATHS := -v .:/var/www/en +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 + +xhtml: .docker/built + docker run ${PATHS} -w /var/www -u ${CURRENT_UID}:${CURRENT_GID} php/doc-en + +php: .docker/built + docker run ${PATHS} -w /var/www -u ${CURRENT_UID}:${CURRENT_GID} \ + -e FORMAT=php php/doc-en + +build: .docker/built + +.docker/built: + docker build .docker -t php/doc-en + touch .docker/built diff --git a/README.md b/README.md index 3ef11ddcb1e8..ad377f28f220 100644 --- a/README.md +++ b/README.md @@ -15,12 +15,22 @@ For information related to creating this setup, see the [contribution guidelines](https://github.com/php/doc-base/blob/master/CONTRIBUTING_DOCS.md) or [this page](http://doc.php.net/tutorial/local-setup.php) on our documentation website. -## Running With Docker +## Building With make and Docker - Install Docker (https://docs.docker.com/get-docker/) -- Rebuild the documentation using `docker-compose up` +- Rebuild the documentation using `make` - Open output/php-chunked-xhtml/ in your browser. +If the `doc-base` or `phd` repositories are available in directories to the +adjacent to this directory, those will be used for building. + +To force the Docker image used for building to itself be rebuilt, you can run +`make -B build`, otherwise the `Makefile` will only build it if does not +already exist. + +You can also build the `web` version of the documentation with `make php` +and the output will be placed in output/php-web + ## Translations For the translations of this documentation, see: diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index f3cec69bcea6..000000000000 --- a/docker-compose.yml +++ /dev/null @@ -1,8 +0,0 @@ -version: '3' - -services: - doc: - build: .docker - working_dir: /var/www - volumes: - - .:/var/www/en