Skip to content

Commit ddd8e58

Browse files
ci: Build docs with docker
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 ddd8e58

4 files changed

Lines changed: 50 additions & 20 deletions

File tree

‎.dockerignore‎

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

1013
**/__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: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,52 @@
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 deps
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
12-
COPY . .
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+
COPY setup.py .
1315
RUN pip install .
1416

15-
FROM build-image AS test-image
17+
# =========
18+
FROM deps AS dev
1619

20+
COPY requirements-dev.txt .
1721
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
2222

23-
FROM base-image AS runtime-image
23+
# =========
24+
FROM dev AS docs
25+
26+
COPY docs ./docs
27+
COPY CONTRIBUTING.md mkdocs.yml ./
28+
RUN mkdocs build
29+
30+
# =========
31+
FROM scratch AS docs-site
32+
33+
COPY --from=docs /workdir/site /site
34+
35+
# =========
36+
FROM dev AS test
37+
38+
COPY . .
39+
RUN pip install .
40+
RUN make checks
41+
42+
# =========
43+
FROM deps AS install
44+
45+
COPY . .
46+
RUN pip install .
47+
48+
# =========
49+
FROM base as final
2450

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

‎Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ coverage:
2828
checks: format-check lint mypy test
2929

3030
image:
31-
docker build -t gitopscli:latest .
31+
DOCKER_BUILDKIT=1 docker build -t gitopscli:latest .
3232

3333
docs:
3434
mkdocs serve

0 commit comments

Comments
 (0)