diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a83bb87 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +build/ +.idea/ diff --git a/Dockerfile b/Dockerfile index 00b4249..b7624e3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,8 +2,6 @@ FROM alpine:3 LABEL maintainer="Varakh" -ENV FILEBIN_VERSION 3.4.1 - # Expose variables to ease overwriting ENV RECONFIGURE true ENV MIGRATE true @@ -47,14 +45,23 @@ ENV SMALL_UPLOAD_SIZE 5120 ENV TARBALL_MAX_SIZE 1073741824 ENV TARBALL_CACHE_TIME 300 ENV MAX_INVITATION_KEYS 3 +ENV SMTP_ENABLED false +ENV SMTP_PROTOCOL 'smtp' +ENV SMTP_HOST '' +ENV SMTP_PORT 587 +ENV SMTP_CRYPTO 'tls' +ENV SMTP_USER '' +ENV SMTP_PASS '' # add script for database ADD src/wait-for.sh /wait-for.sh +# add upstream application +ADD build/ /var/www + # install dependencies RUN chmod -x /wait-for.sh && \ apk add --update --no-cache \ - git \ nginx \ s6 \ curl \ @@ -80,17 +87,13 @@ RUN chmod -x /wait-for.sh && \ php7-pdo \ php7-pdo_pgsql \ php7-ctype \ - php7-pdo_pgsql \ - php7-mysqli \ php7-mysqli \ php7-pecl-memcached \ memcached \ ca-certificates && \ rm -rf /var/cache/apk/* && \ apk add gnu-libiconv --update-cache --repository http://dl-cdn.alpinelinux.org/alpine/edge/community/ --allow-untrusted && \ - rm -rf /var/www && \ - # clone application and prepare www dir - git clone --branch ${FILEBIN_VERSION} https://github.com/Bluewind/filebin --depth=1 /var/www && \ + # prepare www dir cp -r /var/www/application/config/example/* /var/www/application/config && \ # set environments sed -i "s|;*memory_limit =.*|memory_limit = ${PHP_MEMORY_LIMIT}|i" /etc/php7/php.ini && \ diff --git a/README.md b/README.md index 87bf35e..96e08f0 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,7 @@ There are two environment variables introduced by this image: * `RECONFIGURE`: If all defined environment should be re-applied to the provided `.tpl` files within the image. You probably want this to be `1` unless you mounted your `config/` folder on the host * `MIGRATE`: Calls FileBin database migration every time the container is started and updates dependencies via `composer` +* `SMTP_ENABLE`: Set to `true` in order to enable sending mails via an external SMTP server, set to `false` to use PHP's internal mailer, see other `SMTP_` variables in the `Dockerfile` ### Setting up a nginx proxy @@ -122,3 +123,20 @@ docker exec filebin_db bash -c "/usr/bin/pg_dumpall -U fb|gzip -c > /filebin_db. docker cp filebin_db/:/var:/filebin_db.sql.gz /tmp/; docker exec filebin_db bash -c "rm /filebin_db.sql.gz"; ``` + +## Building + +Steps: + +* Clone to local `build/` folder which is later added +* Build image +* Push to registry or use locally + +Example: + +``` +export FILEBIN_VERSION=3.4.1 +mkdir -p build +git clone --branch ${FILEBIN_VERSION} https://github.com/Bluewind/filebin --depth=1 build/ +docker build -t varakh/filebin:${FILEBIN_VERSION} -t varakh/filebin:latest . +``` \ No newline at end of file diff --git a/src/config/config-local.php.tpl b/src/config/config-local.php.tpl index f3b7e9f..e14e39c 100644 --- a/src/config/config-local.php.tpl +++ b/src/config/config-local.php.tpl @@ -41,3 +41,13 @@ $config['tarball_cache_time'] = intval(%%%TARBALL_CACHE_TIME%%%); // The maximum number of active invitation keys per account. $config['max_invitation_keys'] = intval(%%%MAX_INVITATION_KEYS%%%); + +// SMTP mail settings if enabled +if (getenv('SMTP_ENABLED') === 'true') { + $config['protocol'] = %%%SMTP_PROTOCOL%%%; + $config['smtp_host'] = %%%SMTP_HOST%%%; + $config['smtp_port'] = intval(%%%SMTP_PORT%%%); + $config['smtp_crypto'] = %%%SMTP_CRYPTO%%%; + $config['smtp_user'] = %%%SMTP_USER%%%; + $config['smtp_pass'] = %%%SMTP_PASS%%%; +} \ No newline at end of file diff --git a/src/configure.php b/src/configure.php index 8104a67..fbf7e14 100644 --- a/src/configure.php +++ b/src/configure.php @@ -19,7 +19,13 @@ if (getenv('RECONFIGURE') === "true") { 'SMALL_UPLOAD_SIZE', 'TARBALL_MAX_SIZE', 'TARBALL_CACHE_TIME', - 'MAX_INVITATION_KEYS' + 'MAX_INVITATION_KEYS', + 'SMTP_PROTOCOL', + 'SMTP_HOST', + 'SMTP_PORT', + 'SMTP_CRYPTO', + 'SMTP_USER', + 'SMTP_PASS' ]; contentsReplace($confVars, $confPath, $confTargetPath);