Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/cli-v3/src/build/extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,10 @@ function applyLayerToManifest(layer: BuildLayer, manifest: BuildManifest): Build
$manifest.image.pkgs = $manifest.image.pkgs.concat(layer.image.pkgs);
$manifest.image.pkgs = Array.from(new Set($manifest.image.pkgs));
}

if (layer.image.entrypointPrefix) {
$manifest.image.entrypointPrefix = [...layer.image.entrypointPrefix];
}
}

if (layer.conditions) {
Expand Down
31 changes: 25 additions & 6 deletions packages/cli-v3/src/deploy/buildImage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -727,14 +727,26 @@ const parseGenerateOptions = (options: GenerateContainerfileOptions) => {
baseInstructions,
buildArgs,
buildEnvVars,
entrypointPrefix: options.image?.entrypointPrefix ?? [],
packages,
postInstallCommands,
};
};

function serializeEntrypoint(entrypointPrefix: string[], entrypoint: string) {
return JSON.stringify(["dumb-init", ...entrypointPrefix, "node", entrypoint]);
}

async function generateBunContainerfile(options: GenerateContainerfileOptions) {
const { baseImage, buildArgs, buildEnvVars, postInstallCommands, baseInstructions, packages } =
parseGenerateOptions(options);
const {
baseImage,
buildArgs,
buildEnvVars,
entrypointPrefix,
postInstallCommands,
baseInstructions,
packages,
} = parseGenerateOptions(options);

return `# syntax=docker/dockerfile:1
# check=skip=SecretsUsedInArgOrEnv
Expand Down Expand Up @@ -829,14 +841,21 @@ COPY --from=build --chown=bun:bun /app ./
# Copy the index.json file from the indexer stage
COPY --from=indexer --chown=bun:bun /app/index.json ./

ENTRYPOINT [ "dumb-init", "node", "${options.entrypoint}" ]
ENTRYPOINT ${serializeEntrypoint(entrypointPrefix, options.entrypoint)}
CMD []
`;
}

async function generateNodeContainerfile(options: GenerateContainerfileOptions) {
const { baseImage, buildArgs, buildEnvVars, postInstallCommands, baseInstructions, packages } =
parseGenerateOptions(options);
const {
baseImage,
buildArgs,
buildEnvVars,
entrypointPrefix,
postInstallCommands,
baseInstructions,
packages,
} = parseGenerateOptions(options);

return `# syntax=docker/dockerfile:1
# check=skip=SecretsUsedInArgOrEnv
Expand Down Expand Up @@ -939,7 +958,7 @@ COPY --from=build --chown=node:node /app ./
# Copy the index.json file from the indexer stage
COPY --from=indexer --chown=node:node /app/index.json ./

ENTRYPOINT [ "dumb-init", "node", "${options.entrypoint}" ]
ENTRYPOINT ${serializeEntrypoint(entrypointPrefix, options.entrypoint)}
CMD []
`;
}
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/v3/build/extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export interface BuildLayer {
image?: {
pkgs?: string[];
instructions?: string[];
entrypointPrefix?: string[];
};
build?: {
env?: Record<string, string | undefined>;
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/v3/schemas/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export const BuildManifest = z.object({
.object({
pkgs: z.array(z.string()).optional(),
instructions: z.array(z.string()).optional(),
entrypointPrefix: z.array(z.string()).optional(),
})
.optional(),
otelImportHook: z
Expand Down