Start implementing docker

master
Jonathan Hodgson 6 years ago
parent 564034e5b7
commit 1290817923
  1. 65
      bin/php-swap
  2. 53
      bin/php-swap.old
  3. 75
      docker/web/apache/sites-enabled/httpd-vhosts.conf
  4. 20
      docker/web/docker-compose.yml
  5. 5
      docker/web/php/Dockerfile
  6. 5
      docker/web/php/Dockerfile.sample

@ -1,53 +1,20 @@
#!/usr/bin/bash
line=$(php --version | grep "PHP" -m 1)
libphp="/opt/lampp/modules/libphp7.1.so"
case "$1" in
5)
file="/opt/lampp/etc/extra/httpd-xampp-php5.conf"
phpexe=$(ls /opt/lampp/bin/php-5.*)
phpcgi=$(ls /opt/lampp/bin/php-cgi-5.*)
phpconfig=$(ls /opt/lampp/bin/php-config-5.*)
phpize=$(ls /opt/lampp/bin/phpize-5.*)
;;
7 | 7.1)
file="/opt/lampp/etc/extra/httpd-xampp-php7.conf"
phpexe=$(ls /opt/lampp/bin/php-7.1.*)
phpcgi=$(ls /opt/lampp/bin/php-cgi-7.1.*)
phpconfig=$(ls /opt/lampp/bin/php-config-7.1.*)
phpize=$(ls /opt/lampp/bin/phpize-7.1.*)
;;
7.0)
file="/opt/lampp/etc/extra/httpd-xampp-php7.conf"
phpexe=$(ls /opt/lampp/bin/php-7.0.*)
phpcgi=$(ls /opt/lampp/bin/php-cgi-7.0.*)
phpconfig=$(ls /opt/lampp/bin/php-config-7.0.*)
phpize=$(ls /opt/lampp/bin/phpize-7.0.*)
libphp="/opt/lampp/modules/libphp7.0.so"
;;
*)
echo "Please specify the version you want"
exit 1
;;
esac
lampp='/opt/lampp/lampp'
echo $phpexe
if [ "$(id -u)" != "0" ]; then
echo "Sorry, you are not root."
exit 1
fi
#!/bin/bash
DOCKER_CONFIG_DIRECTORY="/home/jonathan/.dotfiles/docker/web/"
$lampp stopapache
ln -s -f $file /opt/lampp/etc/extra/httpd-xampp.conf
ln -s -f $phpexe /opt/lampp/bin/php
ln -s -f $phpcgi /opt/lampp/bin/php-cgi
ln -s -f $phpconfig /opt/lampp/bin/php-config
ln -s -f $phpize /opt/lampp/bin/phpize
ln -s -f $libphp /opt/lampp/modules/libphp7.so
if [ ! -z "$1" ]; then
version="$1"
$lampp startapache
echo
echo "Now on PHP ${phpexe##*-}"
exit 0
if [ "$(whoami)" == "root" ]; then
cd "$DOCKER_CONFIG_DIRECTORY"
docker-compose down
sed "s/%version%/$version/" php/Dockerfile.sample > php/Dockerfile
docker-compose up --build -d
else
gksudo $0 "$version"
fi
else
version="$(echo -e "5.6\n7.0\n7.1\n7.2\n7.3" | rofi -dmenu -p "PHP Version")"
$0 "$version"
fi

@ -0,0 +1,53 @@
#!/usr/bin/bash
line=$(php --version | grep "PHP" -m 1)
libphp="/opt/lampp/modules/libphp7.1.so"
case "$1" in
5)
file="/opt/lampp/etc/extra/httpd-xampp-php5.conf"
phpexe=$(ls /opt/lampp/bin/php-5.*)
phpcgi=$(ls /opt/lampp/bin/php-cgi-5.*)
phpconfig=$(ls /opt/lampp/bin/php-config-5.*)
phpize=$(ls /opt/lampp/bin/phpize-5.*)
;;
7 | 7.1)
file="/opt/lampp/etc/extra/httpd-xampp-php7.conf"
phpexe=$(ls /opt/lampp/bin/php-7.1.*)
phpcgi=$(ls /opt/lampp/bin/php-cgi-7.1.*)
phpconfig=$(ls /opt/lampp/bin/php-config-7.1.*)
phpize=$(ls /opt/lampp/bin/phpize-7.1.*)
;;
7.0)
file="/opt/lampp/etc/extra/httpd-xampp-php7.conf"
phpexe=$(ls /opt/lampp/bin/php-7.0.*)
phpcgi=$(ls /opt/lampp/bin/php-cgi-7.0.*)
phpconfig=$(ls /opt/lampp/bin/php-config-7.0.*)
phpize=$(ls /opt/lampp/bin/phpize-7.0.*)
libphp="/opt/lampp/modules/libphp7.0.so"
;;
*)
echo "Please specify the version you want"
exit 1
;;
esac
lampp='/opt/lampp/lampp'
echo $phpexe
if [ "$(id -u)" != "0" ]; then
echo "Sorry, you are not root."
exit 1
fi
$lampp stopapache
ln -s -f $file /opt/lampp/etc/extra/httpd-xampp.conf
ln -s -f $phpexe /opt/lampp/bin/php
ln -s -f $phpcgi /opt/lampp/bin/php-cgi
ln -s -f $phpconfig /opt/lampp/bin/php-config
ln -s -f $phpize /opt/lampp/bin/phpize
ln -s -f $libphp /opt/lampp/modules/libphp7.so
$lampp startapache
echo
echo "Now on PHP ${phpexe##*-}"
exit 0

@ -0,0 +1,75 @@
# Virtual Hosts
#
# Required modules: mod_log_config
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.4/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#
<VirtualHost *:80>
ServerName test.local
ServerAlias *.local
VirtualDocumentRoot /var/www/html/%-2/public_html
CustomLog /var/www/html/access.log vhost_combined
ErrorLog /var/www/html/error.log
Options +FollowSymLinks
php_flag session.auto_start off
php_value max_execution_time 18000
php_flag suhosin.session.cryptua off
</VirtualHost>
#<VirtualHost *:443>
# ServerName test.local
# ServerAlias *.local
# VirtualDocumentRoot /var/www/html/%-2/public_html
# CustomLog /var/www/html/access.log vhost_combined
# ErrorLog /var/www/html/error.log
# Options +FollowSymLinks
# php_flag session.auto_start off
# php_value max_execution_time 18000
# php_flag suhosin.session.cryptua off
# SSLEngine On
# #SSLCertificateFile /var/www/html/root-ca/certs/local.cert.pem
# #SSLCertificateKeyFile /var/www/html/root-ca/private/local.key.pem
#</VirtualHost>
<VirtualHost *:80>
ServerName test.local.jh
ServerAlias *.local.jh
VirtualDocumentRoot /var/www/html/%-3/public_html
CustomLog /var/www/html/access.log vhost_combined
ErrorLog /var/www/html/error.log
Options +FollowSymLinks
php_flag session.auto_start off
php_value max_execution_time 18000
php_flag suhosin.session.cryptua off
</VirtualHost>
<VirtualHost *:443>
ServerName test.local.jh
ServerAlias *.local.jh
VirtualDocumentRoot /var/www/html/%-3/public_html
CustomLog /var/www/html/access.log vhost_combined
ErrorLog /var/www/html/error.log
Options +FollowSymLinks
php_flag session.auto_start off
php_value max_execution_time 18000
php_flag suhosin.session.cryptua off
SSLEngine On
SSLCertificateFile /var/www/html/root-ca/certs/local.cert.pem
SSLCertificateKeyFile /var/www/html/root-ca/private/local.key.pem
</VirtualHost>

@ -0,0 +1,20 @@
version: '3'
services:
php:
container_name: php
build: ./php/
volumes:
- /home/jonathan/Sites/:/var/www/html/
- /home/jonathan/.dotfiles/docker/web/apache/sites-enabled/:/etc/apache2/sites-enabled
ports:
- 80:80
- 443:443
restart: always
mysql:
container_name: mysql
image: mysql:5.6
ports:
- 3306:3306
environment:
MYSQL_ROOT_PASSWORD: root
restart: always

@ -0,0 +1,5 @@
FROM php:7.3-apache
RUN a2enmod rewrite vhost_alias ssl
RUN docker-php-ext-install mysqli pdo pdo_mysql

@ -0,0 +1,5 @@
FROM php:%version%-apache
RUN a2enmod rewrite vhost_alias ssl
RUN docker-php-ext-install mysqli pdo pdo_mysql
Loading…
Cancel
Save