Skip to content

Instantly share code, notes, and snippets.

@isaqueprofeta
Created March 7, 2018 23:00
Show Gist options
  • Save isaqueprofeta/78fdeed95bb58dccd310496fe74e2db6 to your computer and use it in GitHub Desktop.
Save isaqueprofeta/78fdeed95bb58dccd310496fe74e2db6 to your computer and use it in GitHub Desktop.
phpipam_docker_72
FROM php:7.2-apache
MAINTAINER Pierre Cheynier <[email protected]>
ENV PHPIPAM_SOURCE https://github.com/phpipam/phpipam/
ENV PHPIPAM_VERSION 1.3.1
ENV PHPMAILER_SOURCE https://github.com/PHPMailer/PHPMailer/
ENV PHPMAILER_VERSION 5.2.21
ENV PHPSAML_SOURCE https://github.com/onelogin/php-saml/
ENV PHPSAML_VERSION 2.10.6
ENV WEB_REPO /var/www/html
# Install required deb packages
RUN sed -i /etc/apt/sources.list -e 's/$/ non-free'/ && \
apt-get update && apt-get -y upgrade && \
rm /etc/apt/preferences.d/no-debian-php && \
apt-get install -y libcurl4-gnutls-dev libgmp-dev libmcrypt-dev libpng-dev libfreetype6-dev libjpeg-dev libpng-dev libldap2-dev libsnmp-dev snmp-mibs-downloader && \
rm -rf /var/lib/apt/lists/*
# Install required packages and files required for snmp
RUN curl -s ftp://ftp.cisco.com/pub/mibs/v2/CISCO-SMI.my -o /var/lib/snmp/mibs/ietf/CISCO-SMI.txt && \
curl -s ftp://ftp.cisco.com/pub/mibs/v2/CISCO-TC.my -o /var/lib/snmp/mibs/ietf/CISCO-TC.txt && \
curl -s ftp://ftp.cisco.com/pub/mibs/v2/CISCO-VTP-MIB.my -o /var/lib/snmp/mibs/ietf/CISCO-VTP-MIB.txt && \
curl -s ftp://ftp.cisco.com/pub/mibs/v2/MPLS-VPN-MIB.my -o /var/lib/snmp/mibs/ietf/MPLS-VPN-MIB.txt
# Configure apache and required PHP modules
RUN docker-php-ext-configure mysqli --with-mysqli=mysqlnd && \
docker-php-ext-install mysqli && \
docker-php-ext-configure gd --enable-gd-native-ttf --with-freetype-dir=/usr/include/freetype2 --with-png-dir=/usr/include --with-jpeg-dir=/usr/include && \
docker-php-ext-install gd && \
docker-php-ext-install curl && \
docker-php-ext-install json && \
docker-php-ext-install snmp && \
docker-php-ext-install sockets && \
docker-php-ext-install pdo_mysql && \
docker-php-ext-install gettext && \
ln -s /usr/include/x86_64-linux-gnu/gmp.h /usr/include/gmp.h && \
docker-php-ext-configure gmp --with-gmp=/usr/include/x86_64-linux-gnu && \
docker-php-ext-install gmp && \
pecl install mcrypt-1.0.1 && \
docker-php-ext-enable mcrypt && \
docker-php-ext-install pcntl && \
docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu && \
docker-php-ext-install ldap && \
echo ". /etc/environment" >> /etc/apache2/envvars && \
a2enmod rewrite
COPY php.ini /usr/local/etc/php/
# Copy phpipam sources to web dir
ADD ${PHPIPAM_SOURCE}/archive/${PHPIPAM_VERSION}.tar.gz /tmp/
RUN tar -xzf /tmp/${PHPIPAM_VERSION}.tar.gz -C ${WEB_REPO}/ --strip-components=1
# Copy referenced submodules into the right directory
ADD ${PHPMAILER_SOURCE}/archive/v${PHPMAILER_VERSION}.tar.gz /tmp/
RUN tar -xzf /tmp/v${PHPMAILER_VERSION}.tar.gz -C ${WEB_REPO}/functions/PHPMailer/ --strip-components=1
ADD ${PHPSAML_SOURCE}/archive/v${PHPSAML_VERSION}.tar.gz /tmp/
RUN tar -xzf /tmp/v${PHPSAML_VERSION}.tar.gz -C ${WEB_REPO}/functions/php-saml/ --strip-components=1
# Use system environment variables into config.php
RUN cp ${WEB_REPO}/config.dist.php ${WEB_REPO}/config.php && \
chown www-data /var/www/html/app/admin/import-export/upload && \
sed -i -e "s/\['host'\] = 'localhost'/\['host'\] = getenv(\"MYSQL_ENV_MYSQL_HOST\") ?: \"mysql\"/" \
-e "s/\['user'\] = 'phpipam'/\['user'\] = getenv(\"MYSQL_ENV_MYSQL_USER\") ?: \"root\"/" \
-e "s/\['pass'\] = 'phpipamadmin'/\['pass'\] = getenv(\"MYSQL_ENV_MYSQL_PASSWORD\")/" \
-e "s/\['port'\] = 3306;/\['port'\] = 3306;\n\n\$password_file = getenv(\"MYSQL_ENV_MYSQL_PASSWORD_FILE\");\nif(file_exists(\$password_file))\n\$db\['pass'\] = preg_replace(\"\/\\\\s+\/\", \"\", file_get_contents(\$password_file));/" \
${WEB_REPO}/config.php
EXPOSE 80
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment