package com.iqser.red.service.peristence.v1.server.integration.utils;

import org.testcontainers.containers.GenericContainer;
import org.testcontainers.utility.DockerImageName;

public final class MongoDBTestContainer extends GenericContainer<MongoDBTestContainer> {

    private static final String IMAGE_VERSION = "mongo:7.0.2";
    public static final Integer MONGO_PORT = 27017;
    public static final String MONGO_DATABASE = "redaction";
    public static final String MONGO_PASSWORD = "mongopassword";
    public static final String MONGO_USERNAME = "mongousername";
    private static MongoDBTestContainer mongoDB;


    private MongoDBTestContainer() {

        super(DockerImageName.parse(IMAGE_VERSION));

    }


    public static MongoDBTestContainer getInstance() {

        if (mongoDB == null) {
            mongoDB = new MongoDBTestContainer().withEnv("MONGO_INITDB_ROOT_USERNAME", MONGO_USERNAME)
                    .withEnv("MONGO_INITDB_ROOT_PASSWORD", MONGO_PASSWORD)
                    .withEnv("MONGO_INITDB_DATABASE", MONGO_DATABASE)
                    .withExposedPorts(MONGO_PORT);

        }
        return mongoDB;
    }

}
