diff --git a/.dockerignore b/.dockerignore index 7915c0c..d24cb44 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,3 +1,3 @@ * !ifm.php -!apache2-foreground +!docker-startup.sh diff --git a/Dockerfile b/Dockerfile index c5e43aa..5392c09 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,22 @@ FROM alpine:3.5 ENV PHP_INI_DIR /etc/php5 +# general settings +ENV IFM_AUTH=0 \ + IFM_AUTH_SOURCE='inline;admin:$2y$10$0Bnm5L4wKFHRxJgNq.oZv.v7yXhkJZQvinJYR2p6X1zPvzyDRUVRC' \ + IFM_ROOT_DIR="" \ + IFM_TMP_DIR="" \ + IFM_DEFAULTTIMEZONE="Europe/Berlin" +# api controls +ENV IFM_API_AJAXREQUEST=1 IFM_API_CHMOD=1 IFM_API_COPYMOVE=1 \ + IFM_API_CREATEDIR=1 IFM_API_CREATEFILE=1 IFM_API_EDIT=1 \ + IFM_API_DELETE=1 IFM_API_DOWNLOAD=1 IFM_API_EXTRACT=1 \ + IFM_API_UPLOAD=1 IFM_API_REMOTEUPLOAD=1 IFM_API_RENAME=1 \ + IFM_API_ZIPNLOAD=1 +# gui controls +ENV IFM_GUI_SHOWLASTMODIFIED=0 IFM_GUI_SHOWFILESIZE=1 IFM_GUI_SHOWOWNER=1 \ + IFM_GUI_SHOWGROUP=1 IFM_GUI_SHOWPERMISSIONS=2 IFM_GUI_SHOWHTDOCS=1 \ + IFM_GUI_SHOWHIDDENFILES=1 IFM_GUI_SHOWPATH=0 # ensure apache user exists with the desired uid RUN set -x \ @@ -76,13 +92,13 @@ RUN { \ echo 'log_errors = On'; \ echo 'error_log = "/var/www/php.log"'; \ } > $PHP_INI_DIR/conf.d/ZZ_ifm.ini - -COPY apache2-foreground /usr/local/bin/ + +COPY docker-startup.sh /usr/local/bin/ COPY ifm.php /var/www/html/index.php WORKDIR /var/www EXPOSE 80 -CMD ["apache2-foreground"] +CMD ["docker-startup.sh"] diff --git a/apache2-foreground b/apache2-foreground deleted file mode 100755 index 819d8ea..0000000 --- a/apache2-foreground +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -set -e - -# Apache gets grumpy about PID files pre-existing -rm -f /usr/local/apache2/logs/httpd.pid - -exec httpd -DFOREGROUND - diff --git a/docker-startup.sh b/docker-startup.sh new file mode 100755 index 0000000..692edf7 --- /dev/null +++ b/docker-startup.sh @@ -0,0 +1,59 @@ +#!/bin/sh +set -e + +################################################################################ +# Adjust ifm configuration according to docker env vars. +# Defaults should match those in ifm.php. See Dockerfile for details. + +# see http://stackoverflow.com/a/2705678/433558 +sed_escape_lhs() { + echo "$@" | sed 's/[]\/$*.^|[]/\\&/g' +} +sed_escape_rhs() { + echo "$@" | sed 's/[\/&]/\\&/g' +} +set_config() { + key=$(sed_escape_lhs "$1") + value=$(sed_escape_rhs "$2" ) + sed -ri -e "s/\"$key\"[[:space:]]*=>.*$/\"$key\" => $value,/" /var/www/html/index.php +} + +# general settings +set_config "auth" "$IFM_AUTH" +set_config "auth_source" "'$IFM_AUTH_SOURCE'" +set_config "root_dir" "'$IFM_ROOT_DIR'" +set_config "tmp_dir" "'$IFM_TMP_DIR'" +set_config "defaulttimezone" "'$IFM_DEFAULTTIMEZONE'" +# api controls +set_config "ajaxrequest" "$IFM_API_AJAXREQUEST" +set_config "chmod" "$IFM_API_CHMOD" +set_config "copymove" "$IFM_API_COPYMOVE" +set_config "createdir" "$IFM_API_CREATEDIR" +set_config "createfile" "$IFM_API_CREATEFILE" +set_config "edit" "$IFM_API_EDIT" +set_config "delete" "$IFM_API_DELETE" +set_config "download" "$IFM_API_DOWNLOAD" +set_config "extract" "$IFM_API_EXTRACT" +set_config "upload" "$IFM_API_UPLOAD" +set_config "remoteupload" "$IFM_API_REMOTEUPLOAD" +set_config "rename" "$IFM_API_RENAME" +set_config "zipnload" "$IFM_API_ZIPNLOAD" +# gui controls +set_config "showlastmodified" "$IFM_GUI_SHOWLASTMODIFIED" +set_config "showfilesize" "$IFM_GUI_SHOWFILESIZE" +set_config "showowner" "$IFM_GUI_SHOWOWNER" +set_config "showgroup" "$IFM_GUI_SHOWGROUP" +set_config "showpermissions" "$IFM_GUI_SHOWPERMISSIONS" +set_config "showhtdocs" "$IFM_GUI_SHOWHTDOCS" +set_config "showhiddenfiles" "$IFM_GUI_SHOWHIDDENFILES" +set_config "showpath" "$IFM_GUI_SHOWPATH" + + +################################################################################ + +# Apache gets grumpy about PID files pre-existing +rm -f /usr/local/apache2/logs/httpd.pid + +# Start up apache +exec httpd -DFOREGROUND +