diff --git a/cmd/provision.go b/cmd/provision.go index 3537d67..6ee61b2 100644 --- a/cmd/provision.go +++ b/cmd/provision.go @@ -17,6 +17,7 @@ var Provision wisski_distillery.Command = pv{} type pv struct { PHPVersion string `short:"p" long:"php" description:"specific php version to use for instance. Should be one of '8.0', '8.1'."` + IIPServer bool `short:"i" long:"iip-server" description:"enable iip-server inside this instance"` OPCacheDevelopment bool `short:"o" long:"opcache-devel" description:"Include opcache development configuration"` Flavor string `short:"f" long:"flavor" description:"Use specific flavor. Use '--list-flavors' to list flavors. "` ListFlavors bool `short:"l" long:"list-flavors" description:"List all known flavors"` @@ -65,6 +66,7 @@ func (p pv) Run(context wisski_distillery.Context) error { Flavor: p.Flavor, System: models.System{ PHP: p.PHPVersion, + IIPServer: p.IIPServer, OpCacheDevelopment: p.OPCacheDevelopment, ContentSecurityPolicy: p.ContentSecurityPolicy, }, diff --git a/cmd/rebuild.go b/cmd/rebuild.go index 4e5075f..cf2ba2a 100644 --- a/cmd/rebuild.go +++ b/cmd/rebuild.go @@ -20,7 +20,9 @@ type rebuild struct { System bool `short:"s" long:"system-update" description:"Update the system configuration according to other flags"` PHPVersion string `short:"p" long:"php" description:"update to specific php version to use for instance. Should be one of '8.0', '8.1'."` + IIPServer bool `short:"i" long:"iip-server" description:"enable iip-server inside this instance"` OPCacheDevelopment bool `short:"o" long:"opcache-devel" description:"Include opcache development configuration"` + Flavor string `short:"f" long:"flavor" description:"Use specific flavor. Use 'provision --list-flavors' to list flavors. "` ContentSecurityPolicy string `short:"c" long:"content-security-policy" description:"Setup ContentSecurityPolicy"` Positionals struct { @@ -75,6 +77,7 @@ func (rb rebuild) Run(context wisski_distillery.Context) (err error) { if rb.System { sys = models.System{ PHP: rb.PHPVersion, + IIPServer: rb.IIPServer, OpCacheDevelopment: rb.OPCacheDevelopment, ContentSecurityPolicy: rb.ContentSecurityPolicy, } diff --git a/internal/dis/component/server/admin/html/instance.html b/internal/dis/component/server/admin/html/instance.html index 24d3f18..d3599b6 100644 --- a/internal/dis/component/server/admin/html/instance.html +++ b/internal/dis/component/server/admin/html/instance.html @@ -92,7 +92,7 @@ - IIP Image Server + IIP Image Server (Experimental) {{ .Instance.System.IIPServer }} diff --git a/internal/dis/component/server/admin/html/instance_system.html b/internal/dis/component/server/admin/html/instance_system.html index a4b631a..e3349d4 100644 --- a/internal/dis/component/server/admin/html/instance_system.html +++ b/internal/dis/component/server/admin/html/instance_system.html @@ -40,10 +40,11 @@
Run an IIPImage server inside this instance. + This is currently experimental.
This can be used for streaming 2D images inside this WissKI, see the WissKI Documentation for more details. Please be aware that any installation or configuration steps are performed automatically by the distillery. diff --git a/internal/models/instances_system.go b/internal/models/instances_system.go index afa7171..8812c22 100644 --- a/internal/models/instances_system.go +++ b/internal/models/instances_system.go @@ -52,6 +52,14 @@ func (system System) GetDockerBaseImage() string { return imagePrefix + version + imageSuffix } +// GetIIPServerEnabled returns if the IIPServer was enabled +func (system System) GetIIPServerEnabled() string { + if !system.IIPServer { + return "" + } + return "1" +} + const ( // Content Security Policy used by the internal server ContentSecurityPolicyNothing = "base-uri 'self'; default-src 'none';" diff --git a/internal/wisski/ingredient/barrel/barrel/Dockerfile b/internal/wisski/ingredient/barrel/barrel/Dockerfile index b4117af..d12e41c 100644 --- a/internal/wisski/ingredient/barrel/barrel/Dockerfile +++ b/internal/wisski/ingredient/barrel/barrel/Dockerfile @@ -13,6 +13,7 @@ FROM $BARREL_BASE_IMAGE WORKDIR /var/www # install and enable the various required php extensions and dropbear ssh server +ARG IIP_SERVER_ENABLED= RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \ curl \ openssh-server \ @@ -32,6 +33,7 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \ unzip \ vim \ zip \ + $([ "$IIP_SERVER_ENABLED" = "1" ] && echo iipimage-server) \ && \ docker-php-source extract && \ mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" && \ @@ -101,11 +103,15 @@ ENV CONTENT_SECURITY_POLICY=${CONTENT_SECURITY_POLICY} RUN rm /etc/apache2/sites-available/*.conf && \ rm /etc/apache2/sites-enabled/*.conf -# Then add the WissKI site +# Then add all the configs ADD apache.d/conf/ports.conf /etc/apache2/ports.conf ADD apache.d/sites-available/wisski.conf /etc/apache2/sites-available/wisski.conf -# And enable it +# this file is technically only needed for iipserv is enabled +# but we add it in either case, as it's not enabled. +ADD apache.d/mods-available/iipsrv.conf /etc/apache2/mods-available/iipsrv.conf + +# enable it RUN a2ensite wisski # volumes for composer diff --git a/internal/wisski/ingredient/barrel/barrel/apache.d/mods-available/iipsrv.conf b/internal/wisski/ingredient/barrel/barrel/apache.d/mods-available/iipsrv.conf new file mode 100644 index 0000000..169f614 --- /dev/null +++ b/internal/wisski/ingredient/barrel/barrel/apache.d/mods-available/iipsrv.conf @@ -0,0 +1,25 @@ +# Create a directory for the iipsrv binary +ScriptAlias /fcgi-bin/ "/usr/lib/iipimage-server/" + +# Set the options on that directory + + AllowOverride None + Options None + Require all granted + + # Set the module handler + AddHandler fcgid-script .fcgi + + +# Set our environment variables for the IIP server +FcgidInitialEnv VERBOSITY "1" +FcgidInitialEnv LOGFILE "/dev/stderr" +FcgidInitialEnv MAX_IMAGE_CACHE_SIZE "10" +FcgidInitialEnv JPEG_QUALITY "90" +FcgidInitialEnv MAX_CVT "5000" +FcgidInitialEnv MEMCACHED_SERVERS "localhost" + +# Define the idle timeout as unlimited and the number of +# processes we want +FcgidIdleTimeout 0 +FcgidMaxProcessesPerClass 1 \ No newline at end of file diff --git a/internal/wisski/ingredient/barrel/barrel/docker-compose.yml b/internal/wisski/ingredient/barrel/barrel/docker-compose.yml index ff1cfe4..bc94b85 100644 --- a/internal/wisski/ingredient/barrel/barrel/docker-compose.yml +++ b/internal/wisski/ingredient/barrel/barrel/docker-compose.yml @@ -8,6 +8,7 @@ services: BARREL_BASE_IMAGE: ${BARREL_BASE_IMAGE} OPCACHE_MODE: ${OPCACHE_MODE} CONTENT_SECURITY_POLICY: ${CONTENT_SECURITY_POLICY} + IIP_SERVER_ENABLED: ${IIP_SERVER_ENABLED} logging: driver: none diff --git a/internal/wisski/ingredient/barrel/stack.go b/internal/wisski/ingredient/barrel/stack.go index 038d530..15cb83c 100644 --- a/internal/wisski/ingredient/barrel/stack.go +++ b/internal/wisski/ingredient/barrel/stack.go @@ -32,6 +32,7 @@ func (barrel *Barrel) Stack() component.StackWithResources { "RUNTIME_DIR": barrel.Malt.Config.Paths.RuntimeDir(), "BARREL_BASE_IMAGE": barrel.GetDockerBaseImage(), + "IIP_SERVER_ENABLED": barrel.GetIIPServerEnabled(), "OPCACHE_MODE": barrel.OpCacheMode(), "CONTENT_SECURITY_POLICY": barrel.ContentSecurityPolicy, },