|
| 1 | +/* |
| 2 | + * Licensed to Elasticsearch B.V. under one or more contributor |
| 3 | + * license agreements. See the NOTICE file distributed with |
| 4 | + * this work for additional information regarding copyright |
| 5 | + * ownership. Elasticsearch B.V. licenses this file to you under |
| 6 | + * the Apache License, Version 2.0 (the "License"); you may |
| 7 | + * not use this file except in compliance with the License. |
| 8 | + * You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, |
| 13 | + * software distributed under the License is distributed on an |
| 14 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | + * KIND, either express or implied. See the License for the |
| 16 | + * specific language governing permissions and limitations |
| 17 | + * under the License. |
| 18 | + */ |
| 19 | + |
| 20 | +import del from 'del'; |
| 21 | +import { run } from '@kbn/dev-utils'; |
| 22 | +import { join, resolve } from 'path'; |
| 23 | +import { execFileSync as exec } from 'child_process'; |
| 24 | + |
| 25 | +run(async ({ log }) => { |
| 26 | + const rootPath = resolve(__dirname, '..', '..', '..'); |
| 27 | + const composePath = join(rootPath, 'src/dev/docker_docs/docker-compose.yml'); |
| 28 | + const htmlDocsDir = join(rootPath, 'html_docs'); |
| 29 | + |
| 30 | + const env = Object.assign(process.env, { |
| 31 | + KIBANA_DOCS_CONTAINER_NAME: 'kibana_docs', |
| 32 | + KIBANA_DOCS_CONTEXT: rootPath, |
| 33 | + }); |
| 34 | + const stdio = [0, 1, 2]; |
| 35 | + const execOptions = { env, stdio }; |
| 36 | + |
| 37 | + exec('docker-compose', ['-f', composePath, 'up'], execOptions); |
| 38 | + |
| 39 | + const containerId = String( |
| 40 | + exec('docker-compose', ['-f', composePath, 'ps', '-q', env.KIBANA_DOCS_CONTAINER_NAME], { |
| 41 | + env, |
| 42 | + }) |
| 43 | + ).trim(); |
| 44 | + |
| 45 | + log.debug('Clearing old docs ... '); |
| 46 | + del.sync(htmlDocsDir); |
| 47 | + log.debug('done'); |
| 48 | + |
| 49 | + log.debug('Copying new docs ... '); |
| 50 | + exec('docker', ['cp', `${containerId}:/home/kibana/html_docs`, htmlDocsDir]); |
| 51 | + log.debug('done'); |
| 52 | +}); |
0 commit comments