# debian -----------------------------------------------------

#	FROM debian:buster
#
#	# bash and vim for debug
#	RUN apt update && apt install -y \
#		php7.3 \
#		php7.3-fpm \
#		php7.3-mysqli \
#		mariadb-client \
#		curl \
#		bash vim
#	RUN rm -rf /var/lib/apt/lists/*
#
#	# fpm config
#	COPY ./conf/www.conf /etc/php/7.3/fpm/pool.d/
#	RUN mkdir /run/php/
#
#	ENV PHP_VERSION="php-fpm7.3"

# alpine -----------------------------------------------------

	FROM alpine:3.15

	# bash and vim for debug
	RUN apk update && apk add \
		php7 \
		php7-fpm \
		php7-mysqli \
		php7-phar \
		php7-json \
		mariadb-client \
		curl \
		bash vim
	RUN rm -rf /var/lib/apt/lists/*

	# fpm config
	COPY ./conf/www.conf /etc/php7/php-fpm.d/
	RUN mkdir /run/php/

	# create wp directory
	ARG WP_DIR
	RUN mkdir -p ${WP_DIR} 

	# create www-data user and add to group
	RUN adduser -S www-data && \
		adduser www-data www-data

	ENV PHP_VERSION="php-fpm7"

# common -----------------------------------------------------

# empty /var/www/html folder to avoid it to rewrite volume
#RUN rm -rf /var/www/html/*

# install wp-cli : https://wp-cli.org/#installing
RUN curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar &&\
	chmod +x wp-cli.phar && \
	mv wp-cli.phar /usr/local/bin/wp

COPY ./conf/wp_entrypoint.sh ./

ENTRYPOINT [ "sh", "wp_entrypoint.sh" ]

