Skip to content

Commit

Permalink
Merge pull request #17 from hoatle/features/#13-docker-workflow
Browse files Browse the repository at this point in the history
@ #13 | should support Docker workflow
  • Loading branch information
hoatle authored Feb 27, 2019
2 parents e28508f + 153a790 commit e09180f
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 0 deletions.
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ For deploying with heroku only.

For auto-building the documentation when a change is detected thanks to https://pypi.org/project/sphinx-autobuild/

**10. `$ make build_docker_image`**

To build the production docker image for the docs site, for example:

```
$ make build_docker_image DOCKER_IMG_TAG=company/project-docs:develop
```


Installation
------------
Expand Down Expand Up @@ -105,6 +113,27 @@ c.. To build with `travis-ci`, you need to copy these following files to your ro
- `.travis/setup.sh`


Auto-build with docker-compose
------------------------------

Make sure `docker` and `docker-compose` are installed and running.

```bash
$ docker-compose up -d
$ echo open http://localhost:`docker port docs_docs_1 80 | grep -o [0-9]*$` to view the docs
open http://localhost:32770 to view the docs
```

Check the output from the command above to open the docs site. The docs site will auto reload when
changes are made to the docs files.

To see the docs site logs, execute the following command:

```bash
$ docker-compose logs -f docs
```


Configuration
-------------

Expand Down Expand Up @@ -186,6 +215,12 @@ ifndef REPO_URL_HEROKU
# REPO_URL_HEROKU = [email protected]:spxd.git
endif

## -- Docker Config -- ##

ifndef DOCKER_IMG_TAG
# Configure your default docker image tag
DOCKER_IMG_TAG = sphinx-deployment/docs:develop
endif

## end deployment configuration, don't edit anything below this line ##
#######################################################################
Expand Down
41 changes: 41 additions & 0 deletions docs/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
ARG PYTHON_VERSION=3.6
ARG NGINX_VERSION=1.13

#building
FROM python:$PYTHON_VERSION as builder

RUN mkdir -p /opt/app

ENV TERM=xterm-256color APP=/opt/app

WORKDIR $APP

ADD requirements.txt $APP/

RUN pip install -r requirements.txt

ADD . $APP

RUN make html

# packaging
FROM nginx:$NGINX_VERSION

LABEL authors="hoatle <[email protected]>"

RUN mkdir -p /opt/app

ENV TERM=xterm APP=/opt/app

WORKDIR $APP

# add more arguments from CI to the image so that `$ env` should reveal more info
ARG CI_BUILD_ID
ARG CI_BUILD_REF
ARG CI_REGISTRY_IMAGE
ARG CI_BUILD_TIME

ENV CI_BUILD_ID=$CI_BUILD_ID CI_BUILD_REF=$CI_BUILD_REF CI_REGISTRY_IMAGE=$CI_REGISTRY_IMAGE \
CI_BUILD_TIME=$CI_BUILD_TIME

COPY --from=builder /opt/app/_build/html /usr/share/nginx/html
17 changes: 17 additions & 0 deletions docs/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: '3'

services:

# how to use:
# $ docker-compose up -d
# $ echo open http://localhost:`docker port docs_docs_1 80 | grep -o [0-9]*$` to view the docs
# open http://localhost:32770 to view the docs
docs:
image: python:3.6
working_dir: /opt/app
command: sh run-dev.sh
restart: unless-stopped
ports:
- "80"
volumes:
- .:/opt/app
5 changes: 5 additions & 0 deletions docs/run-dev.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

pip install -r requirements.txt

make livehtml
13 changes: 13 additions & 0 deletions docs/sphinx_deployment.mk
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,14 @@ ifndef REPO_URL_HEROKU
endif


## -- Docker Config -- ##

ifndef DOCKER_IMG_TAG
# Configure your default docker image tag
DOCKER_IMG_TAG = sphinx-deployment/docs:develop
endif


## end deployment configuration, don't edit anything below this line ##
#######################################################################

Expand Down Expand Up @@ -204,3 +212,8 @@ gen_deploy: generate deploy
# `$ make livehtml` to auto-build the documentation when a change is detected
livehtml:
sphinx-autobuild -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html -H 0.0.0.0 --port 80

# for example: `$ make build_docker_image DOCKER_IMG_TAG=company/project-docs:develop`
build_docker_image:
@echo "docker build -t $(DOCKER_IMG_TAG) -f Dockerfile ."
docker build -t $(DOCKER_IMG_TAG) -f Dockerfile .

0 comments on commit e09180f

Please sign in to comment.