From 5442b0ab4f5da28083291841beb3395894db3452 Mon Sep 17 00:00:00 2001 From: Arve Knudsen Date: Tue, 28 Apr 2020 09:27:46 +0200 Subject: [PATCH] Docs: Fix building of docs (#23923) * Docs: Fix building of docs * CircleCI: Fixate grafana/docs-base image revision in job for building docs --- .circleci/config.yml | 22 +++++++++++----------- docs/Makefile | 13 +++++-------- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index fb1f7e0012c..df236165148 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -840,7 +840,6 @@ jobs: build-docs-website: executor: grafana-build - working_directory: /docs steps: - checkout - setup_remote_docker @@ -853,22 +852,23 @@ jobs: apt-get update apt-get install -y docker.io - run: - name: Build grafana docs website + name: Build Grafana docs website command: | - # https://circleci.com/docs/2.0/building-docker-images/#mounting-folders - # create a dummy container which will hold a volume with config - docker create -v /hugo/content/docs/grafana --name docs-website alpine:3.4 /bin/true - # copy a config file into this volume - docker cp ${PWD}/docs/sources docs-website:/hugo/content/docs/grafana/latest - # start an application container using this volume - docker run --volumes-from docs-website --rm -it grafana/docs-base:latest /bin/bash -c 'npm i && make prod' + IMAGE=grafana/docs-base@sha256:63758b74e3990ab61e274f5e98da092d5c38378829dad0488aa97c59f0144f34 + + # In order to copy sources into the remote container, we need to employ a trick of creating a container + # with a volume, that we copy the sources into. Then, we launch the build container, with the volume + # from the other container + docker create -v /hugo/content/docs/grafana --name docs alpine:3.11 /bin/true + docker cp ${PWD}/docs/sources docs:/hugo/content/docs/grafana/latest + docker run --volumes-from docs $IMAGE /bin/bash -c 'make prod' - run: name: CI job failed - command: "docker stop docs-website && docker rm docs-website && ./scripts/ci-job-failed.sh" + command: "./scripts/ci-job-failed.sh" when: on_fail - run: name: CI job succeeded - command: "docker stop docs-website && docker rm docs-website && ./scripts/ci-job-succeeded.sh" + command: "./scripts/ci-job-succeeded.sh" when: on_success deploy-to-kubernetes: diff --git a/docs/Makefile b/docs/Makefile index 2c1b8574372..e88c9d276f0 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -1,12 +1,9 @@ -.PHONY: docs docs-no-pull docs-test +.PHONY: docs docs-test + +IMAGE = grafana/docs-base@sha256:63758b74e3990ab61e274f5e98da092d5c38378829dad0488aa97c59f0144f34 docs: - docker pull grafana/docs-base:latest - docker run -v $(PWD)/sources:/hugo/content/docs/grafana/latest -p 3002:3002 --rm -it grafana/docs-base:latest /bin/bash -c 'npm i && make webpack && make docs-menu && hugo server -p 3002 -D --ignoreCache --baseUrl http://localhost:3002 --bind 0.0.0.0' - -docs-no-pull: - docker run -v $(PWD)/sources:/hugo/content/docs/grafana/latest -p 3002:3002 --rm -it grafana/docs-base:latest /bin/bash -c 'make docs-menu && hugo server -p 3002 -D --ignoreCache --baseUrl http://localhost:3002 --bind 0.0.0.0' + docker run -v $(shell pwd)/sources:/hugo/content/docs/grafana/latest -p 3002:3002 --rm -it $(IMAGE) /bin/bash -c 'make server' docs-test: - docker pull grafana/docs-base:latest - docker run -v $(PWD)/sources:/hugo/content/docs/grafana/latest --rm -it grafana/docs-base:latest /bin/bash -c 'npm i && make prod' + docker run -v $(shell pwd)/sources:/hugo/content/docs/grafana/latest --rm -it $(IMAGE) /bin/bash -c 'make prod'