2020-10-29 12:54:53 +00:00
|
|
|
FROM php:7.4.11-alpine3.11
|
2020-10-28 19:56:26 +00:00
|
|
|
|
|
|
|
ARG TARGETPLATFORM
|
|
|
|
RUN echo "TARGETPLATFORM : $TARGETPLATFORM"
|
2018-09-06 23:42:29 +00:00
|
|
|
|
|
|
|
ENV PHPIPAM_AGENT_SOURCE https://github.com/phpipam/phpipam-agent
|
|
|
|
|
2022-01-09 02:56:25 +00:00
|
|
|
RUN apk update && apk upgrade
|
|
|
|
|
2022-01-05 21:13:10 +00:00
|
|
|
RUN apk add --no-cache --virtual .build-dependencies git \
|
2020-10-28 19:57:36 +00:00
|
|
|
\
|
2020-10-29 12:54:53 +00:00
|
|
|
&& apk add --no-cache \
|
|
|
|
apk-cron \
|
|
|
|
gmp \
|
|
|
|
gmp-dev \
|
|
|
|
gettext \
|
|
|
|
gettext-dev \
|
|
|
|
iputils \
|
|
|
|
fping \
|
|
|
|
bash \
|
2020-10-29 13:26:03 +00:00
|
|
|
tzdata \
|
2020-10-29 12:54:53 +00:00
|
|
|
\
|
|
|
|
# Configure apache and required PHP modules
|
|
|
|
&& docker-php-ext-configure mysqli --with-mysqli=mysqlnd \
|
|
|
|
&& docker-php-ext-install mysqli \
|
|
|
|
&& docker-php-ext-install json \
|
|
|
|
&& docker-php-ext-install pdo_mysql \
|
|
|
|
&& docker-php-ext-install gettext \
|
|
|
|
&& docker-php-ext-install gmp \
|
|
|
|
&& docker-php-ext-install pcntl
|
2018-09-06 23:42:29 +00:00
|
|
|
|
|
|
|
COPY php.ini /usr/local/etc/php/
|
2020-10-29 17:25:33 +00:00
|
|
|
COPY entrypoint.sh /
|
2018-09-06 23:42:29 +00:00
|
|
|
|
|
|
|
# Clone phpipam-agent sources
|
|
|
|
WORKDIR /opt/
|
|
|
|
RUN git clone ${PHPIPAM_AGENT_SOURCE}.git
|
|
|
|
|
|
|
|
WORKDIR /opt/phpipam-agent
|
|
|
|
# Use system environment variables into config.php
|
|
|
|
RUN cp config.dist.php config.php && \
|
|
|
|
sed -i -e "s/\['key'\] = .*;/\['key'\] = getenv(\"PHPIPAM_AGENT_KEY\");/" \
|
2020-10-29 12:54:53 +00:00
|
|
|
-e "s/\['pingpath'\] = .*;/\['pingpath'\] = \"\/usr\/sbin\/fping\";/" \
|
2022-01-06 18:34:32 +00:00
|
|
|
-e "s/\['reset_autodiscover_addresses'\] = false/\['reset_autodiscover_addresses'\] = getenv(\"PHPIPAM_RESET_AUTODISCOVER\") ?: false/" \
|
|
|
|
-e "s/\['remove_inactive_dhcp'\].*= false/\['remove_inactive_dhcp'\] = getenv(\"PHPIPAM_REMOVE_DHCP\") ?: false/" \
|
2022-01-06 16:02:16 +00:00
|
|
|
-e "s/\['db'\]\['host'\] = \"localhost\"/\['db'\]\['host'\] = getenv(\"PHPIPAM_DB_HOST\")/" \
|
2022-01-06 18:34:32 +00:00
|
|
|
-e "s/\['db'\]\['user'\] = \"phpipam\"/\['db'\]\['user'\] = getenv(\"PHPIPAM_DB_USER\") ?: \"phpipam\"/" \
|
2022-01-06 16:02:16 +00:00
|
|
|
-e "s/\['db'\]\['pass'\] = \"phpipamadmin\"/\['db'\]\['pass'\] = getenv(\"PHPIPAM_DB_PASS\")/" \
|
2022-01-06 18:34:32 +00:00
|
|
|
-e "s/\['db'\]\['name'\] = \"phpipam\"/\['db'\]\['name'\] = getenv(\"PHPIPAM_DB_NAME\") ?: \"phpipam\"/" \
|
|
|
|
-e "s/\['db'\]\['port'\] = 3306/\['db'\]\['port'\] = getenv(\"PHPIPAM_DB_PORT\") ?: 3306/" \
|
2020-10-29 12:54:53 +00:00
|
|
|
config.php \
|
|
|
|
\
|
2020-10-29 17:25:33 +00:00
|
|
|
&& chmod +x /entrypoint.sh \
|
|
|
|
\
|
2020-10-29 12:54:53 +00:00
|
|
|
&& apk del --no-cache --purge .build-dependencies \
|
|
|
|
&& rm -fr \
|
|
|
|
/tmp/*
|
2018-09-06 23:42:29 +00:00
|
|
|
|
|
|
|
# Setup crontab
|
2020-10-29 12:54:53 +00:00
|
|
|
ENV CRONTAB_FILE=/var/spool/cron/crontabs/root
|
2018-09-06 23:42:29 +00:00
|
|
|
|
2020-10-29 17:25:33 +00:00
|
|
|
ENTRYPOINT ["/entrypoint.sh"]
|
2020-10-30 10:47:28 +00:00
|
|
|
CMD [ "sh", "-c", "crond -l 2 -f" ]
|
2020-10-29 17:25:33 +00:00
|
|
|
|