Created
July 4, 2019 18:52
-
-
Save dmikusa/81b2540006488cba577a88cb8303b0bd to your computer and use it in GitHub Desktop.
Deploy PHP MyAdmin using PHP Cloud Native Buildpacks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# See https://mikusa.blogspot.com/2019/07/php-cloud-native-buildpacks.html | |
# | |
# create private bridge network | |
docker network create -d bridge test-app-bridge | |
# create db | |
docker run --name test-db --network test-app-bridge -e MYSQL_ROOT_PASSWORD=hacKm3 -d percona | |
# Create a project folder for PHP MyAdmin | |
mkdir php-myadmin-project && cd php-myadmin-project | |
# Download and extract PHP MyAdmin. | |
mkdir -p htdocs && curl -s -L https://files.phpmyadmin.net/phpMyAdmin/4.9.0.1/phpMyAdmin-4.9.0.1-english.tar.gz | tar zx -C htdocs/ --strip=1 | |
cp htdocs/config.sample.inc.php htdocs/config.inc.php | |
# edit htdocs/config.inc.php - set 'Servers'->'host' to 'test-db' & other options you want | |
sed -i '' "s/\['blowfish_secret'\] = ''/\['blowfish_secret'\] = '$(openssl rand -hex 16)'/" htdocs/config.inc.php | |
sed -i '' "s/'localhost'/'test-db'/" htdocs/config.inc.php | |
# add extensions | |
mkdir -p .php.ini.d | |
cat <<EOF > .php.ini.d/extensions.ini | |
extension=mysqli.so | |
extension=openssl.so | |
extension=curl.so | |
extension=zlib.so | |
extension=bz2.so | |
extension=zip.so | |
extension=gd.so | |
extension=mbstring.so | |
zend_extension=opcache.so | |
EOF | |
# make sure buildpacks are set | |
if [ "$BUILDPACKS" == "" ]; then | |
echo "You forgot to set the list of PHP buildpacks" | |
exit -1 | |
fi | |
# build php-myadmin | |
pack build php-myadmin $BUILDPACKS | |
# run it | |
docker run -d --net test-app-bridge -e PORT=8080 -p 8080:8080 --name php-myadmin php-myadmin | |
echo "Go to http://localhost:8080/ in your browser & enter root / hacKm3 as the password" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment