# Install php and nginx

FROM debian:jessie
MAINTAINER Ivaylo Iliev <ranapat@gmail.com>

# Install base packages
RUN \
  apt-get update > /dev/null 2>&1 && \
  apt-get install -y curl wget apt-transport-https lsb-release ca-certificates zip unzip git > /dev/null 2>&1

# Install php5.6
RUN \
  wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg > /dev/null 2>&1 && \
  echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list && \
  apt-get update > /dev/null 2>&1 && \
  apt-get install -y php5.6 php5.6-fpm php5.6-cli php5.6-common php5.6-curl php5.6-mbstring php5.6-mysqlnd php5.6-xml > /dev/null 2>&1 && \
  echo "cgi.fix_pathinfo=0" >> /etc/php/5.6/fpm/php.ini && \
  sed -i 's/UTF-8/windows-1251/g' /etc/php/5.6/fpm/php.ini

# Install Nginx.
RUN \
  apt-get install -y nginx > /dev/null 2>&1 && \
  echo "\ndaemon off;" >> /etc/nginx/nginx.conf && \
  chown -R www-data:www-data /var/lib/nginx

COPY etc/nginx/sites-enabled/default /etc/nginx/sites-enabled/default

# Define mountable directories.
VOLUME ["/etc/nginx/sites-enabled", "/etc/nginx/certs", "/etc/nginx/conf.d", "/var/log/nginx"]

RUN \
  rm /var/www/html/*

COPY application.start /application/application.start

# Define working directory.
WORKDIR /var/www/html

# Define default command.
CMD /application/application.start

# Expose ports.
EXPOSE 80
EXPOSE 443
