Skip to content

Commit 8f30de0

Browse files
committed
Use dependabot to update docker images in tests
1 parent 455df68 commit 8f30de0

File tree

4 files changed

+30
-15
lines changed

4 files changed

+30
-15
lines changed

.github/dependabot.yml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1-
# To get started with Dependabot version updates, you'll need to specify which
2-
# package ecosystems to update and where the package manifests are located.
3-
# Please see the documentation for all configuration options:
4-
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
5-
61
version: 2
72
updates:
8-
- package-ecosystem: "gradle" # See documentation for possible values
9-
directory: "/" # Location of package manifests
3+
- package-ecosystem: "gradle"
4+
directory: "/"
105
schedule:
116
interval: "weekly"
127
groups:
13-
dependencies:
8+
gradle-deps:
9+
patterns:
10+
- "*"
11+
- package-ecosystem: "docker"
12+
directory: "/"
13+
schedule:
14+
interval: "weekly"
15+
groups:
16+
dockerfiles:
1417
patterns:
1518
- "*"

bosk-mongo/src/test/java/works/bosk/drivers/mongo/internal/MongoService.java

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@
1010
import java.io.IOException;
1111
import java.net.InetSocketAddress;
1212
import java.net.Socket;
13+
import java.nio.file.Paths;
1314
import java.util.Map;
1415
import org.jetbrains.annotations.NotNull;
1516
import org.junit.jupiter.api.TestInfo;
1617
import org.slf4j.Logger;
1718
import org.slf4j.LoggerFactory;
1819
import org.testcontainers.containers.Network;
20+
import org.testcontainers.images.builder.ImageFromDockerfile;
1921
import org.testcontainers.mongodb.MongoDBContainer;
2022
import org.testcontainers.toxiproxy.ToxiproxyContainer;
2123
import org.testcontainers.utility.DockerImageName;
@@ -40,18 +42,22 @@
4042
public class MongoService implements Closeable {
4143
// We do logging in some static initializers, so this needs to be initialized first
4244
private static final Logger LOGGER = LoggerFactory.getLogger(MongoService.class);
43-
44-
private static final DockerImageName MONGODB_IMAGE_NAME = DockerImageName.parse("mongo:8.0");
45-
4645
private final MongoClient mongoClient = MongoClients.create(normalClientSettings);
4746

4847
// Expensive stuff shared among instances as much as possible, hence static
4948
private static final Network NETWORK = Network.newNetwork();
49+
private static final DockerImageName MONGO_IMAGE = newImageFromDockerfile(
50+
"mongo",
51+
"src/test/resources/mongo.dockerfile");
5052
private static final MongoDBContainer MONGO_CONTAINER = mongoContainer();
5153
private static final MongoClientSettings normalClientSettings = mongoClientSettings(
5254
new ServerAddress(MONGO_CONTAINER.getHost(), MONGO_CONTAINER.getFirstMappedPort())
5355
);
5456

57+
public static final DockerImageName TOXIPROXY_IMAGE = newImageFromDockerfile(
58+
"shopify/toxiproxy",
59+
"src/test/resources/toxiproxy.dockerfile");
60+
5561
private static final ToxiproxyContainer TOXIPROXY_CONTAINER = toxiproxyContainer();
5662
private static final ToxiproxyClient TOXIPROXY_CLIENT = createToxiproxyClient();
5763

@@ -113,18 +119,22 @@ private static MongoDBContainer mongoContainer() {
113119
* @return just the {@link MongoDBContainer} with no options, and not yet started
114120
*/
115121
static MongoDBContainer newPlainMongoContainer() {
116-
return new MongoDBContainer(MONGODB_IMAGE_NAME);
122+
return new MongoDBContainer(MONGO_IMAGE);
117123
}
118124

119125
private static ToxiproxyContainer toxiproxyContainer() {
120-
ToxiproxyContainer result = new ToxiproxyContainer(
121-
DockerImageName.parse("ghcr.io/shopify/toxiproxy:2.12.0")
122-
.asCompatibleSubstituteFor("shopify/toxiproxy"))
126+
ToxiproxyContainer result = new ToxiproxyContainer(TOXIPROXY_IMAGE)
123127
.withNetwork(NETWORK);
124128
result.start();
125129
return result;
126130
}
127131

132+
private static DockerImageName newImageFromDockerfile(String otherImageName, String filePath) {
133+
return DockerImageName.parse(new ImageFromDockerfile()
134+
.withDockerfile(Paths.get(filePath)).get()
135+
).asCompatibleSubstituteFor(otherImageName);
136+
}
137+
128138
private static ToxiproxyClient createToxiproxyClient() {
129139
return new ToxiproxyClient(
130140
TOXIPROXY_CONTAINER.getHost(),
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
FROM mongo:8.0.18
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
FROM ghcr.io/shopify/toxiproxy:2.12.0

0 commit comments

Comments
 (0)