Skip to content
Snippets Groups Projects
Select Git revision
  • 79a3df8a72fd970e672f850836d2c3df4875fe3b
  • master default protected
  • 551-init-broker-service-permissions
  • dev protected
  • release-1.10 protected
  • 549-test-oai-pmh
  • 545-saving-multiple-times-breaks-pid-metadata
  • release-1.9 protected
  • 499-standalone-compute-service-2
  • 539-load-tests
  • hotfix/helm-chart
  • luca_ba_new_interface
  • 534-bug-when-adding-access-to-user-that-is-not-registered-at-dashboard-service
  • release-1.8 protected
  • 533-integrate-semantic-recommendation
  • feature/openshift
  • 518-spark-doesn-t-map-the-headers-correct
  • 485-fixity-checks
  • 530-various-schema-problems-with-subsets
  • release-1.7 protected
  • fix/auth-service
  • v1.10.1 protected
  • v1.10.0-rc13 protected
  • v1.10.0-rc12 protected
  • v1.10.0-rc11 protected
  • v1.10.0-rc10 protected
  • v1.10.0-rc9 protected
  • v1.10.0-rc8 protected
  • v1.10.0-rc7 protected
  • v1.10.0-rc6 protected
  • v1.10.0-rc5 protected
  • v1.10.0-rc4 protected
  • v1.10.0-rc3 protected
  • v1.10.0-rc2 protected
  • v1.10.0rc1 protected
  • v1.10.0rc0 protected
  • v1.10.0 protected
  • v1.9.3 protected
  • v1.9.2 protected
  • v1.9.2-rc0 protected
  • v1.9.1 protected
41 results

TusdContainerConfig.java

Blame
  • TusdContainerConfig.java 2.08 KiB
    package at.tuwien.config;
    
    import org.springframework.context.annotation.Bean;
    import org.springframework.context.annotation.Configuration;
    import org.testcontainers.containers.BindMode;
    import org.testcontainers.containers.GenericContainer;
    import org.testcontainers.images.PullPolicy;
    
    import java.io.File;
    
    @Configuration
    public class TusdContainerConfig {
    
        public static TusdContainer getContainer() {
            return TusdContainer.getInstance();
        }
    
        @Bean
        public TusdContainer tusdContainer() {
            return getContainer();
        }
    
        /**
         * This class represents the customized MariaDB container. It is a singleton to avoid the recreation of containers
         * which can be very time-consuming.
         */
        public static class TusdContainer extends GenericContainer<TusdContainer> {
    
            private static TusdContainer instance;
    
            private boolean started = false;
    
            public static synchronized TusdContainer getInstance() {
                final File filePath = new File("pre-create.sh");
                if (instance == null) {
                    instance = new TusdContainer("tusproject/tusd:v2.4.0");
                    instance.withFileSystemBind(filePath.getAbsolutePath(), "/srv/tusd-hooks/pre-create", BindMode.READ_ONLY);
                    instance.withExposedPorts(8080);
                    instance.withCommand("-max-size=2000000000",
                            "-base-path=/api/upload/files/",
                            "-hooks-dir=/srv/tusd-hooks/");
                    instance.withImagePullPolicy(PullPolicy.alwaysPull());
                }
                return instance;
            }
    
            private TusdContainer(String dockerImageName) {
                super(dockerImageName);
            }
    
            @Override
            protected void configure() {
                super.configure();
            }
    
            @Override
            public synchronized void start() {
                if (!started) {
                    super.stop();
                    super.start();
                    started = true;
                }
            }
    
            @Override
            public void stop() {
                // do nothing, JVM handles shut down
            }
        }
    }