Implement experimental IIPServer support

This commit is contained in:
Tom Wiesing 2023-11-11 10:37:56 +01:00
parent 5d84301361
commit 10b93ddbe8
No known key found for this signature in database
9 changed files with 51 additions and 4 deletions

View file

@ -17,6 +17,7 @@ var Provision wisski_distillery.Command = pv{}
type pv struct { 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'."` 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"` 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. "` 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"` 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, Flavor: p.Flavor,
System: models.System{ System: models.System{
PHP: p.PHPVersion, PHP: p.PHPVersion,
IIPServer: p.IIPServer,
OpCacheDevelopment: p.OPCacheDevelopment, OpCacheDevelopment: p.OPCacheDevelopment,
ContentSecurityPolicy: p.ContentSecurityPolicy, ContentSecurityPolicy: p.ContentSecurityPolicy,
}, },

View file

@ -20,7 +20,9 @@ type rebuild struct {
System bool `short:"s" long:"system-update" description:"Update the system configuration according to other flags"` 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'."` 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"` 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"` ContentSecurityPolicy string `short:"c" long:"content-security-policy" description:"Setup ContentSecurityPolicy"`
Positionals struct { Positionals struct {
@ -75,6 +77,7 @@ func (rb rebuild) Run(context wisski_distillery.Context) (err error) {
if rb.System { if rb.System {
sys = models.System{ sys = models.System{
PHP: rb.PHPVersion, PHP: rb.PHPVersion,
IIPServer: rb.IIPServer,
OpCacheDevelopment: rb.OPCacheDevelopment, OpCacheDevelopment: rb.OPCacheDevelopment,
ContentSecurityPolicy: rb.ContentSecurityPolicy, ContentSecurityPolicy: rb.ContentSecurityPolicy,
} }

View file

@ -92,7 +92,7 @@
</tr> </tr>
<tr> <tr>
<td> <td>
IIP Image Server IIP Image Server (<em>Experimental</em>)
</td> </td>
<td> <td>
<code>{{ .Instance.System.IIPServer }}</code> <code>{{ .Instance.System.IIPServer }}</code>

View file

@ -40,10 +40,11 @@
<div class="pure-controls"> <div class="pure-controls">
<label for="iipserver" class="pure-checkbox"> <label for="iipserver" class="pure-checkbox">
<input {{ if $rebuild }}{{ if .System.IIPServer }}checked{{end}}{{end}} type="checkbox" id="iipserver" /> <input {{ if $rebuild }}{{ if .System.IIPServer }}checked{{end}}{{end}} type="checkbox" id="iipserver" />
IIP Image Server IIP Image Server (<em>Experimental</em>)
</label> </label>
<span class="pure-form-message-inline"> <span class="pure-form-message-inline">
Run an <a href="https://iipimage.sourceforge.io/documentation/server" target="_blank" rel="noopener noreferer">IIPImage server</a> inside this instance. Run an <a href="https://iipimage.sourceforge.io/documentation/server" target="_blank" rel="noopener noreferer">IIPImage server</a> inside this instance.
This is currently <em>experimental</em>.
<br /> <br />
This can be used for streaming 2D images inside this WissKI, see <a href="https://wiss-ki.eu/documentation/periphal-software/iip-image-server" target="_blank" rel="noopener noreferer">the WissKI Documentation</a> for more details. This can be used for streaming 2D images inside this WissKI, see <a href="https://wiss-ki.eu/documentation/periphal-software/iip-image-server" target="_blank" rel="noopener noreferer">the WissKI Documentation</a> for more details.
Please be aware that any installation or configuration steps are performed automatically by the distillery. Please be aware that any installation or configuration steps are performed automatically by the distillery.

View file

@ -52,6 +52,14 @@ func (system System) GetDockerBaseImage() string {
return imagePrefix + version + imageSuffix return imagePrefix + version + imageSuffix
} }
// GetIIPServerEnabled returns if the IIPServer was enabled
func (system System) GetIIPServerEnabled() string {
if !system.IIPServer {
return ""
}
return "1"
}
const ( const (
// Content Security Policy used by the internal server // Content Security Policy used by the internal server
ContentSecurityPolicyNothing = "base-uri 'self'; default-src 'none';" ContentSecurityPolicyNothing = "base-uri 'self'; default-src 'none';"

View file

@ -13,6 +13,7 @@ FROM $BARREL_BASE_IMAGE
WORKDIR /var/www WORKDIR /var/www
# install and enable the various required php extensions and dropbear ssh server # 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 \ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
curl \ curl \
openssh-server \ openssh-server \
@ -32,6 +33,7 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
unzip \ unzip \
vim \ vim \
zip \ zip \
$([ "$IIP_SERVER_ENABLED" = "1" ] && echo iipimage-server) \
&& \ && \
docker-php-source extract && \ docker-php-source extract && \
mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini" && \ 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 && \ RUN rm /etc/apache2/sites-available/*.conf && \
rm /etc/apache2/sites-enabled/*.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/conf/ports.conf /etc/apache2/ports.conf
ADD apache.d/sites-available/wisski.conf /etc/apache2/sites-available/wisski.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 RUN a2ensite wisski
# volumes for composer # volumes for composer

View file

@ -0,0 +1,25 @@
# Create a directory for the iipsrv binary
ScriptAlias /fcgi-bin/ "/usr/lib/iipimage-server/"
# Set the options on that directory
<Location "/fcgi-bin/">
AllowOverride None
Options None
Require all granted
# Set the module handler
AddHandler fcgid-script .fcgi
</Location>
# 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

View file

@ -8,6 +8,7 @@ services:
BARREL_BASE_IMAGE: ${BARREL_BASE_IMAGE} BARREL_BASE_IMAGE: ${BARREL_BASE_IMAGE}
OPCACHE_MODE: ${OPCACHE_MODE} OPCACHE_MODE: ${OPCACHE_MODE}
CONTENT_SECURITY_POLICY: ${CONTENT_SECURITY_POLICY} CONTENT_SECURITY_POLICY: ${CONTENT_SECURITY_POLICY}
IIP_SERVER_ENABLED: ${IIP_SERVER_ENABLED}
logging: logging:
driver: none driver: none

View file

@ -32,6 +32,7 @@ func (barrel *Barrel) Stack() component.StackWithResources {
"RUNTIME_DIR": barrel.Malt.Config.Paths.RuntimeDir(), "RUNTIME_DIR": barrel.Malt.Config.Paths.RuntimeDir(),
"BARREL_BASE_IMAGE": barrel.GetDockerBaseImage(), "BARREL_BASE_IMAGE": barrel.GetDockerBaseImage(),
"IIP_SERVER_ENABLED": barrel.GetIIPServerEnabled(),
"OPCACHE_MODE": barrel.OpCacheMode(), "OPCACHE_MODE": barrel.OpCacheMode(),
"CONTENT_SECURITY_POLICY": barrel.ContentSecurityPolicy, "CONTENT_SECURITY_POLICY": barrel.ContentSecurityPolicy,
}, },