testcontainers-nginx 0.1.0
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.
- checksums.yaml +7 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +76 -0
- data/LICENSE.txt +21 -0
- data/README.md +98 -0
- data/Rakefile +14 -0
- data/lib/testcontainers/nginx/version.rb +7 -0
- data/lib/testcontainers/nginx.rb +49 -0
- metadata +125 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3fe5ec01455e273dc09c0c3b47d7d9a77fe16a856ee9cd534501e9f62ae3dec9
|
4
|
+
data.tar.gz: e32791132bec474f8fe6c498c9700d42946c8e8a923e4675bab790eaa64762a4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e1106b7dbf2c1c5b811e03997a4f6b8ef98e9bdcb982b8d51ca64d6a5040f6045d5b8a9499194ba09778bd52aeabf427b04787003a5d178871048b10e0d650e1
|
7
|
+
data.tar.gz: 195ba2471772b690322ea3733d87c2303fe793a4bc3d4d117dc47711b974126cbc2ed057f8294e696d15225a03d0a9f3d2f1537ab210daebf006d070a9f6894a
|
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ../core
|
3
|
+
specs:
|
4
|
+
testcontainers-core (0.1.3)
|
5
|
+
docker-api (~> 2.2)
|
6
|
+
|
7
|
+
PATH
|
8
|
+
remote: .
|
9
|
+
specs:
|
10
|
+
testcontainers-nginx (0.1.0)
|
11
|
+
testcontainers-core (~> 0.1.3)
|
12
|
+
|
13
|
+
GEM
|
14
|
+
remote: https://rubygems.org/
|
15
|
+
specs:
|
16
|
+
ast (2.4.2)
|
17
|
+
docker-api (2.2.0)
|
18
|
+
excon (>= 0.47.0)
|
19
|
+
multi_json
|
20
|
+
excon (0.99.0)
|
21
|
+
json (2.6.3)
|
22
|
+
language_server-protocol (3.17.0.3)
|
23
|
+
lint_roller (1.0.0)
|
24
|
+
minitest (5.18.0)
|
25
|
+
minitest-hooks (1.5.0)
|
26
|
+
minitest (> 5.3)
|
27
|
+
multi_json (1.15.0)
|
28
|
+
parallel (1.23.0)
|
29
|
+
parser (3.2.2.1)
|
30
|
+
ast (~> 2.4.1)
|
31
|
+
rainbow (3.1.1)
|
32
|
+
rake (13.0.6)
|
33
|
+
regexp_parser (2.8.0)
|
34
|
+
rexml (3.2.5)
|
35
|
+
rubocop (1.50.2)
|
36
|
+
json (~> 2.3)
|
37
|
+
parallel (~> 1.10)
|
38
|
+
parser (>= 3.2.0.0)
|
39
|
+
rainbow (>= 2.2.2, < 4.0)
|
40
|
+
regexp_parser (>= 1.8, < 3.0)
|
41
|
+
rexml (>= 3.2.5, < 4.0)
|
42
|
+
rubocop-ast (>= 1.28.0, < 2.0)
|
43
|
+
ruby-progressbar (~> 1.7)
|
44
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
45
|
+
rubocop-ast (1.28.1)
|
46
|
+
parser (>= 3.2.1.0)
|
47
|
+
rubocop-performance (1.16.0)
|
48
|
+
rubocop (>= 1.7.0, < 2.0)
|
49
|
+
rubocop-ast (>= 0.4.0)
|
50
|
+
ruby-progressbar (1.13.0)
|
51
|
+
standard (1.28.2)
|
52
|
+
language_server-protocol (~> 3.17.0.2)
|
53
|
+
lint_roller (~> 1.0)
|
54
|
+
rubocop (~> 1.50.2)
|
55
|
+
standard-custom (~> 1.0.0)
|
56
|
+
standard-performance (~> 1.0.1)
|
57
|
+
standard-custom (1.0.0)
|
58
|
+
lint_roller (~> 1.0)
|
59
|
+
standard-performance (1.0.1)
|
60
|
+
lint_roller (~> 1.0)
|
61
|
+
rubocop-performance (~> 1.16.0)
|
62
|
+
unicode-display_width (2.4.2)
|
63
|
+
|
64
|
+
PLATFORMS
|
65
|
+
arm64-darwin-21
|
66
|
+
|
67
|
+
DEPENDENCIES
|
68
|
+
minitest (~> 5.0)
|
69
|
+
minitest-hooks (~> 1.5)
|
70
|
+
rake (~> 13.0)
|
71
|
+
standard (~> 1.3)
|
72
|
+
testcontainers-core!
|
73
|
+
testcontainers-nginx!
|
74
|
+
|
75
|
+
BUNDLED WITH
|
76
|
+
2.4.1
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2023 Guillermo Iguaran
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
# Testcontainers module for Nginx
|
2
|
+
|
3
|
+
testcontainers-nginx simplifies the creation and management of Nginx containers for testing purposes using the Testcontainers library.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add the library to the test section in your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
group :test do
|
11
|
+
gem 'testcontainers-nginx'
|
12
|
+
end
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
```bash
|
18
|
+
$ bundle install
|
19
|
+
```
|
20
|
+
|
21
|
+
Or install it yourself as:
|
22
|
+
|
23
|
+
```bash
|
24
|
+
$ gem install testcontainers-nginx
|
25
|
+
```
|
26
|
+
|
27
|
+
## Usage
|
28
|
+
|
29
|
+
To use the library, you first need to require it:
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
require 'testcontainers/nginx'
|
33
|
+
```
|
34
|
+
|
35
|
+
### Creating a Nginx container
|
36
|
+
|
37
|
+
Create a new instance of the `Testcontainers::NginxContainer` class:
|
38
|
+
|
39
|
+
```ruby
|
40
|
+
container = Testcontainers::NginxContainer.new
|
41
|
+
```
|
42
|
+
|
43
|
+
|
44
|
+
This creates a new container with the default Nginx image and port. You can customize these by passing arguments to the constructor:
|
45
|
+
|
46
|
+
```ruby
|
47
|
+
container = Testcontainers::MysqlContainer.new("nginx:alpine", port: 8080)
|
48
|
+
```
|
49
|
+
|
50
|
+
You can setup filesystem binds to configure the container with custom configuration files or to serve content from a custom path:
|
51
|
+
|
52
|
+
```ruby
|
53
|
+
container.with_filesystem_binds(["/local/path/custom/conf:/etc/nginx/conf.d:ro"])
|
54
|
+
container.with_filesystem_binds(["/local/path/custom/content:/usr/share/nginx/html:ro"])
|
55
|
+
```
|
56
|
+
|
57
|
+
### Starting and stopping the container
|
58
|
+
|
59
|
+
Start the container:
|
60
|
+
|
61
|
+
```ruby
|
62
|
+
container.start
|
63
|
+
```
|
64
|
+
|
65
|
+
Stop the container when you're done:
|
66
|
+
|
67
|
+
```ruby
|
68
|
+
container.stop
|
69
|
+
```
|
70
|
+
|
71
|
+
### Connecting to the Nginx container
|
72
|
+
|
73
|
+
Once the container is running, you can obtain the connection details using the following methods:
|
74
|
+
|
75
|
+
```ruby
|
76
|
+
host = container.host
|
77
|
+
port = container.first_mapped_port
|
78
|
+
```
|
79
|
+
|
80
|
+
|
81
|
+
Or, you can generate a full server URL:
|
82
|
+
|
83
|
+
```ruby
|
84
|
+
server_url = container.server_url
|
85
|
+
```
|
86
|
+
|
87
|
+
|
88
|
+
## Contributing
|
89
|
+
|
90
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/testcontainers/testcontainers-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/testcontainers/testcontainers-ruby/blob/main/CODE_OF_CONDUCT.md).
|
91
|
+
|
92
|
+
## License
|
93
|
+
|
94
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
95
|
+
|
96
|
+
## Code of Conduct
|
97
|
+
|
98
|
+
Everyone interacting in the Testcontainers project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/testcontainers/testcontainers-ruby/blob/main/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
require "rake/testtask"
|
5
|
+
|
6
|
+
Rake::TestTask.new(:test) do |t|
|
7
|
+
t.libs << "test"
|
8
|
+
t.libs << "lib"
|
9
|
+
t.test_files = FileList["test/**/*_test.rb"]
|
10
|
+
end
|
11
|
+
|
12
|
+
require "standard/rake"
|
13
|
+
|
14
|
+
task default: %i[test standard]
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require_relative "nginx/version"
|
2
|
+
require "testcontainers"
|
3
|
+
|
4
|
+
module Testcontainers
|
5
|
+
# NginxContainer class is used to manage containers that run an NGINX server
|
6
|
+
class NginxContainer < ::Testcontainers::DockerContainer
|
7
|
+
# Default port used by the container
|
8
|
+
NGINX_DEFAULT_PORT = 80
|
9
|
+
|
10
|
+
# Default image used by the container
|
11
|
+
NGINX_DEFAULT_IMAGE = "nginx:latest"
|
12
|
+
|
13
|
+
# Initializes a new instance of NginxContainer
|
14
|
+
#
|
15
|
+
# @param image [String] the image to use
|
16
|
+
# @param port [String] the port to use
|
17
|
+
# @param kwargs [Hash] the options to pass to the container. See {DockerContainer#initialize}
|
18
|
+
# @return [NginxContainer] a new instance of NginxContainer
|
19
|
+
def initialize(image = NGINX_DEFAULT_IMAGE, port: nil, **kwargs)
|
20
|
+
super(image, **kwargs)
|
21
|
+
@wait_for ||= add_wait_for(:logs, /start worker process/)
|
22
|
+
end
|
23
|
+
|
24
|
+
# Starts the container
|
25
|
+
#
|
26
|
+
# @return [NginxContainer] self
|
27
|
+
def start
|
28
|
+
with_exposed_ports(port)
|
29
|
+
super
|
30
|
+
end
|
31
|
+
|
32
|
+
# Returns the port used by the container
|
33
|
+
#
|
34
|
+
# @return [Integer] the port used by the container
|
35
|
+
def port
|
36
|
+
NGINX_DEFAULT_PORT
|
37
|
+
end
|
38
|
+
|
39
|
+
# Returns the server url (e.g. http://host:port)
|
40
|
+
#
|
41
|
+
# @param protocol [String] the protocol to use in the string (default: "http")
|
42
|
+
# @return [String] the server url
|
43
|
+
# @raise [ConnectionError] If the connection to the Docker daemon fails.
|
44
|
+
# @raise [ContainerNotStartedError] If the container has not been started.
|
45
|
+
def server_url(protocol: "http")
|
46
|
+
"#{protocol}://#{host}:#{mapped_port(port)}"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
metadata
ADDED
@@ -0,0 +1,125 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: testcontainers-nginx
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Guillermo Iguaran
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-06-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: testcontainers-core
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.1.3
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.1.3
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '13.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '13.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: minitest-hooks
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.5'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.5'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: standard
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.3'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.3'
|
83
|
+
description: Testcontainers makes it easy to create and clean up container-based dependencies
|
84
|
+
for automated tests.
|
85
|
+
email:
|
86
|
+
- guilleiguaran@gmail.com
|
87
|
+
executables: []
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files: []
|
90
|
+
files:
|
91
|
+
- CHANGELOG.md
|
92
|
+
- Gemfile
|
93
|
+
- Gemfile.lock
|
94
|
+
- LICENSE.txt
|
95
|
+
- README.md
|
96
|
+
- Rakefile
|
97
|
+
- lib/testcontainers/nginx.rb
|
98
|
+
- lib/testcontainers/nginx/version.rb
|
99
|
+
homepage: https://github.com/testcontainers/testcontainers-ruby
|
100
|
+
licenses:
|
101
|
+
- MIT
|
102
|
+
metadata:
|
103
|
+
homepage_uri: https://github.com/testcontainers/testcontainers-ruby/blob/main/nginx
|
104
|
+
source_code_uri: https://github.com/testcontainers/testcontainers-ruby/blob/main/nginx
|
105
|
+
changelog_uri: https://github.com/testcontainers/testcontainers-ruby/blob/main/nginx/CHANGELOG.md
|
106
|
+
post_install_message:
|
107
|
+
rdoc_options: []
|
108
|
+
require_paths:
|
109
|
+
- lib
|
110
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: 2.6.0
|
115
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0'
|
120
|
+
requirements: []
|
121
|
+
rubygems_version: 3.4.1
|
122
|
+
signing_key:
|
123
|
+
specification_version: 4
|
124
|
+
summary: 'Testcontainers for Ruby: Nginx module'
|
125
|
+
test_files: []
|