@@ -7,9 +7,18 @@ import { GenericContainer } from "../generic-container/generic-container";
77import { LABEL_TESTCONTAINERS_RYUK , LABEL_TESTCONTAINERS_SESSION_ID } from "../utils/labels" ;
88import { Wait } from "../wait-strategies/wait" ;
99
10- export const REAPER_IMAGE = process . env [ "RYUK_CONTAINER_IMAGE" ]
11- ? ImageName . fromString ( process . env [ "RYUK_CONTAINER_IMAGE" ] ) . string
12- : ImageName . fromString ( "testcontainers/ryuk:0.14.0" ) . string ;
10+ /**
11+ * Resolve the Ryuk reaper image name. Read lazily so that callers (and tests)
12+ * can set `process.env.RYUK_CONTAINER_IMAGE` _after_ this module is imported —
13+ * including via `.env` files loaded by `dotenv` at runtime.
14+ *
15+ * See https://github.com/testcontainers/testcontainers-node/issues/1310.
16+ */
17+ export function getReaperImage ( ) : string {
18+ return process . env [ "RYUK_CONTAINER_IMAGE" ]
19+ ? ImageName . fromString ( process . env [ "RYUK_CONTAINER_IMAGE" ] ) . string
20+ : ImageName . fromString ( "testcontainers/ryuk:0.14.0" ) . string ;
21+ }
1322
1423export interface Reaper {
1524 sessionId : string ;
@@ -87,7 +96,7 @@ async function useExistingReaper(reaperContainer: ContainerInfo, sessionId: stri
8796async function createNewReaper ( sessionId : string , remoteSocketPath : string ) : Promise < Reaper > {
8897 log . debug ( `Creating new Reaper for session "${ sessionId } " with socket path "${ remoteSocketPath } "...` ) ;
8998
90- const container = new GenericContainer ( REAPER_IMAGE )
99+ const container = new GenericContainer ( getReaperImage ( ) )
91100 . withName ( `testcontainers-ryuk-${ sessionId } ` )
92101 . withExposedPorts (
93102 process . env [ "TESTCONTAINERS_RYUK_PORT" ]
0 commit comments