diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..7915c0c --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +* +!ifm.php +!apache2-foreground diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c5e43aa --- /dev/null +++ b/Dockerfile @@ -0,0 +1,88 @@ +FROM alpine:3.5 + +ENV PHP_INI_DIR /etc/php5 + +# ensure apache user exists with the desired uid +RUN set -x \ + && deluser xfs \ + && addgroup -g 33 -S apache \ + && adduser -u 33 -D -S -G apache apache + +RUN set -xe; \ + apk add --no-cache --virtual .image-runtime-deps \ + bash \ + sed \ + unzip \ + zip \ + curl \ + tar \ + gzip \ + bzip2 \ + xz + +RUN set -xe; \ + apk add --no-cache --virtual .wordpress-runtime-deps \ + apache2 \ + apache2-utils \ + php5-apache2 \ + php5 \ + php5-mcrypt \ + php5-gd \ + php5-intl \ + php5-json \ + php5-curl \ + php5-bz2 \ + php5-zlib \ + php5-posix \ + php5-soap \ + php5-pcntl \ + php5-xml \ + php5-zip + +RUN mkdir -p /run/apache2 \ + && mv /var/www/localhost/htdocs /var/www/html \ + && chown -R apache:apache /var/www \ + && chmod g+ws /var/www/html \ + && rm /var/www/html/index.html \ + && rm -Rf /var/www/localhost \ + && sed -ri \ + -e 's!^(\s*CustomLog)\s+\S+!\1 /proc/self/fd/1!g' \ + -e 's!^(\s*ErrorLog)\s+\S+!\1 /proc/self/fd/2!g' \ + -e 's!^#LoadModule rewrite_module!LoadModule rewrite_module!' \ + -e 's!/var/www/localhost/htdocs!/var/www/html!g' \ + -e 's!/var/www/localhost!/var/www!g' \ + "/etc/apache2/httpd.conf" \ + && rm /etc/apache2/conf.d/info.conf \ + && rm /etc/apache2/conf.d/userdir.conf \ + && { \ + echo 'ServerTokens Prod'; \ + echo 'ServerSignature Off'; \ + echo 'DocumentRoot "/var/www/html"'; \ + echo ''; \ + echo ' Options None'; \ + echo ' AllowOverride All'; \ + echo ' Require all granted'; \ + echo ''; \ + } > /etc/apache2/conf.d/ZZ_ifm + +RUN { \ + echo 'date.timezone = "Europe/Berlin"'; \ + echo 'zlib.output_compression = On'; \ + echo 'zlib.output_compression_level = 6'; \ + echo 'memory_limit = 256M'; \ + echo 'max_execution_time = 120'; \ + echo 'upload_max_filesize = 512M'; \ + echo 'post_max_size = 512M'; \ + 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 ifm.php /var/www/html/index.php + +WORKDIR /var/www + +EXPOSE 80 +CMD ["apache2-foreground"] + diff --git a/README.md b/README.md index 5bb24db..7120e55 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,23 @@ The IFM uses the following resources: ## installation Just copy the ifm.php to your webspace - thats all :) +## docker + +The docker image is based on alpine 3.5 for a small image footprint, with necessary apache, php and supporting packages installed and exposes port 80. + +### build image + +Run the following command from the top source dir: + +`docker build -t ifm .` + +### run image + +The script is installed inside the image at `/var/www/html/index.php`. Its default configuration is unchanged, thus it will display the contents of the document root (`/var/www/html`). + +Here is an example of how to start up a container with this image: +`docker run --rm -i -p "9090:80" -v "/data:/var/www/html/data" ifm` + ## key bindings * e - edit / extract current file * hjkl - vim-style navigation (alternative to arrow keys) diff --git a/apache2-foreground b/apache2-foreground new file mode 100755 index 0000000..819d8ea --- /dev/null +++ b/apache2-foreground @@ -0,0 +1,8 @@ +#!/bin/sh +set -e + +# Apache gets grumpy about PID files pre-existing +rm -f /usr/local/apache2/logs/httpd.pid + +exec httpd -DFOREGROUND +