( options: SelfhostDockerBootOptions, )
| 143 | }; |
| 144 | |
| 145 | export const bootSelfhostDocker = async ( |
| 146 | options: SelfhostDockerBootOptions, |
| 147 | ): Promise<BootedProcesses> => { |
| 148 | const image = await resolveImage(options.logFile); |
| 149 | const name = selfhostDockerContainerName(options.port); |
| 150 | const volume = selfhostDockerVolumeName(options.port); |
| 151 | |
| 152 | // A previous suite that died without teardown leaves the named container |
| 153 | // and volume squatting — remove both for a hermetic boot. |
| 154 | await exec("docker", ["rm", "-f", name]).catch(() => {}); |
| 155 | await exec("docker", ["volume", "rm", "-f", volume]).catch(() => {}); |
| 156 | |
| 157 | await runSelfhostContainer({ image, ...options }); |
| 158 | |
| 159 | // The target's restart() runs in a different process (test worker, not |
| 160 | // globalsetup) and must re-run the same image. claimPorts-style env |
| 161 | // publication: workers spawn after globalsetup, so they inherit this. |
| 162 | process.env.E2E_SELFHOST_DOCKER_RESOLVED_IMAGE = image; |
| 163 | |
| 164 | return { |
| 165 | teardown: async () => { |
| 166 | await stopSelfhostContainer(options.port, options.logFile); |
| 167 | await exec("docker", ["volume", "rm", "-f", volume]).catch(() => {}); |
| 168 | }, |
| 169 | pids: [], |
| 170 | }; |
| 171 | }; |
no test coverage detected