Dont use git in Dockerfile #1 and support upstream smtp #2

This commit is contained in:
Varakh 2019-12-18 21:32:57 +01:00
parent a57c3a8437
commit 9136d0ac5c
5 changed files with 48 additions and 9 deletions

2
.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
build/
.idea/

View file

@ -2,8 +2,6 @@ FROM alpine:3
LABEL maintainer="Varakh<varakh@varakh.de>" LABEL maintainer="Varakh<varakh@varakh.de>"
ENV FILEBIN_VERSION 3.4.1
# Expose variables to ease overwriting # Expose variables to ease overwriting
ENV RECONFIGURE true ENV RECONFIGURE true
ENV MIGRATE true ENV MIGRATE true
@ -47,14 +45,23 @@ ENV SMALL_UPLOAD_SIZE 5120
ENV TARBALL_MAX_SIZE 1073741824 ENV TARBALL_MAX_SIZE 1073741824
ENV TARBALL_CACHE_TIME 300 ENV TARBALL_CACHE_TIME 300
ENV MAX_INVITATION_KEYS 3 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 script for database
ADD src/wait-for.sh /wait-for.sh ADD src/wait-for.sh /wait-for.sh
# add upstream application
ADD build/ /var/www
# install dependencies # install dependencies
RUN chmod -x /wait-for.sh && \ RUN chmod -x /wait-for.sh && \
apk add --update --no-cache \ apk add --update --no-cache \
git \
nginx \ nginx \
s6 \ s6 \
curl \ curl \
@ -80,17 +87,13 @@ RUN chmod -x /wait-for.sh && \
php7-pdo \ php7-pdo \
php7-pdo_pgsql \ php7-pdo_pgsql \
php7-ctype \ php7-ctype \
php7-pdo_pgsql \
php7-mysqli \
php7-mysqli \ php7-mysqli \
php7-pecl-memcached \ php7-pecl-memcached \
memcached \ memcached \
ca-certificates && \ ca-certificates && \
rm -rf /var/cache/apk/* && \ rm -rf /var/cache/apk/* && \
apk add gnu-libiconv --update-cache --repository http://dl-cdn.alpinelinux.org/alpine/edge/community/ --allow-untrusted && \ apk add gnu-libiconv --update-cache --repository http://dl-cdn.alpinelinux.org/alpine/edge/community/ --allow-untrusted && \
rm -rf /var/www && \ # prepare www dir
# clone application and prepare www dir
git clone --branch ${FILEBIN_VERSION} https://github.com/Bluewind/filebin --depth=1 /var/www && \
cp -r /var/www/application/config/example/* /var/www/application/config && \ cp -r /var/www/application/config/example/* /var/www/application/config && \
# set environments # set environments
sed -i "s|;*memory_limit =.*|memory_limit = ${PHP_MEMORY_LIMIT}|i" /etc/php7/php.ini && \ sed -i "s|;*memory_limit =.*|memory_limit = ${PHP_MEMORY_LIMIT}|i" /etc/php7/php.ini && \

View file

@ -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 * `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` * `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 ### 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 cp filebin_db/:/var:/filebin_db.sql.gz /tmp/;
docker exec filebin_db bash -c "rm /filebin_db.sql.gz"; 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 .
```

View file

@ -41,3 +41,13 @@ $config['tarball_cache_time'] = intval(%%%TARBALL_CACHE_TIME%%%);
// The maximum number of active invitation keys per account. // The maximum number of active invitation keys per account.
$config['max_invitation_keys'] = intval(%%%MAX_INVITATION_KEYS%%%); $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%%%;
}

View file

@ -19,7 +19,13 @@ if (getenv('RECONFIGURE') === "true") {
'SMALL_UPLOAD_SIZE', 'SMALL_UPLOAD_SIZE',
'TARBALL_MAX_SIZE', 'TARBALL_MAX_SIZE',
'TARBALL_CACHE_TIME', '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); contentsReplace($confVars, $confPath, $confTargetPath);