-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Command to start a local container (#491)
* RFC local conatiner commands * Log progress * Use stderrStream * Remove -q * No jumps when writing output * Fix build * Improvements for states * Marke awaits in loop OK * Refactor * Refactor * Refactor * Initial tests * Initial tests * Initial tests * Fix stuff * More tests * More tests * Move test file to be for local command. Remove ability to pick the image * Apply suggestions from code review Co-authored-by: echo-bravo-yahoo <[email protected]> --------- Co-authored-by: echo-bravo-yahoo <[email protected]>
- Loading branch information
1 parent
02b5166
commit 1801770
Showing
12 changed files
with
898 additions
and
16 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { ensureContainerRunning } from "../lib/docker-containers.mjs"; | ||
|
||
/** | ||
* Starts the local Fauna container | ||
* @param {import('yargs').Arguments} argv The arguments from yargs | ||
* @returns {Promise<void>} a promise that resolves when the container is ready. | ||
* It will reject if the container is not ready after the maximum number of attempts. | ||
*/ | ||
async function startLocal(argv) { | ||
await ensureContainerRunning({ | ||
imageName: argv.image, | ||
containerName: argv.name, | ||
hostPort: argv.hostPort, | ||
containerPort: argv.containerPort, | ||
pull: argv.pull, | ||
}); | ||
} | ||
|
||
/** | ||
* Builds the yargs command for the local command | ||
* @param {import('yargs').Argv} yargs The yargs instance | ||
* @returns {import('yargs').Argv} The yargs instance | ||
*/ | ||
function buildLocalCommand(yargs) { | ||
return yargs.options({ | ||
containerPort: { | ||
describe: "The port inside the container Fauna listens on.", | ||
type: "number", | ||
default: "8443", | ||
}, | ||
hostPort: { | ||
describe: | ||
"The port on the host machine mapped to the container's port. This is the port you'll connect to Fauna on.", | ||
type: "number", | ||
default: "8443", | ||
}, | ||
name: { | ||
describe: "The name to give the container", | ||
type: "string", | ||
default: "faunadb", | ||
}, | ||
pull: { | ||
describe: "Pull the latest image before starting the container.", | ||
type: "boolean", | ||
default: true, | ||
}, | ||
}); | ||
} | ||
|
||
export default { | ||
command: "local", | ||
describe: "Start a local Fauna container", | ||
builder: buildLocalCommand, | ||
handler: startLocal, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.