Search in sources :

Example 1 with DockerfileBuilder

use of org.testcontainers.images.builder.dockerfile.DockerfileBuilder in project testcontainers-java by testcontainers.

the class DockerfileTrait method withDockerfileFromBuilder.

default SELF withDockerfileFromBuilder(Consumer<DockerfileBuilder> builderConsumer) {
    DockerfileBuilder builder = new DockerfileBuilder();
    builderConsumer.accept(builder);
    // return Transferable because we want to build Dockerfile's content lazily
    return ((SELF) this).withFileFromTransferable("Dockerfile", new Transferable() {

        @Getter(lazy = true)
        private final byte[] bytes = builder.build().getBytes();

        @Override
        public long getSize() {
            return getBytes().length;
        }

        @Override
        public String getDescription() {
            return "Dockerfile: " + builder;
        }
    });
}
Also used : DockerfileBuilder(org.testcontainers.images.builder.dockerfile.DockerfileBuilder) Getter(lombok.Getter) Transferable(org.testcontainers.images.builder.Transferable)

Aggregations

Getter (lombok.Getter)1 Transferable (org.testcontainers.images.builder.Transferable)1 DockerfileBuilder (org.testcontainers.images.builder.dockerfile.DockerfileBuilder)1