UNPKG

@adpt/cloud

Version:
129 lines 4.05 kB
import Adapt, { Handle, SFCDeclProps } from "@adpt/core"; import { ConnectToInstance } from "../ConnectTo"; import { Environment } from "../env"; import { NetworkServiceScope } from "../NetworkService"; import { NodeImageBuildOptions } from "./LocalNodeImage"; /** * Props for {@link nodejs.NodeService}. * @public */ export interface NodeServiceProps { /** * Image build options to pass to {@link nodejs.LocalNodeImage}. */ buildOptions: NodeImageBuildOptions; /** * Handles for services that this component connects to. * @remarks * The referenced service components must implement the * {@link ConnectToInstance} interface. The Node Container will be * started with the combined set of environment variables that are * provided by all of the referenced components' * {@link ConnectToInstance.connectEnv | connectEnv} methods. * * In case of environment variable naming conflicts among those in * from the `connectTo` prop, the value from the handle with the highest * index in the `connectTo` array will take precedence. * In case of naming conflicts between `connectTo` and `env`, the value * in `env` will take precedence. * @defaultValue `[]` */ connectTo: Handle<ConnectToInstance> | Handle<ConnectToInstance>[]; /** * Dependencies that must be deployed before the Container image will * build. * @remarks * Note that the NetworkService will also not deploy before the * Container image has been built. * @defaultValue `[]` */ deps: Handle | Handle[]; /** * Object containing environment variables that the Container will be * started with. * @defaultValue `{}` */ env: Environment; /** * The port that the NetworkService will expose. * @defaultValue Use the same port number as `port` */ externalPort?: number; /** * The port number that the Node Container will use. * @defaultValue 8080 */ port: number; /** * Scope within which the NetworkService will be exposed. * @defaultValue "cluster-internal" */ scope: NetworkServiceScope; /** * Root directory (which contains package.json) for the Node.js app * source code. */ srcDir: string; } declare const defaultProps: { buildOptions: { runNpmScripts: string; }; connectTo: never[]; deps: never[]; env: {}; port: number; scope: string; }; /** * A partially abstract component that builds Node.js source code into a Container * and exposes a NetworkService. * * @remarks * To use this component, the `srcDir` prop must be the path to the root of * a Node.js project, which contains a package.json file. The component will * build a Docker container image by: * * - starting with an official Node.js base image * * - copying `srcDir` into the container image * * - executing `npm run build` * * - setting the container CMD to execute the `main` file specified in * package.json * * Abstract components: * * This component uses the following abstract components which must be * replaced via style sheet rules: * * - {@link Service} * * - {@link NetworkService} * * - {@link Container} * * The {@link NetworkService} and {@link Container} components are both * children of the {@link Service} component. * * Instance methods: * * - `hostname(): string | undefined` * * Returns the hostname of the NetworkService, once it is known. * * - `port(): number | undefined` * * Returns the port number of the NetworkService, once it is known. * * - `image():` {@link docker.ImageInfo} | `undefined` * * Information about the successfully built image, once it has been built. * * @param props - See {@link nodejs.NodeServiceProps} * @public */ export declare function NodeService(props: SFCDeclProps<NodeServiceProps, typeof defaultProps>): Adapt.AdaptElement<Adapt.AnyProps>; export default NodeService; //# sourceMappingURL=NodeService.d.ts.map