# ****************************************************************************************************
# *      ______                                                  _                       _           *
# *     |  ____|                                           /\   (_)                     | |          *
# *     | |__  _   _ _ __ ___  _ __   ___  __ _ _ __      /  \   _ _ __ _ __   ___  _ __| |_ ___     *
# *     |  __|| | | | '__/ _ \| '_ \ / _ \/ _` | '_ \    / /\ \ | | '__| '_ \ / _ \| '__| __/ __|    *
# *     | |___| |_| | | | (_) | |_) |  __/ (_| | | | |  / ____ \| | |  | |_) | (_) | |  | |_\__ \    *
# *     |______\__,_|_|  \___/| .__/ \___|\__,_|_| |_| /_/    \_\_|_|  | .__/ \___/|_|   \__|___/    *
# *                           | |                                      | |                           *
# *                           |_|                                      |_|                           *
# *                                                                                                  *
# ****************************************************************************************************

# This file is part of the European Airports Project, a free, collaborative platform of airport data 
# extending beyond the official AIPs.

# Copyright (C) 2023

# Florian Meissner <florianmeissner@gmx.de>

# This program is free software: you can redistribute it and/or modify it under the 
# terms of the GNU General Public License as published by the Free Software Foundation, either 
# version 3 of the License, or (at your option) any later version. This program is distributed in the 
# hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 
# details. You should have received a copy of the GNU General Public License along with this program. 
# (license.md in the root folder of this project) If not, see <http://www.gnu.org/licenses/>.



ARG PHP_VERSION
FROM php:${PHP_VERSION}

# Set timezone
RUN apk add --no-cache tzdata
ENV TZ=Etc/UTC

# Install PHP config
RUN mv /usr/local/etc/php/php.ini-development /usr/local/etc/php/php.ini
COPY etc/php /usr/local/etc/php/conf.d

# Install dependencies
RUN apk update && \
    apk upgrade && \
    apk add git fcgi && \
    curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer && \
    rm -rf /var/cache/apk/*

# Enable php fpm status page
RUN set -xe && echo "pm.status_path = /status" >> /usr/local/etc/php-fpm.d/zz-docker.conf

# Install and execute own entrypoint script. This scrpit should hold all instructions that are not
# executed while the image is build (use RUN in this file therefore) but that are run when the 
# container starts up. One major advanatge is that mounted volumes are already available when this
# script is executed.
COPY entrypoint.sh /entrypoint.sh
RUN ["chmod", "+x", "/entrypoint.sh"]
ENTRYPOINT ["/entrypoint.sh"]
