From e2519cd43dad522cb8439b182b41733eb25e3cff Mon Sep 17 00:00:00 2001 From: Jonathan Budzenski Date: Mon, 14 Dec 2020 13:59:01 -0600 Subject: [PATCH 1/2] [build] Replace grunt docker:docs with script Part of a larger effort to remote our grunt depdencies, #85341. --- scripts/docker_docs.js | 21 ++++++++ {tasks => src/dev}/docker_docs/Dockerfile | 0 .../dev}/docker_docs/docker-compose.yml | 2 +- src/dev/docker_docs/run_docker_docs.js | 52 ++++++++++++++++++ tasks/docker_docs.js | 53 ------------------- test/scripts/jenkins_docs.sh | 2 +- 6 files changed, 75 insertions(+), 55 deletions(-) create mode 100644 scripts/docker_docs.js rename {tasks => src/dev}/docker_docs/Dockerfile (100%) rename {tasks => src/dev}/docker_docs/docker-compose.yml (75%) create mode 100644 src/dev/docker_docs/run_docker_docs.js delete mode 100644 tasks/docker_docs.js diff --git a/scripts/docker_docs.js b/scripts/docker_docs.js new file mode 100644 index 0000000000000..fc17f00944a7b --- /dev/null +++ b/scripts/docker_docs.js @@ -0,0 +1,21 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +require('../src/setup_node_env'); +require('../src/dev/docker_docs/run_docker_docs'); diff --git a/tasks/docker_docs/Dockerfile b/src/dev/docker_docs/Dockerfile similarity index 100% rename from tasks/docker_docs/Dockerfile rename to src/dev/docker_docs/Dockerfile diff --git a/tasks/docker_docs/docker-compose.yml b/src/dev/docker_docs/docker-compose.yml similarity index 75% rename from tasks/docker_docs/docker-compose.yml rename to src/dev/docker_docs/docker-compose.yml index 8d0bd2c136596..c5b6be6786a2c 100644 --- a/tasks/docker_docs/docker-compose.yml +++ b/src/dev/docker_docs/docker-compose.yml @@ -3,6 +3,6 @@ services: kibana_docs: container_name: $KIBANA_DOCS_CONTAINER_NAME build: - context: $KIBANA_DOCS_CONTEXT/tasks/docker_docs + context: $KIBANA_DOCS_CONTEXT/src/dev/docker_docs volumes: - $KIBANA_DOCS_CONTEXT/docs:/home/kibana/ascii_docs diff --git a/src/dev/docker_docs/run_docker_docs.js b/src/dev/docker_docs/run_docker_docs.js new file mode 100644 index 0000000000000..cdede0a80e5a0 --- /dev/null +++ b/src/dev/docker_docs/run_docker_docs.js @@ -0,0 +1,52 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import del from 'del'; +import { run } from '@kbn/dev-utils'; +import { join, resolve } from 'path'; +import { execFileSync as exec } from 'child_process'; + +run(async ({ log }) => { + const rootPath = resolve(__dirname, '..', '..', '..'); + const composePath = join(rootPath, 'src/dev/docker_docs/docker-compose.yml'); + const htmlDocsDir = join(rootPath, 'html_docs'); + + const env = Object.assign(process.env, { + KIBANA_DOCS_CONTAINER_NAME: 'kibana_docs', + KIBANA_DOCS_CONTEXT: rootPath, + }); + const stdio = [0, 1, 2]; + const execOptions = { env, stdio }; + + exec('docker-compose', ['-f', composePath, 'up'], execOptions); + + const containerId = String( + exec('docker-compose', ['-f', composePath, 'ps', '-q', env.KIBANA_DOCS_CONTAINER_NAME], { + env, + }) + ).trim(); + + log.debug('Clearing old docs ... '); + del.sync(htmlDocsDir); + log.debug('done'); + + log.debug('Copying new docs ... '); + exec('docker', ['cp', `${containerId}:/home/kibana/html_docs`, htmlDocsDir]); + log.debug('done'); +}); diff --git a/tasks/docker_docs.js b/tasks/docker_docs.js deleted file mode 100644 index 3a2041abc9301..0000000000000 --- a/tasks/docker_docs.js +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import del from 'del'; -import { join } from 'path'; -import { execFileSync as exec } from 'child_process'; - -export default function (grunt) { - grunt.registerTask('docker:docs', 'Build docs from docker', function () { - const rootPath = grunt.config.get('root'); - const composePath = join(rootPath, 'tasks/docker_docs/docker-compose.yml'); - const htmlDocsDir = join(rootPath, 'html_docs'); - - const env = Object.assign(process.env, { - KIBANA_DOCS_CONTAINER_NAME: 'kibana_docs', - KIBANA_DOCS_CONTEXT: rootPath, - }); - const stdio = [0, 1, 2]; - const execOptions = { env, stdio }; - - exec('docker-compose', ['-f', composePath, 'up'], execOptions); - - const containerId = String( - exec('docker-compose', ['-f', composePath, 'ps', '-q', env.KIBANA_DOCS_CONTAINER_NAME], { - env, - }) - ).trim(); - - grunt.log.write('Clearing old docs ... '); - del.sync(htmlDocsDir); - grunt.log.writeln('done'); - - grunt.log.write('Copying new docs ... '); - exec('docker', ['cp', `${containerId}:/home/kibana/html_docs`, htmlDocsDir]); - grunt.log.writeln('done'); - }); -} diff --git a/test/scripts/jenkins_docs.sh b/test/scripts/jenkins_docs.sh index f447afda1f948..6f46115fbac7a 100755 --- a/test/scripts/jenkins_docs.sh +++ b/test/scripts/jenkins_docs.sh @@ -3,4 +3,4 @@ set -e source "$(dirname $0)/../../src/dev/ci_setup/setup.sh" -"$(FORCE_COLOR=0 yarn bin)/grunt" docker:docs; +node scripts/docker_docs From b592b7e5b30979ff32101af7a1173028ff7b4dab Mon Sep 17 00:00:00 2001 From: Jonathan Budzenski Date: Mon, 14 Dec 2020 14:56:46 -0600 Subject: [PATCH 2/2] rm docker docs --- scripts/docker_docs.js | 21 ----------- src/dev/docker_docs/Dockerfile | 18 --------- src/dev/docker_docs/docker-compose.yml | 8 ---- src/dev/docker_docs/run_docker_docs.js | 52 -------------------------- test/scripts/jenkins_docs.sh | 6 --- 5 files changed, 105 deletions(-) delete mode 100644 scripts/docker_docs.js delete mode 100644 src/dev/docker_docs/Dockerfile delete mode 100644 src/dev/docker_docs/docker-compose.yml delete mode 100644 src/dev/docker_docs/run_docker_docs.js delete mode 100755 test/scripts/jenkins_docs.sh diff --git a/scripts/docker_docs.js b/scripts/docker_docs.js deleted file mode 100644 index fc17f00944a7b..0000000000000 --- a/scripts/docker_docs.js +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -require('../src/setup_node_env'); -require('../src/dev/docker_docs/run_docker_docs'); diff --git a/src/dev/docker_docs/Dockerfile b/src/dev/docker_docs/Dockerfile deleted file mode 100644 index 435b78f89f2e7..0000000000000 --- a/src/dev/docker_docs/Dockerfile +++ /dev/null @@ -1,18 +0,0 @@ -FROM alpine:3.6 - -RUN apk add --no-cache \ - git \ - libxslt \ - curl \ - python \ - libxml2-utils \ - perl - -RUN addgroup kibana && \ - adduser -D -G kibana -s /bin/bash -h /home/kibana kibana - -USER kibana -RUN git clone --depth 1 https://github.com/elastic/docs.git /home/kibana/docs_builder - -WORKDIR /home/kibana/docs_builder -CMD git pull origin master && ./build_docs.pl --doc /home/kibana/ascii_docs/index.asciidoc --out /home/kibana/html_docs --chunk=1 diff --git a/src/dev/docker_docs/docker-compose.yml b/src/dev/docker_docs/docker-compose.yml deleted file mode 100644 index c5b6be6786a2c..0000000000000 --- a/src/dev/docker_docs/docker-compose.yml +++ /dev/null @@ -1,8 +0,0 @@ -version: '2' -services: - kibana_docs: - container_name: $KIBANA_DOCS_CONTAINER_NAME - build: - context: $KIBANA_DOCS_CONTEXT/src/dev/docker_docs - volumes: - - $KIBANA_DOCS_CONTEXT/docs:/home/kibana/ascii_docs diff --git a/src/dev/docker_docs/run_docker_docs.js b/src/dev/docker_docs/run_docker_docs.js deleted file mode 100644 index cdede0a80e5a0..0000000000000 --- a/src/dev/docker_docs/run_docker_docs.js +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import del from 'del'; -import { run } from '@kbn/dev-utils'; -import { join, resolve } from 'path'; -import { execFileSync as exec } from 'child_process'; - -run(async ({ log }) => { - const rootPath = resolve(__dirname, '..', '..', '..'); - const composePath = join(rootPath, 'src/dev/docker_docs/docker-compose.yml'); - const htmlDocsDir = join(rootPath, 'html_docs'); - - const env = Object.assign(process.env, { - KIBANA_DOCS_CONTAINER_NAME: 'kibana_docs', - KIBANA_DOCS_CONTEXT: rootPath, - }); - const stdio = [0, 1, 2]; - const execOptions = { env, stdio }; - - exec('docker-compose', ['-f', composePath, 'up'], execOptions); - - const containerId = String( - exec('docker-compose', ['-f', composePath, 'ps', '-q', env.KIBANA_DOCS_CONTAINER_NAME], { - env, - }) - ).trim(); - - log.debug('Clearing old docs ... '); - del.sync(htmlDocsDir); - log.debug('done'); - - log.debug('Copying new docs ... '); - exec('docker', ['cp', `${containerId}:/home/kibana/html_docs`, htmlDocsDir]); - log.debug('done'); -}); diff --git a/test/scripts/jenkins_docs.sh b/test/scripts/jenkins_docs.sh deleted file mode 100755 index 6f46115fbac7a..0000000000000 --- a/test/scripts/jenkins_docs.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash - -set -e -source "$(dirname $0)/../../src/dev/ci_setup/setup.sh" - -node scripts/docker_docs