Skip to content

Instantly share code, notes, and snippets.

@yaredc
Last active July 8, 2020 20:14
Show Gist options
  • Save yaredc/68e8c00fcfb71f0a2b28eb9bae7a53e0 to your computer and use it in GitHub Desktop.
Save yaredc/68e8c00fcfb71f0a2b28eb9bae7a53e0 to your computer and use it in GitHub Desktop.
version: "3"
volumes:
composer:
services:
php:
image: ah/php:1.0.0
build:
context: .
dockerfile: .docker/dev/php.dockerfile
restart: always
volumes:
- ./:/var/www/html
- composer:/home/www-data/.composer
working_dir: /var/www/html
dns:
- 1.1.1.1
- 1.0.0.1
- 8.8.8.8
- 8.8.4.4
selenium:
depends_on:
- php
image: selenium/standalone-chrome:4
build:
context: .
dockerfile: .docker/dev/selenium.dockerfile
volumes:
- /dev/shm:/dev/shm
cap_add:
- NET_ADMIN
devices:
- /dev/net/tun
restart: always
user: root
environment:
- SCREEN_WIDTH=1920
- SCREEN_HEIGHT=1080
dns:
- 1.1.1.1
- 1.0.0.1
- 8.8.8.8
- 8.8.4.4
FROM php:7.4-fpm-alpine
###########################################################
#PRODUCTION ENVIRONMENT
###########################################################
ENV PHP_FPM_USER="www-data" \
PHP_FPM_GROUP="www-data"
#TIMEZONE
RUN apk add --no-cache --virtual .deps tzdata &&\
cp /usr/share/zoneinfo/Europe/Berlin /etc/localtime &&\
echo "Europe/Berlin" > /etc/timezone &&\
apk del .deps
#NAMESERVERS
RUN echo "nameserver 1.1.1.1" >> /etc/resolv.conf &&\
echo "nameserver 1.0.0.1" >> /etc/resolv.conf &&\
echo "nameserver 8.8.8.8" >> /etc/resolv.conf &&\
echo "nameserver 8.8.4.4" >> /etc/resolv.conf
#DEPENDENCIES
RUN apk add --no-cache --virtual .deps \
autoconf \
build-base \
curl-dev \
zlib-dev \
icu-dev \
libxml2-dev \
libzip-dev
#INSTALL EXTENSIONS
RUN docker-php-ext-install -j$(nproc) pdo &&\
docker-php-ext-install -j$(nproc) dom &&\
docker-php-ext-install -j$(nproc) json &&\
docker-php-ext-install -j$(nproc) mysqli &&\
docker-php-ext-install -j$(nproc) fileinfo &&\
docker-php-ext-install -j$(nproc) intl &&\
docker-php-ext-install -j$(nproc) zip
#PHP.INI SETTINGS
RUN echo "date.timezone=Europe/Berlin" >> "$PHP_INI_DIR"/php.ini-production &&\
echo "memory_limit=2048M" >> "$PHP_INI_DIR"/php.ini-production &&\
echo "date.timezone=Europe/Berlin" >> "$PHP_INI_DIR"/php.ini-development &&\
echo "memory_limit=2048M" >> "$PHP_INI_DIR"/php.ini-development &&\
cp "$PHP_INI_DIR"/php.ini-production "$PHP_INI_DIR"/php.ini &&\
echo "php_flag[display_errors]=off" >> /usr/local/etc/php-fpm.conf &&\
echo "php_admin_flag[log_errors]=on" >> /usr/local/etc/php-fpm.conf &&\
echo "php_admin_value[error_log]=/proc/self/fd/2" >> /usr/local/etc/php-fpm.conf &&\
echo "php_admin_value[error_reporting]=E_ALL" >> /usr/local/etc/php-fpm.conf &&\
echo "php_admin_value[display_startup_errors]=off" >> /usr/local/etc/php-fpm.conf
#PROD
RUN apk del .deps &&\
apk add --no-cache curl \
zlib \
icu \
libzip \
libxml2
###########################################################
#DEVELOPMENT ENVIRONMENT
###########################################################
#DEV DEPS
RUN apk add --no-cache git
#XDEBUG
ENV EXT_XDEBUG_VERSION=2.9.5
RUN docker-php-source extract &&\
mkdir -p /usr/src/php/ext/xdebug &&\
curl -fsSL https://github.com/xdebug/xdebug/archive/$EXT_XDEBUG_VERSION.tar.gz | tar xvz -C /usr/src/php/ext/xdebug --strip 1 &&\
docker-php-ext-configure xdebug &&\
docker-php-ext-install xdebug &&\
docker-php-source delete &&\
echo "xdebug.remote_enable=1" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini &&\
echo "xdebug.remote_autostart=0" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini &&\
echo "xdebug.default_enable=0" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini &&\
echo "xdebug.remote_host=host.docker.internal" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini &&\
echo "xdebug.remote_port=9000" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini &&\
echo "xdebug.remote_connect_back=0" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini &&\
echo "xdebug.profiler_enable=0" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini &&\
cp "$PHP_INI_DIR"/php.ini-development "$PHP_INI_DIR"/php.ini &&\
echo "php_flag[display_errors]=on" >> /usr/local/etc/php-fpm.conf &&\
echo "php_admin_value[display_startup_errors]=on" >> /usr/local/etc/php-fpm.conf
#COMPOSER
RUN curl -sS https://getcomposer.org/composer-stable.phar > /bin/composer &&\
chmod a+x /bin/composer &&\
su $PHP_FPM_USER -s /bin/sh -c "composer global require fxp/composer-asset-plugin"
ENV COMPOSER_HOME="/home/$PHP_FPM_USER/.composer" COMPOSER_MEMORY_LIMIT="-1"
#PHING
RUN curl -sS https://www.phing.info/get/phing-latest.phar > /bin/phing &&\
chmod a+x /bin/phing
#PHPUNIT
RUN curl -sS https://phar.phpunit.de/phpunit-9.phar > /bin/phpunit &&\
chmod a+x /bin/phpunit
#PHP-CS-FIXER
RUN curl -sS https://cs.symfony.com/download/php-cs-fixer-v2.phar > /bin/php-cs-fixer &&\
chmod a+x /bin/php-cs-fixer
#WORKDIR
RUN mkdir -p /var/www &&\
chown -R $PHP_FPM_USER:$PHP_FPM_GROUP /var/www /home/$PHP_FPM_USER &&\
chmod -R 0774 /var/www
WORKDIR /var/www
USER $PHP_FPM_USER
EXPOSE 9000
FROM selenium/standalone-chrome:4.0.0
USER root
RUN apt update &&\
apt install -y openvpn &&\
apt clean &&\
apt autoclean &&\
apt autoremove &&\
rm -rf /var/cache/apt/archives/* &&\
mkdir -p /ipvanish &&\
cd /ipvanish &&\
wget https://www.ipvanish.com/software/configs/configs.zip &&\
unzip -o configs.zip &&\
rm configs.zip &&\
cd / &&\
echo "seluser ALL = (ALL) NOPASSWD: /usr/sbin/openvpn, /dev/net/tun" >> /etc/sudoers &&\
find /ipvanish -type f -name "*.ovpn" -exec sed -i 's|auth-user-pass|auth-user-pass /etc/openvpn/auth|g' {} \; &&\
find /ipvanish -type f -name "*.ovpn" -exec sed -i 's|ca ca.ipvanish.com.crt|ca /ipvanish/ca.ipvanish.com.crt|g' {} \; &&\
echo "USERNAME" > /etc/openvpn/auth &&\
echo "PASSWORD" >> /etc/openvpn/auth &&\
systemctl enable openvpn
USER seluser
CMD ["sh", "-c", "sudo /usr/sbin/openvpn --config $(find /ipvanish -type f | shuf -n 1) & /opt/bin/entry_point.sh"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment