Skip to content

Commit 0c02152

Browse files
committed
custom entrypoint prefix
1 parent 3d906a8 commit 0c02152

File tree

4 files changed

+31
-6
lines changed

4 files changed

+31
-6
lines changed

packages/cli-v3/src/build/extensions.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,10 @@ function applyLayerToManifest(layer: BuildLayer, manifest: BuildManifest): Build
208208
$manifest.image.pkgs = $manifest.image.pkgs.concat(layer.image.pkgs);
209209
$manifest.image.pkgs = Array.from(new Set($manifest.image.pkgs));
210210
}
211+
212+
if (layer.image.entrypointPrefix) {
213+
$manifest.image.entrypointPrefix = [...layer.image.entrypointPrefix];
214+
}
211215
}
212216

213217
if (layer.conditions) {

packages/cli-v3/src/deploy/buildImage.ts

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -727,14 +727,26 @@ const parseGenerateOptions = (options: GenerateContainerfileOptions) => {
727727
baseInstructions,
728728
buildArgs,
729729
buildEnvVars,
730+
entrypointPrefix: options.image?.entrypointPrefix ?? [],
730731
packages,
731732
postInstallCommands,
732733
};
733734
};
734735

736+
function serializeEntrypoint(entrypointPrefix: string[], entrypoint: string) {
737+
return JSON.stringify(["dumb-init", ...entrypointPrefix, "node", entrypoint]);
738+
}
739+
735740
async function generateBunContainerfile(options: GenerateContainerfileOptions) {
736-
const { baseImage, buildArgs, buildEnvVars, postInstallCommands, baseInstructions, packages } =
737-
parseGenerateOptions(options);
741+
const {
742+
baseImage,
743+
buildArgs,
744+
buildEnvVars,
745+
entrypointPrefix,
746+
postInstallCommands,
747+
baseInstructions,
748+
packages,
749+
} = parseGenerateOptions(options);
738750

739751
return `# syntax=docker/dockerfile:1
740752
# check=skip=SecretsUsedInArgOrEnv
@@ -829,14 +841,21 @@ COPY --from=build --chown=bun:bun /app ./
829841
# Copy the index.json file from the indexer stage
830842
COPY --from=indexer --chown=bun:bun /app/index.json ./
831843
832-
ENTRYPOINT [ "dumb-init", "node", "${options.entrypoint}" ]
844+
ENTRYPOINT ${serializeEntrypoint(entrypointPrefix, options.entrypoint)}
833845
CMD []
834846
`;
835847
}
836848

837849
async function generateNodeContainerfile(options: GenerateContainerfileOptions) {
838-
const { baseImage, buildArgs, buildEnvVars, postInstallCommands, baseInstructions, packages } =
839-
parseGenerateOptions(options);
850+
const {
851+
baseImage,
852+
buildArgs,
853+
buildEnvVars,
854+
entrypointPrefix,
855+
postInstallCommands,
856+
baseInstructions,
857+
packages,
858+
} = parseGenerateOptions(options);
840859

841860
return `# syntax=docker/dockerfile:1
842861
# check=skip=SecretsUsedInArgOrEnv
@@ -939,7 +958,7 @@ COPY --from=build --chown=node:node /app ./
939958
# Copy the index.json file from the indexer stage
940959
COPY --from=indexer --chown=node:node /app/index.json ./
941960
942-
ENTRYPOINT [ "dumb-init", "node", "${options.entrypoint}" ]
961+
ENTRYPOINT ${serializeEntrypoint(entrypointPrefix, options.entrypoint)}
943962
CMD []
944963
`;
945964
}

packages/core/src/v3/build/extensions.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ export interface BuildLayer {
5656
image?: {
5757
pkgs?: string[];
5858
instructions?: string[];
59+
entrypointPrefix?: string[];
5960
};
6061
build?: {
6162
env?: Record<string, string | undefined>;

packages/core/src/v3/schemas/build.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export const BuildManifest = z.object({
6060
.object({
6161
pkgs: z.array(z.string()).optional(),
6262
instructions: z.array(z.string()).optional(),
63+
entrypointPrefix: z.array(z.string()).optional(),
6364
})
6465
.optional(),
6566
otelImportHook: z

0 commit comments

Comments
 (0)