Class: Testcontainers::NginxContainer
- Inherits:
-
DockerContainer
- Object
- DockerContainer
- Testcontainers::NginxContainer
- Defined in:
- lib/testcontainers/nginx.rb
Overview
NginxContainer class is used to manage containers that run an NGINX server
Constant Summary collapse
- NGINX_DEFAULT_PORT =
Default port used by the container
80
- NGINX_DEFAULT_IMAGE =
Default image used by the container
"nginx:latest"
Instance Method Summary collapse
-
#initialize(image = NGINX_DEFAULT_IMAGE, port: nil, **kwargs) ⇒ NginxContainer
constructor
Initializes a new instance of NginxContainer.
-
#port ⇒ Integer
Returns the port used by the container.
-
#server_url(protocol: "http") ⇒ String
Returns the server url (e.g. host:port).
-
#start ⇒ NginxContainer
Starts the container.
Constructor Details
#initialize(image = NGINX_DEFAULT_IMAGE, port: nil, **kwargs) ⇒ NginxContainer
Initializes a new instance of NginxContainer
19 20 21 22 |
# File 'lib/testcontainers/nginx.rb', line 19 def initialize(image = NGINX_DEFAULT_IMAGE, port: nil, **kwargs) super(image, **kwargs) @wait_for ||= add_wait_for(:logs, /start worker process/) end |
Instance Method Details
#port ⇒ Integer
Returns the port used by the container
35 36 37 |
# File 'lib/testcontainers/nginx.rb', line 35 def port NGINX_DEFAULT_PORT end |
#server_url(protocol: "http") ⇒ String
Returns the server url (e.g. host:port)
45 46 47 |
# File 'lib/testcontainers/nginx.rb', line 45 def server_url(protocol: "http") "#{protocol}://#{host}:#{mapped_port(port)}" end |
#start ⇒ NginxContainer
Starts the container
27 28 29 30 |
# File 'lib/testcontainers/nginx.rb', line 27 def start with_exposed_ports(port) super end |