Adds a flag to the cli to override the entrypoint of a custom docker image. It could be used to reuse existing images with different eentrypoints.

Signed-off-by: Carlo Colombo <carlo.colombo@klarna.com>
This commit is contained in:
Carlo Colombo
2022-03-23 17:44:48 +01:00
parent 7fae0c07e9
commit eb470ea54c
6 changed files with 26 additions and 6 deletions
@@ -206,6 +206,10 @@ export function registerCommands(program: CommanderStatic) {
'The mkdocs docker container to use',
defaultDockerImage,
)
.option(
'--docker-entrypoint <DOCKER_ENTRYPOINT>',
'Override the image entrypoint',
)
.option(
'--no-docker',
'Do not use Docker, run `mkdocs serve` in current user environment.',
@@ -224,6 +228,10 @@ export function registerCommands(program: CommanderStatic) {
'The mkdocs docker container to use',
defaultDockerImage,
)
.option(
'--docker-entrypoint <DOCKER_ENTRYPOINT>',
'Override the image entrypoint',
)
.option(
'--no-docker',
'Do not use Docker, use MkDocs executable in current user environment.',
@@ -61,6 +61,7 @@ export default async function serveMkdocs(cmd: Command) {
const childProcess = await runMkdocsServer({
port: cmd.port,
dockerImage: cmd.dockerImage,
dockerEntrypoint: cmd.dockerEntrypoint,
useDocker: cmd.docker,
stdoutLogFunc: logFunc,
stderrLogFunc: logFunc,
@@ -90,6 +90,7 @@ export default async function serve(cmd: Command) {
const mkdocsChildProcess = await runMkdocsServer({
port: cmd.mkdocsPort,
dockerImage: cmd.dockerImage,
dockerEntrypoint: cmd.dockerEntrypoint,
useDocker: cmd.docker,
stdoutLogFunc: mkdocsLogFunc,
stderrLogFunc: mkdocsLogFunc,
@@ -21,6 +21,7 @@ export const runMkdocsServer = async (options: {
port?: string;
useDocker?: boolean;
dockerImage?: string;
dockerEntrypoint?: string;
stdoutLogFunc?: LogFunc;
stderrLogFunc?: LogFunc;
}): Promise<ChildProcess> => {
@@ -41,6 +42,9 @@ export const runMkdocsServer = async (options: {
'-p',
`${port}:${port}`,
'-it',
...(options.dockerEntrypoint
? ['--entrypoint', options.dockerEntrypoint]
: []),
dockerImage,
'serve',
'--dev-addr',