Skip to content

Commit 64a3c9d

Browse files
ci: Build docs with docker (#183)
We're having odd errors in the travis python runner that I cannot reproduce locally. Solution: Build docs with docker build. With the BuildKit backend it's quite easy to `--output` the site directory.
1 parent d486144 commit 64a3c9d

File tree

6 files changed

+60
-26
lines changed

6 files changed

+60
-26
lines changed

.dockerignore

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
*
2+
!docs
23
!gitopscli/
34
!tests/
45
!.pylintrc
6+
!CONTRIBUTING.md
7+
!mkdocs.yml
8+
!Makefile
59
!mypy.ini
6-
!requirements-dev.txt
7-
!requirements.txt
10+
!requirements-docs.txt
11+
!requirements-test.txt
812
!setup.py
913

1014
**/__pycache__/

.travis.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ language: shell
55
env:
66
global:
77
- DOCKER_IMAGE: baloise/gitopscli
8+
- DOCKER_BUILDKIT: '1' # use BuildKit backend (https://docs.docker.com/engine/reference/builder/#buildkit)
9+
- BUILDKIT_PROGRESS: plain
810
# DOCKER_USERNAME
911
- secure: "Ecq9r+yXVc9gVdn1e4sDS/yegMKOyN3F6f4jxNSNl1pEkBZayVOvl6seh58sK+QzaIOLlrMYNlOzmWIKaekRuskYLJNYMUh67RJB24knOMSbA0hD3WPO8GbFY1Y/Xe1Gk5zKlLqFKe9OoCbM0ItGIXL2DrFPWl94F1YoZim2h7q6lFEo9NHvYSjreGMcqJujQKoN5/UkO76C3TEKNFXbyxev18nHwXQvqC2axbZONYEQuzYC7dDDAHRMxQ25t2qcWh19f/ssl0qR7VYheBY72Pypvl131+qIxaMl+r/7UeKHnhrM2/ineyo8VPfxhHwar31ldu0YyC0KtSYEMERASsKmJNyaP9d3mo6Vciws/8fGaU0FqlwfRPOhaa/ixMS43qJ4NS9vSogteQJVIIC4B9mHmFvzShDK5aDML+KJ0ehQnayS/30AywS80iSkSWdbkKPAdr+djVhUbey+LAWPVdmJOnIiBET4eSFqJ37dXmcKrhUcfrthL2SftkTGZ4Fm4gHPNYWXIej9N6kTwHlYzRkuJN3PNTLsqp9YE6dUYIUZEu0qkyX2IBljdOxLK5UTKzdkD+j8kLFEP2kN1ELbhP4qEBJj17swycTP9wR4RB+FfjsdeTXonaEOGq8z2CctnczJe87TJ1/GuRj5l/VXiK2ph25El/Axhg5Kv3lHxJw="
1012
# DOCKER_PASSWORD
@@ -17,12 +19,11 @@ jobs:
1719
- stage: test
1820
language: shell
1921
services: docker
20-
script: docker build .
22+
script: docker build --target=test .
2123
- stage: doc
22-
language: python
23-
python: 3.6
24-
install: pip install -r requirements-dev.txt
25-
script: mkdocs build
24+
language: shell
25+
services: docker
26+
script: docker build --target=docs-site --output . .
2627
deploy:
2728
provider: pages
2829
strategy: git

Dockerfile

Lines changed: 41 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,54 @@
1-
FROM python:3.8-alpine AS base-image
1+
# =========
2+
FROM python:3.8-alpine AS base
23

34
ENV PATH="/opt/venv/bin:$PATH"
45
RUN apk add --no-cache git
56

6-
FROM base-image AS build-image
7+
# =========
8+
FROM base AS dev
79

8-
RUN apk add --no-cache gcc linux-headers musl-dev \
9-
&& python -m venv /opt/venv \
10-
&& pip install --upgrade pip
1110
WORKDIR /workdir
11+
RUN apk add --no-cache gcc linux-headers musl-dev make
12+
RUN python -m venv /opt/venv
13+
RUN pip install --upgrade pip
14+
15+
# =========
16+
FROM dev AS deps
17+
18+
COPY setup.py .
19+
RUN pip install .
20+
21+
# =========
22+
FROM deps AS test
23+
24+
COPY requirements-test.txt .
25+
RUN pip install -r requirements-test.txt
1226
COPY . .
1327
RUN pip install .
28+
RUN make checks
29+
30+
# =========
31+
FROM dev AS docs
1432

15-
FROM build-image AS test-image
33+
COPY requirements-docs.txt .
34+
RUN pip install -r requirements-docs.txt
35+
COPY docs ./docs
36+
COPY CONTRIBUTING.md mkdocs.yml ./
37+
RUN mkdocs build
1638

17-
RUN pip install -r requirements-dev.txt
18-
RUN black --check -l 120 -t py37 gitopscli tests setup.py
19-
RUN pylint gitopscli
20-
RUN mypy .
21-
RUN python -m pytest -vv -s --typeguard-packages=gitopscli
39+
# =========
40+
FROM scratch AS docs-site
41+
42+
COPY --from=docs /workdir/site /site
43+
44+
# =========
45+
FROM deps AS install
46+
47+
COPY . .
48+
RUN pip install .
2249

23-
FROM base-image AS runtime-image
50+
# =========
51+
FROM base as final
2452

25-
COPY --from=build-image /opt/venv /opt/venv
53+
COPY --from=install /opt/venv /opt/venv
2654
ENTRYPOINT ["gitopscli"]

Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ BLACK_ARGS = -l 120 -t py37 gitopscli tests setup.py
22

33
init:
44
pip3 install --editable .
5-
pip3 install -r requirements-dev.txt
5+
pip3 install -r requirements-test.txt
6+
pip3 install -r requirements-docs.txt
67
pre-commit install
78

89
format:
@@ -28,7 +29,7 @@ coverage:
2829
checks: format-check lint mypy test
2930

3031
image:
31-
docker build -t gitopscli:latest .
32+
DOCKER_BUILDKIT=1 docker build --progress=plain -t gitopscli:latest .
3233

3334
docs:
3435
mkdocs serve

requirements-docs.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
mkdocs==1.3.0
2+
mkdocs-material==8.2.12
3+
markdown-include==0.6.0
4+
pymdown-extensions==9.4
Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@ black==22.3.0
22
coverage==5.3
33
pylint==2.4.4
44
pytest==5.4.2
5-
mkdocs==1.3.0
6-
mkdocs-material==8.2.12
7-
markdown-include==0.6.0
8-
pymdown-extensions==9.4
95
mypy==0.790
106
typeguard==2.10.0
117
pre-commit==2.13.0

0 commit comments

Comments
 (0)