@@ -117,6 +117,24 @@ class AppTests {
117
117
val nginx =
118
118
GenericContainer (DockerImageName .parse(" alpine:latest" ))
119
119
.withEnv(" TLS_CERT_PATH" , certDir)
120
+ .withCopyToContainer(
121
+ Transferable .of(
122
+ """
123
+ #!/bin/sh
124
+ apk add openssl
125
+ mkdir -p $certDir
126
+ openssl req -x509 \
127
+ -newkey rsa:4096 -sha256 -nodes \
128
+ -days 365 \
129
+ -subj "/CN=localhost" \
130
+ -addext "subjectAltName=DNS:localhost.com,IP:127.0.0.1" \
131
+ -keyout $key \
132
+ -out $cert
133
+ # -outform der -keyform der
134
+ """
135
+ .trimIndent(),
136
+ 365 ),
137
+ " $certDir /gen-certs.sh" )
120
138
.withCopyToContainer(
121
139
Transferable .of(
122
140
"""
@@ -129,8 +147,8 @@ class AppTests {
129
147
server {
130
148
listen 80 default_server;
131
149
listen [::]:80 default_server;
132
- listen 443 ssl http2 default_server;
133
- listen [::]:443 ssl http2 default_server;
150
+ listen $tlsPort ssl http2 default_server;
151
+ listen [::]:$tlsPort ssl http2 default_server;
134
152
ssl_certificate $cert ;
135
153
ssl_certificate_key $key ;
136
154
location / {
@@ -147,24 +165,6 @@ class AppTests {
147
165
.trimIndent(),
148
166
365 ),
149
167
" /entrypoint.sh" )
150
- .withCopyToContainer(
151
- Transferable .of(
152
- """
153
- #!/bin/sh
154
- apk add openssl
155
- mkdir -p $certDir
156
- openssl req -x509 \
157
- -newkey rsa:4096 -sha256 -nodes \
158
- -days 365 \
159
- -subj "/CN=localhost" \
160
- -addext "subjectAltName=DNS:localhost.com,IP:127.0.0.1" \
161
- -keyout $key \
162
- -out $cert
163
- # -outform der -keyform der
164
- """
165
- .trimIndent(),
166
- 365 ),
167
- " $certDir /gen-certs.sh" )
168
168
.withCommand(" sh" , " -c" , " $certDir /gen-certs.sh && /entrypoint.sh" )
169
169
.withExposedPorts(tlsPort)
170
170
.withLogConsumer(Slf4jLogConsumer (logger, false ))
0 commit comments