summaryrefslogtreecommitdiffstats
path: root/docker
diff options
context:
space:
mode:
Diffstat (limited to 'docker')
-rw-r--r--docker/README.md7
-rwxr-xr-xdocker/add_user.sh1
-rw-r--r--docker/docker-compose.yml5
-rwxr-xr-xdocker/filebin_starter.sh81
4 files changed, 73 insertions, 21 deletions
diff --git a/docker/README.md b/docker/README.md
index 32a812cda..870591c9f 100644
--- a/docker/README.md
+++ b/docker/README.md
@@ -4,7 +4,7 @@
Filebin is a paste service developed by Florian Pritz [https://paste.xinu.at/](https://paste.xinu.at/)
## Dockerfile
-[Dockerfile](https://git.server-speed.net/users/flo/filebin/tree/docker/Dockerfile)
+[Dockerfile](https://github.com/Bluewind/filebin/blob/master/Dockerfile)
## Ports
The PHP webserver is listening on ```8080```
@@ -23,6 +23,11 @@ The PHP webserver is listening on ```8080```
- **FB_CONTACT_NAME:** Contact Name
- **FB_CONTACT_MAIL:** Contact E-Mail (will be used as email for the first user)
+- **FB_SMTP_HOST:** Address of the SMTP Server
+- **FB_SMTP_PORT:** Port for SMTP Server (default 587)
+- **FB_SMTP_USER:** Username for SMTP Server (will also be used as mail from)
+- **FB_SMTP_PASSWORD:** Password for the SMTP Server Useraccount
+
## First User
The first user is **admin** with the password **admin**
diff --git a/docker/add_user.sh b/docker/add_user.sh
index 4342528ef..88618746d 100755
--- a/docker/add_user.sh
+++ b/docker/add_user.sh
@@ -1,4 +1,5 @@
#!/bin/bash
cd ${FILEBIN_DIR}
+echo "Creating initial user. If it exists, this will show an error message instead"
printf "%s\n%s\n%s\n" admin ${FB_CONTACT_MAIL} admin | php index.php user add_user
diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml
index 03bc37f59..e6975682f 100644
--- a/docker/docker-compose.yml
+++ b/docker/docker-compose.yml
@@ -2,6 +2,7 @@ version: '2'
services:
mysql:
image: mysql
+ command: --default-authentication-plugin=mysql_native_password
environment:
- MYSQL_DATABASE=filebin
- MYSQL_USER=filebin
@@ -22,4 +23,8 @@ services:
- FB_DB_DATABASE=filebin
- FB_CONTACT_NAME=John Doe
- FB_CONTACT_MAIL=root@example.local
+ - FB_SMTP_HOST=localhost
+ - FB_SMTP_PORT=587
+ - FB_SMTP_USER=webmaster@example.invalid
+ - FB_SMTP_PASSWORD=mysecretpassword
diff --git a/docker/filebin_starter.sh b/docker/filebin_starter.sh
index 4fa50d583..38088537e 100755
--- a/docker/filebin_starter.sh
+++ b/docker/filebin_starter.sh
@@ -1,15 +1,61 @@
#!/bin/bash
+#set -euo pipefail
+
+function set_mail_config() {
+cat <<EOF > ${FILEBIN_HOME_DIR}/msmtprc
+account filebinmail
+tls on
+tls_certcheck off
+auth on
+host ${FB_SMTP_HOST}
+port ${FB_SMTP_PORT}
+user ${FB_SMTP_USER}
+from ${FB_SMTP_USER}
+password ${FB_SMTP_PASSWORD}
+EOF
+
+chmod 600 ${FILEBIN_HOME_DIR}/msmtprc
+}
+
function set_config() {
FB_ENCRYPTION_KEY=`< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c32`
- sed -i "s/\$config\['encryption_key'\] = ''/\$config['encryption_key'] = '${FB_ENCRYPTION_KEY}'/" ${FILEBIN_DIR}/application/config/config-local.php
+cat <<EOF >${FILEBIN_DIR}/application/config/config-local.php
+<?php
+\$config['base_url'] = 'http://127.0.0.1:8080/';
+\$config['encryption_key'] = '${FB_ENCRYPTION_KEY}';
+\$config['email_from'] = '${FB_SMTP_USER}';
+EOF
}
function set_database_config() {
- sed -i "s/\$db\['default'\]\['hostname'\] = .*/\$db['default']['hostname'] = \"${FB_DB_HOSTNAME}\";/" ${FILEBIN_DIR}/application/config/database.php
- sed -i "s/\$db\['default'\]\['username'\] = .*/\$db['default']['username'] = \"${FB_DB_USERNAME}\";/" ${FILEBIN_DIR}/application/config/database.php
- sed -i "s/\$db\['default'\]\['password'\] = .*/\$db['default']['password'] = \"${FB_DB_PASSWORD}\";/" ${FILEBIN_DIR}/application/config/database.php
- sed -i "s/\$db\['default'\]\['database'\] = .*/\$db['default']['database'] = \"${FB_DB_DATABASE}\";/" ${FILEBIN_DIR}/application/config/database.php
+cat <<EOF >${FILEBIN_DIR}/application/config/database.php
+<?php
+defined('BASEPATH') OR exit('No direct script access allowed');
+\$active_group = 'default';
+\$query_builder = TRUE;
+
+\$db['default'] = array(
+ 'dsn' => 'mysql:host=${FB_DB_HOSTNAME};dbname=${FB_DB_DATABASE}',
+ 'hostname' => '',
+ 'port' => 3306,
+ 'username' => '${FB_DB_USERNAME}',
+ 'password' => '${FB_DB_PASSWORD}',
+ 'database' => '${FB_DB_DATABASE}',
+ 'dbdriver' => 'pdo',
+ 'dbprefix' => '',
+ 'pconnect' => FALSE,
+ 'db_debug' => TRUE,
+ 'char_set' => 'utf8mb4', // if you use postgres, set this to utf8
+ 'dbcollat' => 'utf8mb4_bin', // if you use postgres, set this to utf8_bin
+ 'swap_pre' => '',
+ 'encrypt' => FALSE,
+ 'compress' => FALSE,
+ 'stricton' => TRUE,
+ 'failover' => array(),
+ 'save_queries' => TRUE
+);
+EOF
}
# wait for DB to be ready
@@ -18,25 +64,20 @@ while ! nc "$FB_DB_HOSTNAME" 3306 </dev/null >/dev/null; do
sleep 0.5
done
+set_config
+set_database_config
+set_mail_config
-if [[ ! -e $FILEBIN_DIR/application/config/config-local.php ]]; then
- echo "no config found, new config will be generated"
- cp $FILEBIN_DIR/application/config/example/config-local.php ${FILEBIN_DIR}/application/config/config-local.php
-
- set_config
- set_database_config
-
- CONTACT_INFO_FILE=${FILEBIN_DIR}/data/local/contact-info.php
- cp $FILEBIN_DIR/data/local/examples/contact-info.php ${CONTACT_INFO_FILE}
+CONTACT_INFO_FILE=${FILEBIN_DIR}/data/local/contact-info.php
+cp $FILEBIN_DIR/data/local/examples/contact-info.php ${CONTACT_INFO_FILE}
- sed -i "s/John Doe/${FB_CONTACT_NAME}/" ${CONTACT_INFO_FILE}
- sed -i "s/john.doe@example.com/${FB_CONTACT_MAIL}/" ${CONTACT_INFO_FILE}
+sed -i "s/John Doe/${FB_CONTACT_NAME}/" ${CONTACT_INFO_FILE}
+sed -i "s/john.doe@example.com/${FB_CONTACT_MAIL}/" ${CONTACT_INFO_FILE}
- ${FILEBIN_DIR}/scripts/install-git-hooks.sh
- ${FILEBIN_DIR}/git-hooks/post-merge
+${FILEBIN_DIR}/scripts/install-git-hooks.sh
+${FILEBIN_DIR}/git-hooks/post-merge
- ${FILEBIN_HOME_DIR}/add_user.sh
-fi
+${FILEBIN_HOME_DIR}/add_user.sh
cd $FILEBIN_DIR/public_html
php -S 0.0.0.0:8080