FROM php:7.0-fpm

RUN mkdir app
WORKDIR /app

# Update dependencies and install wget
RUN apt-get update && apt-get install wget unzip -y

# install mysql dependencies for php
RUN docker-php-ext-install mysqli pdo pdo_mysql

# Download and extract wordpress to the workdir folder
RUN wget https://wordpress.org/latest.tar.gz \
    && tar -zxvpf latest.tar.gz --strip-components 1 \
    && rm latest.tar.gz

# PHP INI
RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini"

# Download and Copy woocommerce
ENV WOOCOMMERCE_VERSION 3.5.2
ENV WOOCOMMERCE_FILE  woocommerce.$WOOCOMMERCE_VERSION.zip
RUN wget https://downloads.wordpress.org/plugin/$WOOCOMMERCE_FILE \
    && unzip $WOOCOMMERCE_FILE \
    && cp -R woocommerce /app/wp-content/plugins/ \
    && rm $WOOCOMMERCE_FILE

RUN wget https://downloads.wordpress.org/plugin/test-gateway-for-woocommerce.zip \
    && unzip test-gateway-for-woocommerce.zip \
    && cp -R test-gateway-for-woocommerce /app/wp-content/plugins/ \
    && rm test-gateway-for-woocommerce.zip

# Copy wordpress configuration file
COPY wp-config.php /app

# Copy plugin files
COPY lib src index.php composer.json composer.lock /app/wp-content/plugins/spocket/
