Skip to content

Commit 4ed1a3f

Browse files
committed
Start using docker-compose and watch the changed files to simplify docs development.
1 parent a2846b9 commit 4ed1a3f

File tree

5 files changed

+39
-20
lines changed

5 files changed

+39
-20
lines changed

Dockerfile

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
FROM python:2-stretch as builder
22

3-
WORKDIR /www
4-
53
COPY ./_build/.requirements.txt _build/
64

75
RUN pip install pip==9.0.1 wheel==0.29.0 \
86
&& pip install -r _build/.requirements.txt
97

10-
COPY . /www
8+
EXPOSE 8000
119

12-
RUN make -C _build html
10+
VOLUME /www
1311

14-
FROM nginx:latest
12+
WORKDIR /www/_build
1513

16-
COPY --from=builder /www/_build/html /usr/share/nginx/html
14+
CMD make html && make livehtml

_build/.requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ requests==2.20.0
1010
six==1.10.0
1111
snowballstemmer==1.2.1
1212
sphinx==1.3.6
13+
sphinx-autobuild==0.6.0
1314
git+https://github.com/fabpot/sphinx-php.git@v1.0.14#egg_name=sphinx-php

_build/Makefile

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22
#
33

44
# You can set these variables from the command line.
5-
SPHINXOPTS =
6-
SPHINXBUILD = sphinx-build
7-
PAPER =
8-
BUILDDIR = .
5+
SPHINXOPTS =
6+
SPHINXBUILD = sphinx-build
7+
PAPER =
8+
BUILDDIR = .
9+
SPHINXAUTOBUILD = sphinx-autobuild
10+
IGNOREWATCH= --ignore "/www/_build" \
11+
--ignore "/www/.idea"
912

1013
# Internal variables.
1114
PAPEROPT_a4 = -D latex_paper_size=a4
@@ -14,7 +17,7 @@ ALLSPHINXOPTS = -c $(BUILDDIR) -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(
1417
# the i18n builder cannot share the environment and doctrees with the others
1518
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
1619

17-
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
20+
.PHONY: help clean html livehtml dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
1821

1922
help:
2023
@echo "Please use \`make <target>' where <target> is one of"
@@ -37,6 +40,7 @@ help:
3740
@echo " changes to make an overview of all changed/added/deprecated items"
3841
@echo " linkcheck to check all external links for integrity"
3942
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
43+
@echo " livehtml to keep recreating the files that are changed"
4044

4145
clean:
4246
-rm -rf $(BUILDDIR)/*
@@ -151,3 +155,9 @@ doctest:
151155
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
152156
@echo "Testing of doctests in the sources finished, look at the " \
153157
"results in $(BUILDDIR)/doctest/output.txt."
158+
159+
livehtml:
160+
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
161+
$(SPHINXAUTOBUILD) --host 0.0.0.0 --port 8000 --watch /www -b html $(ALLSPHINXOPTS) $(IGNOREWATCH) /www/_build/html
162+
@echo
163+
@echo "Listening to changes and rebuilding files"

contributing/documentation/overview.rst

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -249,21 +249,20 @@ GitHub, click on the **Show all checks** link and finally, click on the
249249
Build the Documentation Locally
250250
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
251251

252-
If you have Docker installed on your machine, run these commands to build the
253-
docs:
252+
If you have Docker installed on your machine, this command will build
253+
the image, compile the docs, and start to watch for changes and
254+
automatically compile them:
254255

255256
.. code-block:: terminal
256257
257-
# build the image...
258-
$ docker build . -t symfony-docs
258+
$ docker-compose up
259259
260-
# ...and start the local web server
261-
# (if it's already in use, change the '8080' port by any other port)
262-
$ docker run --rm -p 8080:80 symfony-docs
263-
264-
You can now read the docs at ``http://127.0.0.1:8080`` (if you use a virtual
260+
You can now read the docs at ``http://localhost:8080`` (if you use a virtual
265261
machine, browse its IP instead of localhost; e.g. ``http://192.168.99.100:8080``).
266262

263+
If por `8080` is already in use, you can change the mapping on `docker-compose.yaml`
264+
file to any other free port.
265+
267266
If you don't use Docker, follow these steps to build the docs locally:
268267

269268
#. Install `pip`_ as explained in the `pip installation`_ article;

docker-compose.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: '3.3'
2+
services:
3+
symfony-docs:
4+
build:
5+
context: ./
6+
image: symfony-docs:latest
7+
user: ${CURRENT_UID}
8+
ports:
9+
- 8080:8000
10+
volumes:
11+
- .:/www

0 commit comments

Comments
 (0)