Skip to content

Commit

Permalink
Use Makefile instead of docker-compose.yml (php#3673)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
jimwins authored Sep 3, 2024
1 parent ffc4b7a commit 1ef0cab
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 11 deletions.
4 changes: 3 additions & 1 deletion .docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
entities.*.xml
output
.docker/built
32 changes: 32 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 0 additions & 8 deletions docker-compose.yml

This file was deleted.

0 comments on commit 1ef0cab

Please sign in to comment.