testcontainers 9.12.0 → 10.0.0-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{dist/src → build/common}/clock.js +1 -0
- package/build/common/clock.js.map +1 -0
- package/build/common/file-lock.js +58 -0
- package/build/common/file-lock.js.map +1 -0
- package/build/common/hash.d.ts +1 -0
- package/{dist/src → build/common}/hash.js +3 -2
- package/build/common/hash.js.map +1 -0
- package/build/common/index.d.ts +7 -0
- package/build/common/index.js +37 -0
- package/build/common/index.js.map +1 -0
- package/{dist/src → build/common}/logger.d.ts +5 -6
- package/{dist/src → build/common}/logger.js +5 -2
- package/build/common/logger.js.map +1 -0
- package/{dist/src/retry-strategy.d.ts → build/common/retry.d.ts} +3 -3
- package/build/common/retry.js +38 -0
- package/build/common/retry.js.map +1 -0
- package/build/common/streams.js +13 -0
- package/build/common/streams.js.map +1 -0
- package/{dist/src → build/common}/type-guards.js +1 -0
- package/build/common/type-guards.js.map +1 -0
- package/{dist/src → build/common}/uuid.js +1 -0
- package/build/common/uuid.js.map +1 -0
- package/build/container-runtime/auth/auths.d.ts +7 -0
- package/build/container-runtime/auth/auths.js +45 -0
- package/build/container-runtime/auth/auths.js.map +1 -0
- package/build/container-runtime/auth/cred-helpers.d.ts +6 -0
- package/{dist/src/registry-auth-locator → build/container-runtime/auth}/cred-helpers.js +1 -0
- package/build/container-runtime/auth/cred-helpers.js.map +1 -0
- package/{dist/src/registry-auth-locator → build/container-runtime/auth}/credential-provider.d.ts +3 -4
- package/build/container-runtime/auth/credential-provider.js +71 -0
- package/build/container-runtime/auth/credential-provider.js.map +1 -0
- package/build/container-runtime/auth/creds-store.d.ts +6 -0
- package/{dist/src/registry-auth-locator → build/container-runtime/auth}/creds-store.js +1 -0
- package/build/container-runtime/auth/creds-store.js.map +1 -0
- package/{dist/src/registry-auth-locator → build/container-runtime/auth}/get-auth-config.d.ts +1 -1
- package/{dist/src/registry-auth-locator → build/container-runtime/auth}/get-auth-config.js +11 -19
- package/build/container-runtime/auth/get-auth-config.js.map +1 -0
- package/build/container-runtime/auth/registry-auth-locator.d.ts +5 -0
- package/build/container-runtime/auth/registry-auth-locator.js +3 -0
- package/build/container-runtime/auth/registry-auth-locator.js.map +1 -0
- package/{dist/src/registry-auth-locator → build/container-runtime/auth}/registry-matches.js +1 -0
- package/build/container-runtime/auth/registry-matches.js.map +1 -0
- package/{dist/src/registry-auth-locator → build/container-runtime/auth}/types.d.ts +13 -1
- package/{dist/src/registry-auth-locator → build/container-runtime/auth}/types.js +1 -0
- package/build/container-runtime/auth/types.js.map +1 -0
- package/build/container-runtime/clients/client.d.ts +14 -0
- package/build/container-runtime/clients/client.js +105 -0
- package/build/container-runtime/clients/client.js.map +1 -0
- package/build/container-runtime/clients/compose/compose-client.d.ts +11 -0
- package/build/container-runtime/clients/compose/compose-client.js +238 -0
- package/build/container-runtime/clients/compose/compose-client.js.map +1 -0
- package/build/container-runtime/clients/compose/default-compose-options.d.ts +4 -0
- package/build/container-runtime/clients/compose/default-compose-options.js +31 -0
- package/build/container-runtime/clients/compose/default-compose-options.js.map +1 -0
- package/build/container-runtime/clients/compose/parse-compose-container-name.d.ts +1 -0
- package/{dist/src/docker-compose/container-name-resolver.js → build/container-runtime/clients/compose/parse-compose-container-name.js} +5 -4
- package/build/container-runtime/clients/compose/parse-compose-container-name.js.map +1 -0
- package/build/container-runtime/clients/compose/types.d.ts +15 -0
- package/{dist/src/docker → build/container-runtime/clients/compose}/types.js +1 -0
- package/build/container-runtime/clients/compose/types.js.map +1 -0
- package/build/container-runtime/clients/container/container-client.d.ts +32 -0
- package/build/container-runtime/clients/container/container-client.js +3 -0
- package/build/container-runtime/clients/container/container-client.js.map +1 -0
- package/build/container-runtime/clients/container/docker-container-client.d.ts +35 -0
- package/build/container-runtime/clients/container/docker-container-client.js +276 -0
- package/build/container-runtime/clients/container/docker-container-client.js.map +1 -0
- package/build/container-runtime/clients/container/podman-container-client.d.ts +8 -0
- package/build/container-runtime/clients/container/podman-container-client.js +43 -0
- package/build/container-runtime/clients/container/podman-container-client.js.map +1 -0
- package/build/container-runtime/clients/container/types.d.ts +4 -0
- package/{dist/src/docker/client/docker-client-types.js → build/container-runtime/clients/container/types.js} +1 -0
- package/build/container-runtime/clients/container/types.js.map +1 -0
- package/build/container-runtime/clients/image/docker-image-client.d.ts +16 -0
- package/build/container-runtime/clients/image/docker-image-client.js +119 -0
- package/build/container-runtime/clients/image/docker-image-client.js.map +1 -0
- package/build/container-runtime/clients/image/image-client.d.ts +9 -0
- package/build/container-runtime/clients/image/image-client.js +3 -0
- package/build/container-runtime/clients/image/image-client.js.map +1 -0
- package/build/container-runtime/clients/network/docker-network-client.d.ts +9 -0
- package/build/container-runtime/clients/network/docker-network-client.js +50 -0
- package/build/container-runtime/clients/network/docker-network-client.js.map +1 -0
- package/build/container-runtime/clients/network/network-client.d.ts +6 -0
- package/build/container-runtime/clients/network/network-client.js +3 -0
- package/build/container-runtime/clients/network/network-client.js.map +1 -0
- package/build/container-runtime/clients/types.d.ts +30 -0
- package/{dist/src/docker/client/strategy/docker-client-strategy.js → build/container-runtime/clients/types.js} +1 -0
- package/build/container-runtime/clients/types.js.map +1 -0
- package/build/container-runtime/image-name.d.ts +11 -0
- package/{dist/src/docker-image-name.js → build/container-runtime/image-name.js} +11 -17
- package/build/container-runtime/image-name.js.map +1 -0
- package/build/container-runtime/index.d.ts +6 -0
- package/build/container-runtime/index.js +13 -0
- package/build/container-runtime/index.js.map +1 -0
- package/build/container-runtime/strategies/configuration-strategy.d.ts +9 -0
- package/build/container-runtime/strategies/configuration-strategy.js +53 -0
- package/build/container-runtime/strategies/configuration-strategy.js.map +1 -0
- package/build/container-runtime/strategies/npipe-socket-strategy.d.ts +6 -0
- package/build/container-runtime/strategies/npipe-socket-strategy.js +21 -0
- package/build/container-runtime/strategies/npipe-socket-strategy.js.map +1 -0
- package/build/container-runtime/strategies/rootless-unix-socket-strategy.d.ts +14 -0
- package/build/container-runtime/strategies/rootless-unix-socket-strategy.js +63 -0
- package/build/container-runtime/strategies/rootless-unix-socket-strategy.js.map +1 -0
- package/build/container-runtime/strategies/strategy.d.ts +5 -0
- package/{dist/src/registry-auth-locator/registry-auth-locator.js → build/container-runtime/strategies/strategy.js} +1 -0
- package/build/container-runtime/strategies/strategy.js.map +1 -0
- package/build/container-runtime/strategies/testcontainers-host-strategy.d.ts +6 -0
- package/build/container-runtime/strategies/testcontainers-host-strategy.js +30 -0
- package/build/container-runtime/strategies/testcontainers-host-strategy.js.map +1 -0
- package/build/container-runtime/strategies/types.d.ts +8 -0
- package/build/container-runtime/strategies/types.js +3 -0
- package/build/container-runtime/strategies/types.js.map +1 -0
- package/build/container-runtime/strategies/unix-socket-strategy.d.ts +6 -0
- package/build/container-runtime/strategies/unix-socket-strategy.js +22 -0
- package/build/container-runtime/strategies/unix-socket-strategy.js.map +1 -0
- package/build/container-runtime/strategies/utils/config.d.ts +9 -0
- package/build/container-runtime/strategies/utils/config.js +75 -0
- package/build/container-runtime/strategies/utils/config.js.map +1 -0
- package/build/container-runtime/utils/attach-container.js +17 -0
- package/build/container-runtime/utils/attach-container.js.map +1 -0
- package/build/container-runtime/utils/demux-stream.d.ts +4 -0
- package/build/container-runtime/utils/demux-stream.js +24 -0
- package/build/container-runtime/utils/demux-stream.js.map +1 -0
- package/build/container-runtime/utils/image-exists.d.ts +3 -0
- package/build/container-runtime/utils/image-exists.js +29 -0
- package/build/container-runtime/utils/image-exists.js.map +1 -0
- package/build/container-runtime/utils/lookup-host-ips.d.ts +2 -0
- package/build/container-runtime/utils/lookup-host-ips.js +18 -0
- package/build/container-runtime/utils/lookup-host-ips.js.map +1 -0
- package/{dist/src/docker/functions/image → build/container-runtime/utils}/pull-image.d.ts +2 -2
- package/build/container-runtime/utils/pull-image.js +35 -0
- package/build/container-runtime/utils/pull-image.js.map +1 -0
- package/build/container-runtime/utils/remote-container-runtime-socket-path.d.ts +7 -0
- package/build/container-runtime/utils/remote-container-runtime-socket-path.js +23 -0
- package/build/container-runtime/utils/remote-container-runtime-socket-path.js.map +1 -0
- package/build/container-runtime/utils/resolve-host.d.ts +8 -0
- package/build/container-runtime/utils/resolve-host.js +54 -0
- package/build/container-runtime/utils/resolve-host.js.map +1 -0
- package/build/container-runtime/utils/run-in-container.js +30 -0
- package/build/container-runtime/utils/run-in-container.js.map +1 -0
- package/build/container-runtime/utils/start-container.js +15 -0
- package/build/container-runtime/utils/start-container.js.map +1 -0
- package/{dist/src → build}/docker-compose-environment/docker-compose-environment.d.ts +5 -5
- package/build/docker-compose-environment/docker-compose-environment.js +144 -0
- package/build/docker-compose-environment/docker-compose-environment.js.map +1 -0
- package/{dist/src → build}/docker-compose-environment/downed-docker-compose-environment.js +1 -0
- package/build/docker-compose-environment/downed-docker-compose-environment.js.map +1 -0
- package/{dist/src → build}/docker-compose-environment/started-docker-compose-environment.d.ts +3 -3
- package/build/docker-compose-environment/started-docker-compose-environment.js +37 -0
- package/build/docker-compose-environment/started-docker-compose-environment.js.map +1 -0
- package/build/docker-compose-environment/stopped-docker-compose-environment.d.ts +7 -0
- package/build/docker-compose-environment/stopped-docker-compose-environment.js +19 -0
- package/build/docker-compose-environment/stopped-docker-compose-environment.js.map +1 -0
- package/{dist/src/modules → build/generic-container}/abstract-started-container.d.ts +1 -1
- package/build/generic-container/abstract-started-container.js +69 -0
- package/build/generic-container/abstract-started-container.js.map +1 -0
- package/{dist/src/modules → build/generic-container}/abstract-stopped-container.js +2 -0
- package/build/generic-container/abstract-stopped-container.js.map +1 -0
- package/{dist/src → build}/generic-container/generic-container-builder.d.ts +4 -4
- package/build/generic-container/generic-container-builder.js +87 -0
- package/build/generic-container/generic-container-builder.js.map +1 -0
- package/{dist/src → build}/generic-container/generic-container.d.ts +18 -22
- package/build/generic-container/generic-container.js +350 -0
- package/build/generic-container/generic-container.js.map +1 -0
- package/{dist/src → build}/generic-container/started-generic-container.d.ts +6 -6
- package/build/generic-container/started-generic-container.js +161 -0
- package/build/generic-container/started-generic-container.js.map +1 -0
- package/build/generic-container/stopped-generic-container.js +23 -0
- package/build/generic-container/stopped-generic-container.js.map +1 -0
- package/build/index.d.ts +16 -0
- package/build/index.js +35 -0
- package/build/index.js.map +1 -0
- package/build/network/network.d.ts +19 -0
- package/build/network/network.js +61 -0
- package/build/network/network.js.map +1 -0
- package/{dist/src → build/port-forwarder}/port-forwarder.d.ts +2 -1
- package/build/port-forwarder/port-forwarder.js +73 -0
- package/build/port-forwarder/port-forwarder.js.map +1 -0
- package/build/reaper/reaper.d.ts +8 -0
- package/build/reaper/reaper.js +119 -0
- package/build/reaper/reaper.js.map +1 -0
- package/{dist/src → build}/test-container.d.ts +6 -6
- package/{dist/src → build}/test-container.js +1 -0
- package/build/test-container.js.map +1 -0
- package/build/test-containers.js +12 -0
- package/build/test-containers.js.map +1 -0
- package/{dist/src/docker → build}/types.d.ts +16 -0
- package/build/types.js +3 -0
- package/build/types.js.map +1 -0
- package/{dist/src → build/utils}/bound-ports.d.ts +4 -3
- package/{dist/src → build/utils}/bound-ports.js +22 -5
- package/build/utils/bound-ports.js.map +1 -0
- package/build/utils/dockerfile-parser.d.ts +3 -0
- package/build/utils/dockerfile-parser.js +28 -0
- package/build/utils/dockerfile-parser.js.map +1 -0
- package/{dist/src → build/utils}/labels.d.ts +1 -0
- package/build/utils/labels.js +18 -0
- package/build/utils/labels.js.map +1 -0
- package/build/utils/map-inspect-result.d.ts +3 -0
- package/build/utils/map-inspect-result.js +55 -0
- package/build/utils/map-inspect-result.js.map +1 -0
- package/build/utils/port-generator.js +43 -0
- package/build/utils/port-generator.js.map +1 -0
- package/{dist/src → build/utils}/port.d.ts +0 -3
- package/build/utils/port.js +10 -0
- package/build/utils/port.js.map +1 -0
- package/build/utils/pull-policy.d.ts +7 -0
- package/build/utils/pull-policy.js +23 -0
- package/build/utils/pull-policy.js.map +1 -0
- package/build/utils/test-helper.d.ts +19 -0
- package/build/utils/test-helper.js +107 -0
- package/build/utils/test-helper.js.map +1 -0
- package/build/version.d.ts +1 -0
- package/build/version.js +5 -0
- package/build/version.js.map +1 -0
- package/{dist/src/wait-strategy → build/wait-strategies}/composite-wait-strategy.d.ts +1 -1
- package/build/wait-strategies/composite-wait-strategy.js +49 -0
- package/build/wait-strategies/composite-wait-strategy.js.map +1 -0
- package/build/wait-strategies/health-check-wait-strategy.js +26 -0
- package/build/wait-strategies/health-check-wait-strategy.js.map +1 -0
- package/{dist/src/wait-strategy → build/wait-strategies}/host-port-wait-strategy.d.ts +1 -1
- package/build/wait-strategies/host-port-wait-strategy.js +42 -0
- package/build/wait-strategies/host-port-wait-strategy.js.map +1 -0
- package/{dist/src/wait-strategy → build/wait-strategies}/http-wait-strategy.d.ts +1 -1
- package/build/wait-strategies/http-wait-strategy.js +111 -0
- package/build/wait-strategies/http-wait-strategy.js.map +1 -0
- package/{dist/src/wait-strategy → build/wait-strategies}/log-wait-strategy.d.ts +1 -1
- package/build/wait-strategies/log-wait-strategy.js +62 -0
- package/build/wait-strategies/log-wait-strategy.js.map +1 -0
- package/build/wait-strategies/shell-wait-strategy.js +30 -0
- package/build/wait-strategies/shell-wait-strategy.js.map +1 -0
- package/{dist/src/wait-strategy → build/wait-strategies}/startup-check-strategy.d.ts +3 -0
- package/build/wait-strategies/startup-check-strategy.js +27 -0
- package/build/wait-strategies/startup-check-strategy.js.map +1 -0
- package/{dist/src → build/wait-strategies/utils}/port-check.d.ts +5 -6
- package/build/wait-strategies/utils/port-check.js +81 -0
- package/build/wait-strategies/utils/port-check.js.map +1 -0
- package/build/wait-strategies/wait-for-container.d.ts +5 -0
- package/build/wait-strategies/wait-for-container.js +24 -0
- package/build/wait-strategies/wait-for-container.js.map +1 -0
- package/{dist/src/wait-strategy → build/wait-strategies}/wait-strategy.d.ts +1 -1
- package/{dist/src/wait-strategy → build/wait-strategies}/wait-strategy.js +3 -4
- package/build/wait-strategies/wait-strategy.js.map +1 -0
- package/{dist/src/wait-strategy → build/wait-strategies}/wait.js +1 -0
- package/build/wait-strategies/wait.js.map +1 -0
- package/package.json +18 -63
- package/LICENSE +0 -21
- package/README.md +0 -27
- package/dist/package.json +0 -104
- package/dist/src/docker/client/docker-client-config.d.ts +0 -9
- package/dist/src/docker/client/docker-client-config.js +0 -82
- package/dist/src/docker/client/docker-client-types.d.ts +0 -23
- package/dist/src/docker/client/docker-client.d.ts +0 -2
- package/dist/src/docker/client/docker-client.js +0 -133
- package/dist/src/docker/client/strategy/configuration-strategy.d.ts +0 -11
- package/dist/src/docker/client/strategy/configuration-strategy.js +0 -66
- package/dist/src/docker/client/strategy/docker-client-strategy.d.ts +0 -7
- package/dist/src/docker/client/strategy/npipe-socket-strategy.d.ts +0 -7
- package/dist/src/docker/client/strategy/npipe-socket-strategy.js +0 -31
- package/dist/src/docker/client/strategy/rootless-unix-socket-strategy.d.ts +0 -18
- package/dist/src/docker/client/strategy/rootless-unix-socket-strategy.js +0 -77
- package/dist/src/docker/client/strategy/testcontainers-host-strategy.d.ts +0 -9
- package/dist/src/docker/client/strategy/testcontainers-host-strategy.js +0 -47
- package/dist/src/docker/client/strategy/unix-socket-strategy.d.ts +0 -7
- package/dist/src/docker/client/strategy/unix-socket-strategy.js +0 -32
- package/dist/src/docker/functions/container/attach-container.js +0 -25
- package/dist/src/docker/functions/container/container-logs.d.ts +0 -6
- package/dist/src/docker/functions/container/container-logs.js +0 -32
- package/dist/src/docker/functions/container/create-container.d.ts +0 -31
- package/dist/src/docker/functions/container/create-container.js +0 -117
- package/dist/src/docker/functions/container/exec-container.d.ts +0 -3
- package/dist/src/docker/functions/container/exec-container.js +0 -66
- package/dist/src/docker/functions/container/get-container-archive.d.ts +0 -11
- package/dist/src/docker/functions/container/get-container-archive.js +0 -23
- package/dist/src/docker/functions/container/get-container.d.ts +0 -3
- package/dist/src/docker/functions/container/get-container.js +0 -49
- package/dist/src/docker/functions/container/inspect-container.d.ts +0 -19
- package/dist/src/docker/functions/container/inspect-container.js +0 -67
- package/dist/src/docker/functions/container/list-containers.d.ts +0 -2
- package/dist/src/docker/functions/container/list-containers.js +0 -25
- package/dist/src/docker/functions/container/put-container-archive.d.ts +0 -9
- package/dist/src/docker/functions/container/put-container-archive.js +0 -26
- package/dist/src/docker/functions/container/remove-container.d.ts +0 -5
- package/dist/src/docker/functions/container/remove-container.js +0 -23
- package/dist/src/docker/functions/container/restart-container.d.ts +0 -5
- package/dist/src/docker/functions/container/restart-container.js +0 -23
- package/dist/src/docker/functions/container/start-container.js +0 -23
- package/dist/src/docker/functions/container/stop-container.d.ts +0 -5
- package/dist/src/docker/functions/container/stop-container.js +0 -29
- package/dist/src/docker/functions/create-labels.d.ts +0 -2
- package/dist/src/docker/functions/create-labels.js +0 -13
- package/dist/src/docker/functions/demux-stream.d.ts +0 -3
- package/dist/src/docker/functions/demux-stream.js +0 -32
- package/dist/src/docker/functions/get-info.d.ts +0 -11
- package/dist/src/docker/functions/get-info.js +0 -38
- package/dist/src/docker/functions/image/build-image.d.ts +0 -14
- package/dist/src/docker/functions/image/build-image.js +0 -81
- package/dist/src/docker/functions/image/image-exists.d.ts +0 -3
- package/dist/src/docker/functions/image/image-exists.js +0 -37
- package/dist/src/docker/functions/image/pull-image.js +0 -48
- package/dist/src/docker/functions/network/connect-network.d.ts +0 -6
- package/dist/src/docker/functions/network/connect-network.js +0 -28
- package/dist/src/docker/functions/network/create-network.d.ts +0 -16
- package/dist/src/docker/functions/network/create-network.js +0 -39
- package/dist/src/docker/functions/network/remove-network.d.ts +0 -1
- package/dist/src/docker/functions/network/remove-network.js +0 -31
- package/dist/src/docker/functions/run-in-container.js +0 -39
- package/dist/src/docker/lookup-host-ips.d.ts +0 -5
- package/dist/src/docker/lookup-host-ips.js +0 -26
- package/dist/src/docker/remote-docker-unix-socket-path.d.ts +0 -7
- package/dist/src/docker/remote-docker-unix-socket-path.js +0 -22
- package/dist/src/docker/resolve-host.d.ts +0 -8
- package/dist/src/docker/resolve-host.js +0 -63
- package/dist/src/docker-compose/container-name-resolver.d.ts +0 -1
- package/dist/src/docker-compose/docker-compose-client.d.ts +0 -9
- package/dist/src/docker-compose/docker-compose-client.js +0 -221
- package/dist/src/docker-compose/docker-compose-options.d.ts +0 -17
- package/dist/src/docker-compose/docker-compose-options.js +0 -51
- package/dist/src/docker-compose-environment/docker-compose-environment.js +0 -146
- package/dist/src/docker-compose-environment/started-docker-compose-environment.js +0 -47
- package/dist/src/docker-compose-environment/stopped-docker-compose-environment.d.ts +0 -7
- package/dist/src/docker-compose-environment/stopped-docker-compose-environment.js +0 -28
- package/dist/src/docker-image-name.d.ts +0 -15
- package/dist/src/dockerfile-parser.d.ts +0 -3
- package/dist/src/dockerfile-parser.js +0 -39
- package/dist/src/file-lock.js +0 -47
- package/dist/src/generic-container/create-container-options.d.ts +0 -3
- package/dist/src/generic-container/create-container-options.js +0 -18
- package/dist/src/generic-container/generic-container-builder.js +0 -97
- package/dist/src/generic-container/generic-container.js +0 -329
- package/dist/src/generic-container/started-generic-container.js +0 -168
- package/dist/src/generic-container/stopped-generic-container.js +0 -20
- package/dist/src/hash.d.ts +0 -1
- package/dist/src/images.d.ts +0 -2
- package/dist/src/images.js +0 -6
- package/dist/src/index.d.ts +0 -25
- package/dist/src/index.js +0 -66
- package/dist/src/labels.js +0 -8
- package/dist/src/modules/abstract-started-container.js +0 -86
- package/dist/src/modules/arangodb/arangodb-container.d.ts +0 -19
- package/dist/src/modules/arangodb/arangodb-container.js +0 -60
- package/dist/src/modules/elasticsearch/elasticsearch-container.d.ts +0 -12
- package/dist/src/modules/elasticsearch/elasticsearch-container.js +0 -49
- package/dist/src/modules/hivemq/hivemq-container.d.ts +0 -15
- package/dist/src/modules/hivemq/hivemq-container.js +0 -79
- package/dist/src/modules/kafka/kafka-container.d.ts +0 -45
- package/dist/src/modules/kafka/kafka-container.js +0 -177
- package/dist/src/modules/mongodb/mongodb-container.d.ts +0 -19
- package/dist/src/modules/mongodb/mongodb-container.js +0 -85
- package/dist/src/modules/mysql/mysql-container.d.ts +0 -30
- package/dist/src/modules/mysql/mysql-container.js +0 -111
- package/dist/src/modules/nats/nats-container.d.ts +0 -55
- package/dist/src/modules/nats/nats-container.js +0 -99
- package/dist/src/modules/neo4j/neo4j-container.d.ts +0 -23
- package/dist/src/modules/neo4j/neo4j-container.js +0 -82
- package/dist/src/modules/postgresql/postgresql-container.d.ts +0 -28
- package/dist/src/modules/postgresql/postgresql-container.js +0 -87
- package/dist/src/modules/selenium/selenium-container.d.ts +0 -38
- package/dist/src/modules/selenium/selenium-container.js +0 -161
- package/dist/src/network.d.ts +0 -18
- package/dist/src/network.js +0 -60
- package/dist/src/port-check.js +0 -90
- package/dist/src/port-forwarder.js +0 -83
- package/dist/src/port-generator.js +0 -51
- package/dist/src/port.js +0 -47
- package/dist/src/pull-policy.d.ts +0 -9
- package/dist/src/pull-policy.js +0 -15
- package/dist/src/reaper.d.ts +0 -5
- package/dist/src/reaper.js +0 -157
- package/dist/src/registry-auth-locator/auths.d.ts +0 -8
- package/dist/src/registry-auth-locator/auths.js +0 -56
- package/dist/src/registry-auth-locator/cred-helpers.d.ts +0 -6
- package/dist/src/registry-auth-locator/credential-provider.js +0 -81
- package/dist/src/registry-auth-locator/creds-store.d.ts +0 -6
- package/dist/src/registry-auth-locator/registry-auth-locator.d.ts +0 -6
- package/dist/src/retry-strategy.js +0 -46
- package/dist/src/stream-utils.js +0 -46
- package/dist/src/system-info.d.ts +0 -19
- package/dist/src/system-info.js +0 -80
- package/dist/src/test-containers.js +0 -22
- package/dist/src/wait-for-container.d.ts +0 -4
- package/dist/src/wait-for-container.js +0 -34
- package/dist/src/wait-strategy/composite-wait-strategy.js +0 -57
- package/dist/src/wait-strategy/health-check-wait-strategy.js +0 -36
- package/dist/src/wait-strategy/host-port-wait-strategy.js +0 -59
- package/dist/src/wait-strategy/http-wait-strategy.js +0 -120
- package/dist/src/wait-strategy/log-wait-strategy.js +0 -69
- package/dist/src/wait-strategy/shell-wait-strategy.js +0 -39
- package/dist/src/wait-strategy/startup-check-strategy.js +0 -35
- /package/{dist/src → build/common}/clock.d.ts +0 -0
- /package/{dist/src → build/common}/file-lock.d.ts +0 -0
- /package/{dist/src/stream-utils.d.ts → build/common/streams.d.ts} +0 -0
- /package/{dist/src → build/common}/type-guards.d.ts +0 -0
- /package/{dist/src → build/common}/uuid.d.ts +0 -0
- /package/{dist/src/registry-auth-locator → build/container-runtime/auth}/registry-matches.d.ts +0 -0
- /package/{dist/src/docker/functions/container → build/container-runtime/utils}/attach-container.d.ts +0 -0
- /package/{dist/src/docker/functions → build/container-runtime/utils}/run-in-container.d.ts +0 -0
- /package/{dist/src/docker/functions/container → build/container-runtime/utils}/start-container.d.ts +0 -0
- /package/{dist/src → build}/docker-compose-environment/downed-docker-compose-environment.d.ts +0 -0
- /package/{dist/src/modules → build/generic-container}/abstract-stopped-container.d.ts +0 -0
- /package/{dist/src → build}/generic-container/stopped-generic-container.d.ts +0 -0
- /package/{dist/src → build}/test-containers.d.ts +0 -0
- /package/{dist/src → build/utils}/port-generator.d.ts +0 -0
- /package/{dist/src/wait-strategy → build/wait-strategies}/health-check-wait-strategy.d.ts +0 -0
- /package/{dist/src/wait-strategy → build/wait-strategies}/shell-wait-strategy.d.ts +0 -0
- /package/{dist/src/wait-strategy → build/wait-strategies}/wait.d.ts +0 -0
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.StartedDockerComposeEnvironment = void 0;
|
|
13
|
-
const logger_1 = require("../logger");
|
|
14
|
-
const stopped_docker_compose_environment_1 = require("./stopped-docker-compose-environment");
|
|
15
|
-
const downed_docker_compose_environment_1 = require("./downed-docker-compose-environment");
|
|
16
|
-
const docker_client_1 = require("../docker/client/docker-client");
|
|
17
|
-
class StartedDockerComposeEnvironment {
|
|
18
|
-
constructor(startedGenericContainers, options) {
|
|
19
|
-
this.startedGenericContainers = startedGenericContainers;
|
|
20
|
-
this.options = options;
|
|
21
|
-
}
|
|
22
|
-
stop() {
|
|
23
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
-
const { dockerComposeClient } = yield (0, docker_client_1.getDockerClient)();
|
|
25
|
-
yield dockerComposeClient.stop(this.options);
|
|
26
|
-
return new stopped_docker_compose_environment_1.StoppedDockerComposeEnvironment(this.options);
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
down(options = {}) {
|
|
30
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
-
const { dockerComposeClient } = yield (0, docker_client_1.getDockerClient)();
|
|
32
|
-
const downOptions = Object.assign({ timeout: 0, removeVolumes: true }, options);
|
|
33
|
-
yield dockerComposeClient.down(this.options, downOptions);
|
|
34
|
-
return new downed_docker_compose_environment_1.DownedDockerComposeEnvironment();
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
getContainer(containerName) {
|
|
38
|
-
const container = this.startedGenericContainers[containerName];
|
|
39
|
-
if (!container) {
|
|
40
|
-
const error = `Cannot get container "${containerName}" as it is not running`;
|
|
41
|
-
logger_1.log.error(error);
|
|
42
|
-
throw new Error(error);
|
|
43
|
-
}
|
|
44
|
-
return container;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
exports.StartedDockerComposeEnvironment = StartedDockerComposeEnvironment;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { DownedDockerComposeEnvironment } from "./downed-docker-compose-environment";
|
|
2
|
-
import { DockerComposeDownOptions, DockerComposeOptions } from "../docker-compose/docker-compose-options";
|
|
3
|
-
export declare class StoppedDockerComposeEnvironment {
|
|
4
|
-
private readonly options;
|
|
5
|
-
constructor(options: DockerComposeOptions);
|
|
6
|
-
down(options?: Partial<DockerComposeDownOptions>): Promise<DownedDockerComposeEnvironment>;
|
|
7
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.StoppedDockerComposeEnvironment = void 0;
|
|
13
|
-
const downed_docker_compose_environment_1 = require("./downed-docker-compose-environment");
|
|
14
|
-
const docker_client_1 = require("../docker/client/docker-client");
|
|
15
|
-
class StoppedDockerComposeEnvironment {
|
|
16
|
-
constructor(options) {
|
|
17
|
-
this.options = options;
|
|
18
|
-
}
|
|
19
|
-
down(options = {}) {
|
|
20
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
-
const { dockerComposeClient } = yield (0, docker_client_1.getDockerClient)();
|
|
22
|
-
const resolvedOptions = Object.assign({ timeout: 0, removeVolumes: true }, options);
|
|
23
|
-
yield dockerComposeClient.down(this.options, resolvedOptions);
|
|
24
|
-
return new downed_docker_compose_environment_1.DownedDockerComposeEnvironment();
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
exports.StoppedDockerComposeEnvironment = StoppedDockerComposeEnvironment;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export declare class DockerImageName {
|
|
2
|
-
readonly registry: string | undefined;
|
|
3
|
-
readonly image: string;
|
|
4
|
-
readonly tag: string;
|
|
5
|
-
private readonly string;
|
|
6
|
-
private static readonly HELPER_CONTAINERS;
|
|
7
|
-
constructor(registry: string | undefined, image: string, tag: string);
|
|
8
|
-
equals(other: DockerImageName): boolean;
|
|
9
|
-
toString(): string;
|
|
10
|
-
isReaper(): boolean;
|
|
11
|
-
isHelperContainer(): boolean;
|
|
12
|
-
static fromString(string: string): DockerImageName;
|
|
13
|
-
private static getRegistry;
|
|
14
|
-
private static isRegistry;
|
|
15
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.getDockerfileImages = void 0;
|
|
13
|
-
const fs_1 = require("fs");
|
|
14
|
-
const logger_1 = require("./logger");
|
|
15
|
-
const docker_image_name_1 = require("./docker-image-name");
|
|
16
|
-
const type_guards_1 = require("./type-guards");
|
|
17
|
-
const buildArgRegex = /\${([^{]+)}/g;
|
|
18
|
-
const getDockerfileImages = (dockerfile, buildArgs) => __awaiter(void 0, void 0, void 0, function* () {
|
|
19
|
-
try {
|
|
20
|
-
return (yield parseImages(dockerfile))
|
|
21
|
-
.map((line) => line.replace(buildArgRegex, (_, arg) => { var _a; return (_a = buildArgs[arg]) !== null && _a !== void 0 ? _a : ""; }))
|
|
22
|
-
.map((line) => docker_image_name_1.DockerImageName.fromString(line.trim()));
|
|
23
|
-
}
|
|
24
|
-
catch (err) {
|
|
25
|
-
logger_1.log.error(`Failed to read Dockerfile "${dockerfile}": ${err}`);
|
|
26
|
-
throw err;
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
exports.getDockerfileImages = getDockerfileImages;
|
|
30
|
-
function parseImages(dockerfile) {
|
|
31
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
-
return Array.from((yield fs_1.promises.readFile(dockerfile, "utf8"))
|
|
33
|
-
.split(/\r?\n/)
|
|
34
|
-
.filter((line) => line.toUpperCase().startsWith("FROM"))
|
|
35
|
-
.map((line) => line.split(" ").filter(type_guards_1.isNotEmptyString)[1])
|
|
36
|
-
.reduce((prev, next) => prev.add(next), new Set())
|
|
37
|
-
.values());
|
|
38
|
-
});
|
|
39
|
-
}
|
package/dist/src/file-lock.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.withFileLock = void 0;
|
|
16
|
-
const path_1 = __importDefault(require("path"));
|
|
17
|
-
const tmp_1 = __importDefault(require("tmp"));
|
|
18
|
-
const promises_1 = require("fs/promises");
|
|
19
|
-
const logger_1 = require("./logger");
|
|
20
|
-
const proper_lockfile_1 = __importDefault(require("proper-lockfile"));
|
|
21
|
-
function withFileLock(fileName, fn) {
|
|
22
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
-
const file = yield createEmptyTmpFile(fileName);
|
|
24
|
-
let releaseLockFn;
|
|
25
|
-
try {
|
|
26
|
-
logger_1.log.debug(`Acquiring lock file "${file}"...`);
|
|
27
|
-
releaseLockFn = yield proper_lockfile_1.default.lock(file, { retries: { forever: true } });
|
|
28
|
-
logger_1.log.debug(`Acquired lock file "${file}"`);
|
|
29
|
-
return yield fn();
|
|
30
|
-
}
|
|
31
|
-
finally {
|
|
32
|
-
if (releaseLockFn) {
|
|
33
|
-
logger_1.log.debug(`Releasing lock file "${file}"...`);
|
|
34
|
-
yield releaseLockFn();
|
|
35
|
-
logger_1.log.debug(`Released lock file "${file}"`);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
exports.withFileLock = withFileLock;
|
|
41
|
-
function createEmptyTmpFile(fileName) {
|
|
42
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
-
const file = path_1.default.resolve(tmp_1.default.tmpdir, fileName);
|
|
44
|
-
yield (0, promises_1.writeFile)(file, "");
|
|
45
|
-
return file;
|
|
46
|
-
});
|
|
47
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.initCreateContainerOptions = void 0;
|
|
4
|
-
const initCreateContainerOptions = (imageName, autoRemove) => ({
|
|
5
|
-
imageName,
|
|
6
|
-
autoRemove,
|
|
7
|
-
environment: {},
|
|
8
|
-
exposedPorts: [],
|
|
9
|
-
command: [],
|
|
10
|
-
bindMounts: [],
|
|
11
|
-
labels: {},
|
|
12
|
-
tmpFs: {},
|
|
13
|
-
useDefaultLogDriver: false,
|
|
14
|
-
privilegedMode: false,
|
|
15
|
-
reusable: false,
|
|
16
|
-
extraHosts: [],
|
|
17
|
-
});
|
|
18
|
-
exports.initCreateContainerOptions = initCreateContainerOptions;
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.GenericContainerBuilder = void 0;
|
|
16
|
-
const pull_policy_1 = require("../pull-policy");
|
|
17
|
-
const uuid_1 = require("../uuid");
|
|
18
|
-
const docker_image_name_1 = require("../docker-image-name");
|
|
19
|
-
const path_1 = __importDefault(require("path"));
|
|
20
|
-
const logger_1 = require("../logger");
|
|
21
|
-
const dockerfile_parser_1 = require("../dockerfile-parser");
|
|
22
|
-
const build_image_1 = require("../docker/functions/image/build-image");
|
|
23
|
-
const get_auth_config_1 = require("../registry-auth-locator/get-auth-config");
|
|
24
|
-
const generic_container_1 = require("./generic-container");
|
|
25
|
-
const docker_client_1 = require("../docker/client/docker-client");
|
|
26
|
-
const image_exists_1 = require("../docker/functions/image/image-exists");
|
|
27
|
-
class GenericContainerBuilder {
|
|
28
|
-
constructor(context, dockerfileName, uuid = new uuid_1.RandomUuid()) {
|
|
29
|
-
this.context = context;
|
|
30
|
-
this.dockerfileName = dockerfileName;
|
|
31
|
-
this.uuid = uuid;
|
|
32
|
-
this.buildArgs = {};
|
|
33
|
-
this.pullPolicy = new pull_policy_1.DefaultPullPolicy();
|
|
34
|
-
this.cache = true;
|
|
35
|
-
}
|
|
36
|
-
withBuildArgs(buildArgs) {
|
|
37
|
-
this.buildArgs = buildArgs;
|
|
38
|
-
return this;
|
|
39
|
-
}
|
|
40
|
-
withPullPolicy(pullPolicy) {
|
|
41
|
-
this.pullPolicy = pullPolicy;
|
|
42
|
-
return this;
|
|
43
|
-
}
|
|
44
|
-
withCache(cache) {
|
|
45
|
-
this.cache = cache;
|
|
46
|
-
return this;
|
|
47
|
-
}
|
|
48
|
-
build(image = `localhost/${this.uuid.nextUuid()}:${this.uuid.nextUuid()}`, options = { deleteOnExit: true }) {
|
|
49
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
50
|
-
const imageName = docker_image_name_1.DockerImageName.fromString(image);
|
|
51
|
-
const { sessionId } = yield (0, docker_client_1.getDockerClient)();
|
|
52
|
-
const dockerfile = path_1.default.resolve(this.context, this.dockerfileName);
|
|
53
|
-
logger_1.log.debug(`Preparing to build Dockerfile "${dockerfile}" as image "${imageName}"...`);
|
|
54
|
-
const imageNames = yield (0, dockerfile_parser_1.getDockerfileImages)(dockerfile, this.buildArgs);
|
|
55
|
-
const { dockerode, info } = yield (0, docker_client_1.getDockerClient)();
|
|
56
|
-
const registryConfig = yield this.getRegistryConfig(info.dockerInfo.indexServerAddress, imageNames);
|
|
57
|
-
yield (0, build_image_1.buildImage)(sessionId, {
|
|
58
|
-
imageName: imageName,
|
|
59
|
-
context: this.context,
|
|
60
|
-
dockerfileName: this.dockerfileName,
|
|
61
|
-
buildArgs: this.buildArgs,
|
|
62
|
-
pullPolicy: this.pullPolicy,
|
|
63
|
-
cache: this.cache,
|
|
64
|
-
deleteOnExit: options.deleteOnExit,
|
|
65
|
-
registryConfig,
|
|
66
|
-
});
|
|
67
|
-
const container = new generic_container_1.GenericContainer(imageName.toString());
|
|
68
|
-
if (!(yield (0, image_exists_1.imageExists)(dockerode, imageName))) {
|
|
69
|
-
throw new Error("Failed to build image");
|
|
70
|
-
}
|
|
71
|
-
return Promise.resolve(container);
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
getRegistryConfig(indexServerAddress, imageNames) {
|
|
75
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
76
|
-
const authConfigs = [];
|
|
77
|
-
yield Promise.all(imageNames.map((imageName) => __awaiter(this, void 0, void 0, function* () {
|
|
78
|
-
var _a;
|
|
79
|
-
const authConfig = yield (0, get_auth_config_1.getAuthConfig)((_a = imageName.registry) !== null && _a !== void 0 ? _a : indexServerAddress);
|
|
80
|
-
if (authConfig !== undefined) {
|
|
81
|
-
authConfigs.push(authConfig);
|
|
82
|
-
}
|
|
83
|
-
})));
|
|
84
|
-
return authConfigs
|
|
85
|
-
.map((authConfig) => {
|
|
86
|
-
return {
|
|
87
|
-
[authConfig.registryAddress]: {
|
|
88
|
-
username: authConfig.username,
|
|
89
|
-
password: authConfig.password,
|
|
90
|
-
},
|
|
91
|
-
};
|
|
92
|
-
})
|
|
93
|
-
.reduce((prev, next) => (Object.assign(Object.assign({}, prev), next)), {});
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
exports.GenericContainerBuilder = GenericContainerBuilder;
|
|
@@ -1,329 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.GenericContainer = void 0;
|
|
16
|
-
const archiver_1 = __importDefault(require("archiver"));
|
|
17
|
-
const async_lock_1 = __importDefault(require("async-lock"));
|
|
18
|
-
const bound_ports_1 = require("../bound-ports");
|
|
19
|
-
const logger_1 = require("../logger");
|
|
20
|
-
const pull_policy_1 = require("../pull-policy");
|
|
21
|
-
const docker_image_name_1 = require("../docker-image-name");
|
|
22
|
-
const port_forwarder_1 = require("../port-forwarder");
|
|
23
|
-
const pull_image_1 = require("../docker/functions/image/pull-image");
|
|
24
|
-
const create_container_1 = require("../docker/functions/container/create-container");
|
|
25
|
-
const connect_network_1 = require("../docker/functions/network/connect-network");
|
|
26
|
-
const docker_client_1 = require("../docker/client/docker-client");
|
|
27
|
-
const inspect_container_1 = require("../docker/functions/container/inspect-container");
|
|
28
|
-
const start_container_1 = require("../docker/functions/container/start-container");
|
|
29
|
-
const container_logs_1 = require("../docker/functions/container/container-logs");
|
|
30
|
-
const put_container_archive_1 = require("../docker/functions/container/put-container-archive");
|
|
31
|
-
const generic_container_builder_1 = require("./generic-container-builder");
|
|
32
|
-
const started_generic_container_1 = require("./started-generic-container");
|
|
33
|
-
const hash_1 = require("../hash");
|
|
34
|
-
const get_container_1 = require("../docker/functions/container/get-container");
|
|
35
|
-
const labels_1 = require("../labels");
|
|
36
|
-
const wait_for_container_1 = require("../wait-for-container");
|
|
37
|
-
const create_container_options_1 = require("./create-container-options");
|
|
38
|
-
const wait_1 = require("../wait-strategy/wait");
|
|
39
|
-
const reusableContainerCreationLock = new async_lock_1.default();
|
|
40
|
-
class GenericContainer {
|
|
41
|
-
static fromDockerfile(context, dockerfileName = "Dockerfile") {
|
|
42
|
-
return new generic_container_builder_1.GenericContainerBuilder(context, dockerfileName);
|
|
43
|
-
}
|
|
44
|
-
constructor(image) {
|
|
45
|
-
this.image = image;
|
|
46
|
-
this.waitStrategy = wait_1.Wait.forListeningPorts();
|
|
47
|
-
this.networkAliases = [];
|
|
48
|
-
this.pullPolicy = new pull_policy_1.DefaultPullPolicy();
|
|
49
|
-
this.filesToCopy = [];
|
|
50
|
-
this.directoriesToCopy = [];
|
|
51
|
-
this.contentsToCopy = [];
|
|
52
|
-
const imageName = docker_image_name_1.DockerImageName.fromString(image);
|
|
53
|
-
this.opts = (0, create_container_options_1.initCreateContainerOptions)(imageName, imageName.isReaper());
|
|
54
|
-
}
|
|
55
|
-
start() {
|
|
56
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
-
const dockerClient = yield (0, docker_client_1.getDockerClient)();
|
|
58
|
-
yield (0, pull_image_1.pullImage)(dockerClient.dockerode, dockerClient.info.dockerInfo.indexServerAddress, {
|
|
59
|
-
imageName: this.opts.imageName,
|
|
60
|
-
force: this.pullPolicy.shouldPull(),
|
|
61
|
-
});
|
|
62
|
-
if (this.beforeContainerStarted) {
|
|
63
|
-
yield this.beforeContainerStarted();
|
|
64
|
-
}
|
|
65
|
-
else if (this.preStart) {
|
|
66
|
-
yield this.preStart();
|
|
67
|
-
}
|
|
68
|
-
if (!this.opts.imageName.isHelperContainer() && port_forwarder_1.PortForwarderInstance.isRunning()) {
|
|
69
|
-
const portForwarder = yield port_forwarder_1.PortForwarderInstance.getInstance();
|
|
70
|
-
this.opts.extraHosts.push({ host: "host.testcontainers.internal", ipAddress: portForwarder.getIpAddress() });
|
|
71
|
-
}
|
|
72
|
-
this.opts.networkMode = this.networkAliases.length > 0 ? undefined : this.networkMode;
|
|
73
|
-
if (this.opts.reusable) {
|
|
74
|
-
return this.reuseOrStartContainer(dockerClient);
|
|
75
|
-
}
|
|
76
|
-
return this.startContainer(dockerClient, this.opts);
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
reuseOrStartContainer(dockerClient) {
|
|
80
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
81
|
-
const containerHash = (0, hash_1.hash)(JSON.stringify(this.opts));
|
|
82
|
-
this.opts.labels = Object.assign(Object.assign({}, this.opts.labels), { [labels_1.LABEL_TESTCONTAINERS_CONTAINER_HASH]: containerHash });
|
|
83
|
-
logger_1.log.debug(`Container reuse has been enabled with hash "${containerHash}"`);
|
|
84
|
-
return reusableContainerCreationLock.acquire(containerHash, () => __awaiter(this, void 0, void 0, function* () {
|
|
85
|
-
const container = yield (0, get_container_1.getContainerByHash)(containerHash);
|
|
86
|
-
if (container !== undefined) {
|
|
87
|
-
logger_1.log.debug(`Found container to reuse with hash "${containerHash}"`, { containerId: container.id });
|
|
88
|
-
return this.reuseContainer(dockerClient, container);
|
|
89
|
-
}
|
|
90
|
-
logger_1.log.debug("No container found to reuse");
|
|
91
|
-
return this.startContainer(dockerClient, this.opts);
|
|
92
|
-
}));
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
reuseContainer(dockerClient, container) {
|
|
96
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
97
|
-
const inspectResult = yield (0, inspect_container_1.inspectContainer)(container);
|
|
98
|
-
const boundPorts = bound_ports_1.BoundPorts.fromInspectResult(dockerClient.hostIps, inspectResult).filter(this.opts.exposedPorts);
|
|
99
|
-
if (this.startupTimeout !== undefined) {
|
|
100
|
-
this.waitStrategy.withStartupTimeout(this.startupTimeout);
|
|
101
|
-
}
|
|
102
|
-
if (this.containerStarting) {
|
|
103
|
-
yield this.containerStarting(inspectResult, true);
|
|
104
|
-
}
|
|
105
|
-
yield (0, wait_for_container_1.waitForContainer)(container, this.waitStrategy, boundPorts);
|
|
106
|
-
const startedContainer = new started_generic_container_1.StartedGenericContainer(container, dockerClient.host, inspectResult, boundPorts, inspectResult.name, this.waitStrategy);
|
|
107
|
-
if (this.containerStarted) {
|
|
108
|
-
yield this.containerStarted(startedContainer, inspectResult, true);
|
|
109
|
-
}
|
|
110
|
-
else if (this.postStart) {
|
|
111
|
-
yield this.postStart(startedContainer, inspectResult, boundPorts);
|
|
112
|
-
}
|
|
113
|
-
return startedContainer;
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
startContainer(dockerClient, createContainerOptions) {
|
|
117
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
118
|
-
const container = yield (0, create_container_1.createContainer)(dockerClient.sessionId, createContainerOptions);
|
|
119
|
-
if (!this.opts.imageName.isHelperContainer() && port_forwarder_1.PortForwarderInstance.isRunning()) {
|
|
120
|
-
yield this.connectContainerToPortForwarder(container);
|
|
121
|
-
}
|
|
122
|
-
if (this.networkMode && this.networkAliases.length > 0) {
|
|
123
|
-
yield (0, connect_network_1.connectNetwork)({
|
|
124
|
-
containerId: container.id,
|
|
125
|
-
networkId: this.networkMode,
|
|
126
|
-
networkAliases: this.networkAliases,
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
if (this.filesToCopy.length > 0 || this.directoriesToCopy.length > 0 || this.contentsToCopy.length > 0) {
|
|
130
|
-
const archive = this.createArchiveToCopyToContainer();
|
|
131
|
-
archive.finalize();
|
|
132
|
-
yield (0, put_container_archive_1.putContainerArchive)({ container, stream: archive, containerPath: "/" });
|
|
133
|
-
}
|
|
134
|
-
logger_1.log.info(`Starting container for image "${this.opts.imageName}"...`, { containerId: container.id });
|
|
135
|
-
if (this.containerCreated) {
|
|
136
|
-
yield this.containerCreated(container.id);
|
|
137
|
-
}
|
|
138
|
-
yield (0, start_container_1.startContainer)(container);
|
|
139
|
-
logger_1.log.info(`Started container for image "${this.opts.imageName}"`, { containerId: container.id });
|
|
140
|
-
const inspectResult = yield (0, inspect_container_1.inspectContainer)(container);
|
|
141
|
-
const boundPorts = bound_ports_1.BoundPorts.fromInspectResult(dockerClient.hostIps, inspectResult).filter(this.opts.exposedPorts);
|
|
142
|
-
if (this.startupTimeout !== undefined) {
|
|
143
|
-
this.waitStrategy.withStartupTimeout(this.startupTimeout);
|
|
144
|
-
}
|
|
145
|
-
if (logger_1.containerLog.enabled() || this.logConsumer !== undefined) {
|
|
146
|
-
if (this.logConsumer !== undefined) {
|
|
147
|
-
this.logConsumer(yield (0, container_logs_1.containerLogs)(container));
|
|
148
|
-
}
|
|
149
|
-
if (logger_1.containerLog.enabled()) {
|
|
150
|
-
(yield (0, container_logs_1.containerLogs)(container))
|
|
151
|
-
.on("data", (data) => logger_1.containerLog.trace(data.trim(), { containerId: container.id }))
|
|
152
|
-
.on("err", (data) => logger_1.containerLog.error(data.trim(), { containerId: container.id }));
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
if (this.containerStarting) {
|
|
156
|
-
yield this.containerStarting(inspectResult, false);
|
|
157
|
-
}
|
|
158
|
-
yield (0, wait_for_container_1.waitForContainer)(container, this.waitStrategy, boundPorts);
|
|
159
|
-
const startedContainer = new started_generic_container_1.StartedGenericContainer(container, dockerClient.host, inspectResult, boundPorts, inspectResult.name, this.waitStrategy);
|
|
160
|
-
if (this.containerStarted) {
|
|
161
|
-
yield this.containerStarted(startedContainer, inspectResult, false);
|
|
162
|
-
}
|
|
163
|
-
else if (this.postStart) {
|
|
164
|
-
yield this.postStart(startedContainer, inspectResult, boundPorts);
|
|
165
|
-
}
|
|
166
|
-
return startedContainer;
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
connectContainerToPortForwarder(container) {
|
|
170
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
171
|
-
const portForwarder = yield port_forwarder_1.PortForwarderInstance.getInstance();
|
|
172
|
-
const portForwarderNetworkId = portForwarder.getNetworkId();
|
|
173
|
-
const excludedNetworks = [portForwarderNetworkId, "none", "host"];
|
|
174
|
-
if (!this.networkMode || !excludedNetworks.includes(this.networkMode)) {
|
|
175
|
-
yield (0, connect_network_1.connectNetwork)({
|
|
176
|
-
containerId: container.id,
|
|
177
|
-
networkId: portForwarderNetworkId,
|
|
178
|
-
networkAliases: [],
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
createArchiveToCopyToContainer() {
|
|
184
|
-
const tar = (0, archiver_1.default)("tar");
|
|
185
|
-
for (const { source, target, mode } of this.filesToCopy) {
|
|
186
|
-
tar.file(source, { name: target, mode });
|
|
187
|
-
}
|
|
188
|
-
for (const { source, target, mode } of this.directoriesToCopy) {
|
|
189
|
-
tar.directory(source, target, { mode });
|
|
190
|
-
}
|
|
191
|
-
for (const { content, target, mode } of this.contentsToCopy) {
|
|
192
|
-
tar.append(content, { name: target, mode });
|
|
193
|
-
}
|
|
194
|
-
return tar;
|
|
195
|
-
}
|
|
196
|
-
get hasExposedPorts() {
|
|
197
|
-
return this.opts.exposedPorts.length !== 0;
|
|
198
|
-
}
|
|
199
|
-
withCommand(command) {
|
|
200
|
-
this.opts.command = command;
|
|
201
|
-
return this;
|
|
202
|
-
}
|
|
203
|
-
withEntrypoint(entrypoint) {
|
|
204
|
-
this.opts.entrypoint = entrypoint;
|
|
205
|
-
return this;
|
|
206
|
-
}
|
|
207
|
-
withName(name) {
|
|
208
|
-
this.opts.name = name;
|
|
209
|
-
return this;
|
|
210
|
-
}
|
|
211
|
-
withLabels(labels) {
|
|
212
|
-
this.opts.labels = Object.assign(Object.assign({}, this.opts.labels), labels);
|
|
213
|
-
return this;
|
|
214
|
-
}
|
|
215
|
-
withEnvironment(environment) {
|
|
216
|
-
this.opts.environment = Object.assign(Object.assign({}, this.opts.environment), environment);
|
|
217
|
-
return this;
|
|
218
|
-
}
|
|
219
|
-
withTmpFs(tmpFs) {
|
|
220
|
-
this.opts.tmpFs = Object.assign(Object.assign({}, this.opts.tmpFs), tmpFs);
|
|
221
|
-
return this;
|
|
222
|
-
}
|
|
223
|
-
withUlimits(ulimits) {
|
|
224
|
-
this.opts.ulimits = Object.assign(Object.assign({}, this.opts.ulimits), ulimits);
|
|
225
|
-
return this;
|
|
226
|
-
}
|
|
227
|
-
withAddedCapabilities(...capabilities) {
|
|
228
|
-
var _a;
|
|
229
|
-
this.opts.addedCapabilities = [...((_a = this.opts.addedCapabilities) !== null && _a !== void 0 ? _a : []), ...capabilities];
|
|
230
|
-
return this;
|
|
231
|
-
}
|
|
232
|
-
withDroppedCapabilities(...capabilities) {
|
|
233
|
-
var _a;
|
|
234
|
-
this.opts.droppedCapabilities = [...((_a = this.opts.droppedCapabilities) !== null && _a !== void 0 ? _a : []), ...capabilities];
|
|
235
|
-
return this;
|
|
236
|
-
}
|
|
237
|
-
withNetwork(network) {
|
|
238
|
-
this.networkMode = network.getName();
|
|
239
|
-
return this;
|
|
240
|
-
}
|
|
241
|
-
withNetworkMode(networkMode) {
|
|
242
|
-
this.networkMode = networkMode;
|
|
243
|
-
return this;
|
|
244
|
-
}
|
|
245
|
-
withNetworkAliases(...networkAliases) {
|
|
246
|
-
this.networkAliases = [...this.networkAliases, ...networkAliases];
|
|
247
|
-
return this;
|
|
248
|
-
}
|
|
249
|
-
withExtraHosts(extraHosts) {
|
|
250
|
-
this.opts.extraHosts = [...this.opts.extraHosts, ...extraHosts];
|
|
251
|
-
return this;
|
|
252
|
-
}
|
|
253
|
-
withExposedPorts(...ports) {
|
|
254
|
-
this.opts.exposedPorts = [...this.opts.exposedPorts, ...ports];
|
|
255
|
-
return this;
|
|
256
|
-
}
|
|
257
|
-
withBindMounts(bindMounts) {
|
|
258
|
-
this.opts.bindMounts = bindMounts.map((bindMount) => (Object.assign({ mode: "rw" }, bindMount)));
|
|
259
|
-
return this;
|
|
260
|
-
}
|
|
261
|
-
withHealthCheck(healthCheck) {
|
|
262
|
-
this.opts.healthCheck = healthCheck;
|
|
263
|
-
return this;
|
|
264
|
-
}
|
|
265
|
-
withStartupTimeout(startupTimeoutMs) {
|
|
266
|
-
this.startupTimeout = startupTimeoutMs;
|
|
267
|
-
return this;
|
|
268
|
-
}
|
|
269
|
-
withWaitStrategy(waitStrategy) {
|
|
270
|
-
this.waitStrategy = waitStrategy;
|
|
271
|
-
return this;
|
|
272
|
-
}
|
|
273
|
-
withDefaultLogDriver() {
|
|
274
|
-
this.opts.useDefaultLogDriver = true;
|
|
275
|
-
return this;
|
|
276
|
-
}
|
|
277
|
-
withPrivilegedMode() {
|
|
278
|
-
this.opts.privilegedMode = true;
|
|
279
|
-
return this;
|
|
280
|
-
}
|
|
281
|
-
withUser(user) {
|
|
282
|
-
this.opts.user = user;
|
|
283
|
-
return this;
|
|
284
|
-
}
|
|
285
|
-
withReuse() {
|
|
286
|
-
this.opts.reusable = true;
|
|
287
|
-
return this;
|
|
288
|
-
}
|
|
289
|
-
withPullPolicy(pullPolicy) {
|
|
290
|
-
this.pullPolicy = pullPolicy;
|
|
291
|
-
return this;
|
|
292
|
-
}
|
|
293
|
-
withIpcMode(ipcMode) {
|
|
294
|
-
this.opts.ipcMode = ipcMode;
|
|
295
|
-
return this;
|
|
296
|
-
}
|
|
297
|
-
withCopyFilesToContainer(filesToCopy) {
|
|
298
|
-
this.filesToCopy = [...this.filesToCopy, ...filesToCopy];
|
|
299
|
-
return this;
|
|
300
|
-
}
|
|
301
|
-
withCopyDirectoriesToContainer(directoriesToCopy) {
|
|
302
|
-
this.directoriesToCopy = [...this.directoriesToCopy, ...directoriesToCopy];
|
|
303
|
-
return this;
|
|
304
|
-
}
|
|
305
|
-
withCopyContentToContainer(contentsToCopy) {
|
|
306
|
-
this.contentsToCopy = [...this.contentsToCopy, ...contentsToCopy];
|
|
307
|
-
return this;
|
|
308
|
-
}
|
|
309
|
-
withWorkingDir(workingDir) {
|
|
310
|
-
this.opts.workingDir = workingDir;
|
|
311
|
-
return this;
|
|
312
|
-
}
|
|
313
|
-
withResourcesQuota({ memory, cpu }) {
|
|
314
|
-
this.opts.resourcesQuota = {
|
|
315
|
-
memory: memory !== undefined ? memory * Math.pow(1024, 3) : undefined,
|
|
316
|
-
cpu: cpu !== undefined ? cpu * Math.pow(10, 9) : undefined,
|
|
317
|
-
};
|
|
318
|
-
return this;
|
|
319
|
-
}
|
|
320
|
-
withSharedMemorySize(bytes) {
|
|
321
|
-
this.opts.sharedMemorySize = bytes;
|
|
322
|
-
return this;
|
|
323
|
-
}
|
|
324
|
-
withLogConsumer(logConsumer) {
|
|
325
|
-
this.logConsumer = logConsumer;
|
|
326
|
-
return this;
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
exports.GenericContainer = GenericContainer;
|