Permalink
Browse files

Merge pull request #64 from J0WI/docker

[WIP] add Dockerfile
  • Loading branch information...
DavidGoodwin committed Nov 11, 2017
2 parents 0f09b8c + 39dca79 commit 356ca84144297c93c7d44838157bebc4e661bc44
Showing with 93 additions and 0 deletions.
  1. +30 −0 docker/Dockerfile
  2. +63 −0 docker/docker-entrypoint.sh
View
@@ -0,0 +1,30 @@
FROM php:7.0-apache
# Install required PHP extensions
RUN buildDeps='libpq-dev libsqlite3-dev' \
&& apt-get update && apt-get install -y --no-install-recommends $buildDeps \
&& docker-php-ext-install mysqli pdo pdo_mysql pdo_pgsql pdo_sqlite pgsql \
&& apt-mark manual libpq5 \
&& apt-get purge -y --auto-remove $buildDeps \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
VOLUME /var/www/html
ENV POSTFIXADMIN_VERSION 3.1
ENV POSTFIXADMIN_SHA512 3bda4e9d4a7308d22edca30d181af76b7153e57b19bda878e32f5eeeb49127f46581c966706bcca13cd31740cadacc584e15830aa157b4655e60d44d66f45ddd
RUN set -eu; \
curl -o postfixadmin.tar.gz -SL "https://github.com/postfixadmin/postfixadmin/archive/postfixadmin-${POSTFIXADMIN_VERSION}.tar.gz"; \
echo "$POSTFIXADMIN_SHA512 *postfixadmin.tar.gz" | sha512sum -c -; \
# upstream tarball include ./postfixadmin-postfixadmin-${POSTFIXADMIN_VERSION}/
tar -xzf postfixadmin.tar.gz -C /usr/src/; \
mv /usr/src/postfixadmin-postfixadmin-${POSTFIXADMIN_VERSION} /usr/src/postfixadmin; \
rm postfixadmin.tar.gz; \
# Does not exist in tarball but is required
mkdir -p /usr/src/postfixadmin/templates_c; \
chown -R www-data:www-data /usr/src/postfixadmin
COPY docker-entrypoint.sh /usr/local/bin/
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
CMD ["apache2-foreground"]
@@ -0,0 +1,63 @@
#!/bin/bash
set -ex
if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
if ! [ -e index.php -a -e scripts/postfixadmin-cli.php ]; then
echo >&2 "Postfixadmin not found in $PWD - copying now..."
if [ "$(ls -A)" ]; then
echo >&2 "WARNING: $PWD is not empty - press Ctrl+C now if this is an error!"
( set -x; ls -A; sleep 10 )
fi
tar cf - --one-file-system -C /usr/src/postfixadmin . | tar xf -
echo >&2 "Complete! Postfixadmin has been successfully copied to $PWD"
fi
if [ -n "${!POSTGRES_ENV_POSTGRES_*}" ]; then
: "${POSTFIXADMIN_DB_TYPE:=pgsql}"
: "${POSTFIXADMIN_DB_HOST:=postgres}"
: "${POSTFIXADMIN_DB_USER:=${POSTGRES_ENV_POSTGRES_USER}}"
: "${POSTFIXADMIN_DB_PASSWORD:=${POSTGRES_ENV_POSTGRES_PASSWORD:-}}"
: "${POSTFIXADMIN_DB_NAME:=${POSTGRES_ENV_POSTGRES_DB:-}}"
fi
if [ -n "${!MYSQL_ENV_MYSQL_*}" ]; then
: "${POSTFIXADMIN_DB_TYPE:=mysqli}"
: "${POSTFIXADMIN_DB_HOST:=mysql}"
: "${POSTFIXADMIN_DB_USER:=${MYSQL_ENV_MYSQL_USER:-root}}"
if [ "$POSTFIXADMIN_DB_USER" = 'root' ]; then
: "${POSTFIXADMIN_DB_PASSWORD:=${MYSQL_ENV_MYSQL_ROOT_PASSWORD}}"
else
: "${POSTFIXADMIN_DB_PASSWORD:=${MYSQL_ENV_MYSQL_PASSWORD}}"
fi
: "${POSTFIXADMIN_DB_NAME:=${MYSQL_ENV_MYSQL_DATABASE:postfix}}"
fi
if [ "$POSTFIXADMIN_DB_TYPE" = 'sqlite' ]; then
: "${POSTFIXADMIN_DB_NAME:=/var/local/postfixadmin.db}"
if [ ! -e "$POSTFIXADMIN_DB_NAME" ]; then
touch $POSTFIXADMIN_DB_NAME
fi
fi
if [ ! -e config.local.php ]; then
touch config.local.php
echo "Write config to $PWD/config.local.php"
echo "<?php
\$CONF['database_type'] = '${POSTFIXADMIN_DB_TYPE}';
\$CONF['database_host'] = '${POSTFIXADMIN_DB_HOST}';
\$CONF['database_user'] = '${POSTFIXADMIN_DB_USER}';
\$CONF['database_password'] = '${POSTFIXADMIN_DB_PASSWORD}';
\$CONF['database_name'] = '${POSTFIXADMIN_DB_NAME}';
\$CONF['setup_password'] = '${POSTFIXADMIN_SETUP_PASSWORD}';
\$CONF['configured'] = true;
?>" | tee config.local.php
else
echo "WARNING: $PWD/config.local.php already exists."
echo "Postfixadmin related environment variables have been ignored."
fi
fi
exec "$@"

0 comments on commit 356ca84

Please sign in to comment.