Start implementing docker

This commit is contained in:
Jonathan Hodgson 2019-04-26 08:58:12 +01:00
parent 564034e5b7
commit 1290817923
6 changed files with 177 additions and 52 deletions

View file

@ -1,53 +1,20 @@
#!/usr/bin/bash #!/bin/bash
line=$(php --version | grep "PHP" -m 1)
libphp="/opt/lampp/modules/libphp7.1.so" DOCKER_CONFIG_DIRECTORY="/home/jonathan/.dotfiles/docker/web/"
case "$1" in
5) if [ ! -z "$1" ]; then
file="/opt/lampp/etc/extra/httpd-xampp-php5.conf"
phpexe=$(ls /opt/lampp/bin/php-5.*) version="$1"
phpcgi=$(ls /opt/lampp/bin/php-cgi-5.*)
phpconfig=$(ls /opt/lampp/bin/php-config-5.*) if [ "$(whoami)" == "root" ]; then
phpize=$(ls /opt/lampp/bin/phpize-5.*) cd "$DOCKER_CONFIG_DIRECTORY"
;; docker-compose down
7 | 7.1) sed "s/%version%/$version/" php/Dockerfile.sample > php/Dockerfile
file="/opt/lampp/etc/extra/httpd-xampp-php7.conf" docker-compose up --build -d
phpexe=$(ls /opt/lampp/bin/php-7.1.*) else
phpcgi=$(ls /opt/lampp/bin/php-cgi-7.1.*) gksudo $0 "$version"
phpconfig=$(ls /opt/lampp/bin/php-config-7.1.*) fi
phpize=$(ls /opt/lampp/bin/phpize-7.1.*) else
;; version="$(echo -e "5.6\n7.0\n7.1\n7.2\n7.3" | rofi -dmenu -p "PHP Version")"
7.0) $0 "$version"
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 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

53
bin/php-swap.old Executable file
View file

@ -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

View file

@ -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>

View file

@ -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

View file

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

View file

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