Search in sources :

Example 1 with ContainerBuilder

use of com.github.qzagarese.dockerunit.annotation.ContainerBuilder in project dockerunit by qzagarese.

the class ConsulDescriptor method setup.

@ContainerBuilder
public CreateContainerCmd setup(CreateContainerCmd cmd) {
    List<ExposedPort> ports = new ArrayList<>(Arrays.asList(cmd.getExposedPorts()));
    ExposedPort dnsPort = ExposedPort.udp(CONSUL_DNS_PORT);
    ports.add(dnsPort);
    ExposedPort consulPort = ExposedPort.tcp(CONSUL_PORT);
    ports.add(consulPort);
    Ports bindings = cmd.getPortBindings();
    if (bindings == null) {
        bindings = new Ports();
    }
    bindings.bind(dnsPort, Binding.bindPort(8600));
    bindings.bind(consulPort, Binding.bindPort(8500));
    return cmd.withExposedPorts(ports).withPortBindings(bindings).withCmd("agent", "-dev", "-client=0.0.0.0", "-enable-script-checks");
}
Also used : ExposedPort(com.github.dockerjava.api.model.ExposedPort) ArrayList(java.util.ArrayList) Ports(com.github.dockerjava.api.model.Ports) ContainerBuilder(com.github.qzagarese.dockerunit.annotation.ContainerBuilder)

Aggregations

ExposedPort (com.github.dockerjava.api.model.ExposedPort)1 Ports (com.github.dockerjava.api.model.Ports)1 ContainerBuilder (com.github.qzagarese.dockerunit.annotation.ContainerBuilder)1 ArrayList (java.util.ArrayList)1