diff options
author | Sebastian Rakel <sebastian@devunit.eu> | 2016-04-26 11:03:06 +0200 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2016-04-26 11:14:23 +0200 |
commit | 066be0f3d446169661c692ce7a16815e1b96f9bb (patch) | |
tree | 5e1c151a8b9442a102b32d34b90ad8682cb3b2ef /docker | |
parent | b8ab8019bd250c86a792b61f6e76d0ff5deaa1d1 (diff) |
Add Dockerfile and scripts to create and run a docker container
Diffstat (limited to 'docker')
-rw-r--r-- | docker/Dockerfile | 47 | ||||
-rw-r--r-- | docker/README.md | 31 | ||||
-rwxr-xr-x | docker/add_user.sh | 4 | ||||
-rwxr-xr-x | docker/filebin_starter.sh | 35 |
4 files changed, 117 insertions, 0 deletions
diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 000000000..cd6fc1380 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,47 @@ +FROM ubuntu:14.04 +MAINTAINER Sebastian Rakel <sebastian@devunit.eu> + +ENV DEBIAN_FRONTEND noninteractive + +RUN apt-get update -y && \ + apt-get install -y php5 php5-mysql php5-gd php5-imagick libtext-markdown-perl expect \ + python-pygments qrencode imagemagick git python-pip realpath curl apt-transport-https + +RUN echo 'deb https://deb.nodesource.com/node_4.x trusty main' > /etc/apt/sources.list.d/nodesource.list +RUN echo 'deb-src https://deb.nodesource.com/node_4.x trusty main' >> /etc/apt/sources.list.d/nodesource.list + +RUN curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add - + +RUN apt-get update -y && \ + apt-get install -y nodejs + +RUN sudo pip install ansi2html + +ENV FILEBIN_HOME_DIR /var/lib/filebin +ENV FILEBIN_DIR $FILEBIN_HOME_DIR/filebin + +RUN useradd -m -g users -d $FILEBIN_HOME_DIR filebin + +USER filebin + +ADD filebin_starter.sh $FILEBIN_HOME_DIR +ADD add_user.expect $FILEBIN_HOME_DIR +ADD add_user.sh $FILEBIN_HOME_DIR + +RUN git clone https://git.server-speed.net/users/flo/filebin/ $FILEBIN_DIR + +WORKDIR $FILEBIN_DIR + +RUN cp ./application/config/example/* ./application/config/ +RUN rm ./application/config/config-local.php + +RUN php ./install.php + +WORKDIR $FILEBIN_HOME_DIR + +EXPOSE 8080 + +VOLUME ["$FILEBIN_DIR/application/config", "$FILEBIN_DIR/data/uploads"] + +ENTRYPOINT ["bash", "-c"] +CMD ["./filebin_starter.sh"] diff --git a/docker/README.md b/docker/README.md new file mode 100644 index 000000000..d6b4af480 --- /dev/null +++ b/docker/README.md @@ -0,0 +1,31 @@ +# Filebin Docker Container + +## Filebin +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) + +## Ports +The PHP webserver is listening on ```8080``` + +## Volumes + +- **Uploaded Data:** uploaded files are saved to ```/var/lib/filebin/data/uploads``` +- **Advanced Configuration:** the configuration is located at ```/var/lib/filebin/application/config``` + +## Environment Variables +- **FB_DB_HOSTNAME:** the hostname of the mysql/mariadb server +- **FB_DB_USERNAME:** the username for the mysql/mariadb server +- **FB_DB_PASSWORD:** the password for the mysql/mariadb server +- **FB_DB_DATABSE:** the database on the mysql/mariadb for Filebin + +- **FB_CONTACT_NAME:** Contact Name +- **FB_CONTACT_MAIL:** Contact E-Mail (will be used as email for the first user) + +## First User +The first user is **admin** with the password **admin** + +## Run +### with linked mysql/mariadb database server +```docker run -ti --rm -p <port>:8080 --link mdb:mysql -e FB_DB_HOSTNAME=mysql -e FB_DB_USERNAME=filebin_usr -e FB_DB_PASSWORD=test -e FB_DB_DATABASE=filebin -e FB_CONTACT_NAME="John Doe" -e FB_CONTACT_MAIL="john.doe@localmail.local" sebastianrakel/filebin``` diff --git a/docker/add_user.sh b/docker/add_user.sh new file mode 100755 index 000000000..4342528ef --- /dev/null +++ b/docker/add_user.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +cd ${FILEBIN_DIR} +printf "%s\n%s\n%s\n" admin ${FB_CONTACT_MAIL} admin | php index.php user add_user diff --git a/docker/filebin_starter.sh b/docker/filebin_starter.sh new file mode 100755 index 000000000..65cf4a44b --- /dev/null +++ b/docker/filebin_starter.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +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 +} + +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 +} + +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} + + 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_HOME_DIR}/add_user.sh +fi + +cd $FILEBIN_DIR/public_html +php -S 0.0.0.0:8080 |