Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Separate server to run documentation
#!/usr/bin/env node
/*
* Raman Marozau <engineer.morozov@gmail.com>, 2019-present
*/
const {
execAction,
stop,
Logger,
EMPTY_LINE,
ANSI_FG_GREEN,
ANSI_FG_NC,
} = require('@softeq/utils');
const { exec, execSync } = require('child_process');
const fs = require('fs');
const DOCKER_COMPOSE_FILE_PATH = `${__dirname}/../docs.docker-compose.yml`;
const DOCKER_COMPOSE_FILE_PATH_DEFAULT = `${__dirname}/../docker-compose.yml`;
const DOCKER_CONTAINER_NAME = 'docs.nginx';
const DOCKER_SERVER_PORT = 7837;
if (!fs.existsSync(DOCKER_COMPOSE_FILE_PATH)) {
Logger.error(`${DOCKER_COMPOSE_FILE_PATH} DOES NOT exist.${EMPTY_LINE}`);
}
exec(`docker stop ${DOCKER_CONTAINER_NAME} && docker rm ${DOCKER_CONTAINER_NAME}`, execAction((_, __, err) => {
if (err && !err.message.includes(`No such container: ${DOCKER_CONTAINER_NAME}`)) {
Logger.error(err);
}
execSync(`docker-compose --file ${DOCKER_COMPOSE_FILE_PATH_DEFAULT} --file ${DOCKER_COMPOSE_FILE_PATH} up --build -d`);
Logger.stack([[`${ANSI_FG_GREEN}%s${ANSI_FG_NC}`, `${EMPTY_LINE}Documentation server: http://localhost:${DOCKER_SERVER_PORT}${EMPTY_LINE}`]]);
}, { error: false, stderr: false }));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.