FROM alpine:latest
MAINTAINER Bandie <bandie@chaospott.de>

RUN apk add --no-cache php nginx php-fpm msmtp tzdata

RUN adduser -D -g 'www' www
RUN mkdir /www
COPY ./www/* /www/

RUN chown -R www:www /var/lib/nginx
RUN chown -R www:www /www
COPY configs/nginx.conf /etc/nginx/nginx.conf

COPY configs/envs/php7.sh /etc/profile.d/php7.sh
RUN chown www:www /var/log/php7
RUN chown www:www /var/lib/nginx/logs/

RUN cp /usr/share/zoneinfo/UTC /etc/localtime
RUN echo "UTC" > /etc/timezone
RUN sed -i "s|;*date.timezone =.*|date.timezone = UTC|i" /etc/php7/php.ini

COPY configs/msmtprc /etc/msmtprc

COPY configs/aliases /etc/aliases

COPY configs/hosts /etc/hosts_append
RUN cat /etc/hosts_append >> /etc/hosts

COPY start.sh /start.sh
RUN chmod +x /start.sh

CMD /start.sh