Merge pull request #14 from Azure/build-test
add nginx-fpm:0.2 and drupal-nginx-fpm:0.2
This commit is contained in:
Коммит
285efea8a0
|
@ -0,0 +1,53 @@
|
|||
FROM appsvcorg/nginx-fpm:0.2
|
||||
MAINTAINER Azure App Service Container Images <appsvc-images@microsoft.com>
|
||||
|
||||
# ========
|
||||
# ENV vars
|
||||
# ========
|
||||
#
|
||||
ENV DOCKER_BUILD_HOME "/dockerbuild"
|
||||
# drupal
|
||||
ENV DRUPAL_SOURCE "/usr/src/drupal"
|
||||
ENV DRUPAL_HOME "/home/site/wwwroot"
|
||||
# mariadb
|
||||
ENV MARIADB_DATA_DIR "/home/data/mysql"
|
||||
ENV MARIADB_LOG_DIR "/home/LogFiles/mysql"
|
||||
# phpmyadmin
|
||||
ENV PHPMYADMIN_SOURCE "/usr/src/phpmyadmin"
|
||||
ENV PHPMYADMIN_HOME "/home/phpmyadmin"
|
||||
#nginx
|
||||
ENV NGINX_LOG_DIR "/home/LogFiles/nginx"
|
||||
#php
|
||||
ENV PHP_HOME "/etc/php/7.0"
|
||||
ENV PHP_CONF_DIR $PHP_HOME"/cli"
|
||||
ENV PHP_CONF_FILE $PHP_CONF_DIR"/php.ini"
|
||||
|
||||
# ====================
|
||||
# Download and Install
|
||||
# ~. essentials
|
||||
# 1. Drupal
|
||||
# ====================
|
||||
|
||||
RUN mkdir -p $DOCKER_BUILD_HOME
|
||||
WORKDIR $DOCKER_BUILD_HOME
|
||||
|
||||
# -------------
|
||||
# 1. Drupal
|
||||
# -------------
|
||||
RUN mkdir -p $DRUPAL_SOURCE
|
||||
COPY drupal.tar.gz $DRUPAL_SOURCE/
|
||||
|
||||
# =========
|
||||
# Configure
|
||||
# =========
|
||||
WORKDIR $DRUPAL_HOME
|
||||
RUN rm -rf $DOCKER_BUILD_HOME
|
||||
|
||||
# =====
|
||||
# final
|
||||
# =====
|
||||
COPY entrypoint.sh /usr/local/bin/
|
||||
RUN chmod +x /usr/local/bin/entrypoint.sh
|
||||
|
||||
EXPOSE 2222 80
|
||||
ENTRYPOINT ["entrypoint.sh"]
|
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2017 Azure App Service
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
|
@ -0,0 +1,57 @@
|
|||
# Drupal-nginx-php Docker
|
||||
This is a Drupal Docker image which can run on both
|
||||
- [Azure Web App on Linux](https://docs.microsoft.com/en-us/azure/app-service-web/app-service-linux-intro)
|
||||
- [Drupal on Linux Web App With MySQL](https://ms.portal.azure.com/#create/Drupal.Drupalonlinux )
|
||||
- Your Docker engines's host.
|
||||
|
||||
You can find it in Docker hub here [https://hub.docker.com/r/appsvcorg/drupal-nginx-fpm/](https://hub.docker.com/r/appsvcorg/drupal-nginx-fpm/)
|
||||
|
||||
# Components
|
||||
This docker image currently contains the following components:
|
||||
1. Drupal (8.4.4)
|
||||
2. nginx (1.13.8)
|
||||
3. PHP (7.0.27)
|
||||
4. Drush
|
||||
5. Composer (1.6.1)
|
||||
6. MariaDB ( 10.1.26/if using Local Database )
|
||||
7. Phpmyadmin ( 4.7.7/if using Local Database )
|
||||
|
||||
# How to Deploy to Azure
|
||||
1. Create a Web App for Containers, set Docker container as ```appsvcorg/drupal-nginx-fpm:0.2```
|
||||
OR: Create a Drupal on Linux Web App With MySQL.
|
||||
2. Update App Setting ```WEBSITES_ENABLE_APP_SERVICE_STORAGE``` = true
|
||||
>If the ```WEBSITES_ENABLE_APP_SERVICE_STORAGE``` setting is false, the /home/ directory will not be shared across scale instances, and files that are written there will not be persisted across restarts.
|
||||
3. Add one App Setting ```WEBSITES_CONTAINER_START_TIME_LIMIT``` = 600
|
||||
4. Browse your site and wait almost 10 mins, you will see install page of Drupal.
|
||||
5. Complete Drupal install.
|
||||
|
||||
### How to configure to use Local Database with web app
|
||||
1. Create a Web App for Containers
|
||||
2. Update App Setting ```WEBSITES_ENABLE_APP_SERVICE_STORAGE``` = true
|
||||
3. Add new App Settings
|
||||
|
||||
Name | Default Value
|
||||
---- | -------------
|
||||
DATABASE_TYPE | local
|
||||
DATABASE_USERNAME | some-string
|
||||
DATABASE_PASSWORD | some-string
|
||||
**Note: We create a database "azurelocaldb" when using local mysql . Hence use this name when setting up the app **
|
||||
|
||||
4. Browse http://[website]/phpmyadmin
|
||||
|
||||
# Limitations
|
||||
- Must include App Setting ```WEBSITES_ENABLE_APP_SERVICE_STORAGE``` = true since we need files to be persisted. Do not use local storage for Drupal. You can use local storage for transient data or cached data say /tmp folder.
|
||||
- Pull and run this image need some time, You can include App Setting ```WEBSITES_CONTAINER_START_TIME_LIMIT``` to specify the time in seconds as need, Default is 240 and max is 600.
|
||||
|
||||
## Change Log
|
||||
- **Version 0.2**
|
||||
1. Supports local MySQL.
|
||||
2. Create default database - azurelocaldb.(You need set DATABASE_TYPE to **"local"**)
|
||||
3. Considering security, please set database authentication info on [*"App settings"*](#How-to-configure-to-use-Local-Database-with-web-app) when enable **"local"** mode.
|
||||
Note: the credentials below is also used by phpMyAdmin.
|
||||
- DATABASE_USERNAME | <*your phpMyAdmin user*>
|
||||
- DATABASE_PASSWORD | <*your phpMyAdmin password*>
|
||||
4. Fixed Restart block issue.
|
||||
|
||||
# How to Contribute
|
||||
If you have feedback please create an issue but **do not send Pull requests** to these images since any changes to the images needs to tested before it is pushed to production.
|
Двоичный файл не отображается.
|
@ -0,0 +1,125 @@
|
|||
#!/bin/bash
|
||||
|
||||
# set -e
|
||||
|
||||
php -v
|
||||
setup_mariadb_data_dir(){
|
||||
test ! -d "$MARIADB_DATA_DIR" && echo "INFO: $MARIADB_DATA_DIR not found. creating ..." && mkdir -p "$MARIADB_DATA_DIR"
|
||||
|
||||
# check if 'mysql' database exists
|
||||
if [ ! -d "$MARIADB_DATA_DIR/mysql" ]; then
|
||||
echo "INFO: 'mysql' database doesn't exist under $MARIADB_DATA_DIR. So we think $MARIADB_DATA_DIR is empty."
|
||||
echo "Copying all data files from the original folder /var/lib/mysql to $MARIADB_DATA_DIR ..."
|
||||
cp -R --no-clobber /var/lib/mysql/. $MARIADB_DATA_DIR
|
||||
else
|
||||
echo "INFO: 'mysql' database already exists under $MARIADB_DATA_DIR."
|
||||
fi
|
||||
|
||||
rm -rf /var/lib/mysql
|
||||
ln -s $MARIADB_DATA_DIR /var/lib/mysql
|
||||
chown -R mysql:mysql $MARIADB_DATA_DIR
|
||||
test ! -d /run/mysqld && echo "INFO: /run/mysqld not found. creating ..." && mkdir -p /run/mysqld
|
||||
chown -R mysql:mysql /run/mysqld
|
||||
}
|
||||
|
||||
start_mariadb(){
|
||||
service mysql start
|
||||
|
||||
rm -f /tmp/mysql.sock
|
||||
ln -s /var/run/mysqld/mysqld.sock /tmp/mysql.sock
|
||||
|
||||
# create default database 'azurelocaldb'
|
||||
mysql -u root -e "CREATE DATABASE IF NOT EXISTS azurelocaldb; FLUSH PRIVILEGES;"
|
||||
}
|
||||
#unzip phpmyadmin
|
||||
setup_phpmyadmin(){
|
||||
test ! -d "$PHPMYADMIN_HOME" && echo "INFO: $PHPMYADMIN_HOME not found. creating..." && mkdir -p "$PHPMYADMIN_HOME"
|
||||
cd $PHPMYADMIN_SOURCE
|
||||
tar -xf phpMyAdmin.tar.gz -C $PHPMYADMIN_HOME/ --strip-components=1
|
||||
cp -R phpmyadmin-nginx.conf /etc/nginx/nginx.conf
|
||||
cd /
|
||||
rm -rf $PHPMYADMIN_SOURCE
|
||||
if [ ! $WEBSITES_ENABLE_APP_SERVICE_STORAGE ]; then
|
||||
echo "INFO: NOT in Azure, chown for "$PHPMYADMIN_HOME
|
||||
chown -R www-data:www-data $PHPMYADMIN_HOME
|
||||
fi
|
||||
}
|
||||
#unzip drupal
|
||||
setup_drupal(){
|
||||
# tar drupal
|
||||
cd $DRUPAL_SOURCE
|
||||
tar -xf drupal.tar.gz -C $DRUPAL_HOME/ --strip-components=1
|
||||
chmod a+w "$DRUPAL_HOME/sites/default"
|
||||
mkdir -p "$DRUPAL_HOME/sites/default/files"
|
||||
chmod a+w "$DRUPAL_HOME/sites/default/files"
|
||||
cp "$DRUPAL_HOME/sites/default/default.settings.php" "$DRUPAL_HOME/sites/default/settings.php"
|
||||
chmod a+w "$DRUPAL_HOME/sites/default/settings.php"
|
||||
}
|
||||
|
||||
# setup server root
|
||||
test ! -d "$DRUPAL_HOME" && echo "INFO: $DRUPAL_HOME not found. creating..." && mkdir -p "$DRUPAL_HOME"
|
||||
if [ ! $WEBSITES_ENABLE_APP_SERVICE_STORAGE ]; then
|
||||
echo "INFO: NOT in Azure, chown for "$DRUPAL_HOME
|
||||
chown -R www-data:www-data $DRUPAL_HOME
|
||||
fi
|
||||
|
||||
# setup nginx log dir
|
||||
# http://nginx.org/en/docs/ngx_core_module.html#error_log
|
||||
# sed -i "s|error_log /var/log/error.log;|error_log stderr;|g" /etc/nginx/nginx.conf
|
||||
|
||||
echo "INFO: creating /run/php/php7.0-fpm.sock ..."
|
||||
test -e /run/php/php7.0-fpm.sock && rm -f /run/php/php7.0-fpm.sock
|
||||
mkdir -p /run/php
|
||||
touch /run/php/php7.0-fpm.sock
|
||||
chown www-data:www-data /run/php/php7.0-fpm.sock
|
||||
chmod 777 /run/php/php7.0-fpm.sock
|
||||
|
||||
DATABASE_TYPE=$(echo ${DATABASE_TYPE}|tr '[A-Z]' '[a-z]')
|
||||
if [ "${DATABASE_TYPE}" == "local" ]; then
|
||||
echo "Starting MariaDB and PHPMYADMIN..."
|
||||
echo 'mysql.default_socket = /run/mysqld/mysqld.sock' >> $PHP_CONF_FILE
|
||||
echo 'mysqli.default_socket = /run/mysqld/mysqld.sock' >> $PHP_CONF_FILE
|
||||
#setup MariaDB
|
||||
echo "INFO: loading local MariaDB and phpMyAdmin ..."
|
||||
echo "Setting up MariaDB data dir ..."
|
||||
setup_mariadb_data_dir
|
||||
echo "Setting up MariaDB log dir ..."
|
||||
test ! -d "$MARIADB_LOG_DIR" && echo "INFO: $MARIADB_LOG_DIR not found. creating ..." && mkdir -p "$MARIADB_LOG_DIR"
|
||||
chown -R mysql:mysql $MARIADB_LOG_DIR
|
||||
echo "Starting local MariaDB ..."
|
||||
start_mariadb
|
||||
|
||||
echo "Granting user for phpMyAdmin ..."
|
||||
# Set default value of username/password if they are't exist/null.
|
||||
DATABASE_USERNAME=${DATABASE_USERNAME:-phpmyadmin}
|
||||
DATABASE_PASSWORD=${DATABASE_PASSWORD:-MS173m_QN}
|
||||
echo "phpmyadmin username: "$DATABASE_USERNAME
|
||||
echo "phpmyadmin password: "$DATABASE_PASSWORD
|
||||
mysql -u root -e "GRANT ALL ON *.* TO \`$DATABASE_USERNAME\`@'localhost' IDENTIFIED BY '$DATABASE_PASSWORD' WITH GRANT OPTION; FLUSH PRIVILEGES;"
|
||||
echo "Installing phpMyAdmin ..."
|
||||
setup_phpmyadmin
|
||||
fi
|
||||
|
||||
# setup Drupal
|
||||
if test ! -e "$DRUPAL_HOME/sites/default/settings.php"; then
|
||||
echo "Installing Drupal ..."
|
||||
setup_drupal
|
||||
fi
|
||||
cd $DRUPAL_HOME
|
||||
rm -rf $DRUPAL_SOURCE
|
||||
|
||||
echo "Starting SSH ..."
|
||||
service ssh start
|
||||
|
||||
echo "Starting php-fpm ..."
|
||||
service php7.0-fpm start
|
||||
chmod 777 /run/php/php7.0-fpm.sock
|
||||
|
||||
echo "Starting Nginx ..."
|
||||
mkdir -p /home/LogFiles/nginx
|
||||
if test ! -e /home/LogFiles/nginx/error.log; then
|
||||
touch /home/LogFiles/nginx/error.log
|
||||
fi
|
||||
/usr/sbin/nginx
|
||||
|
||||
|
|
@ -0,0 +1,161 @@
|
|||
FROM nginx
|
||||
MAINTAINER Azure App Service Container Images <appsvc-images@microsoft.com>
|
||||
|
||||
# ========
|
||||
# ENV vars
|
||||
# ========
|
||||
|
||||
# ssh
|
||||
ENV SSH_PASSWD "root:Docker!"
|
||||
|
||||
# Composer
|
||||
# Updation: https://getcomposer.org/download/
|
||||
ENV COMPOSER_DOWNLOAD_URL "https://getcomposer.org/installer"
|
||||
ENV COMPOSER_ALLOW_SUPERUSER 1
|
||||
ENV COMPOSER_HOME /home/.composer
|
||||
ENV COMPOSER_VERSION "1.6.1"
|
||||
# SHA384SUM https://composer.github.io/installer.sha384sum
|
||||
ENV COMPOSER_SETUP_SHA 544e09ee996cdf60ece3804abc52599c22b1f40f4323403c44d44fdfdd586475ca9813a858088ffbc1f233e9b180f061
|
||||
#nginx
|
||||
ENV NGINX_LOG_DIR "/home/LogFiles/nginx"
|
||||
#php
|
||||
ENV PHP_HOME "/etc/php/7.0"
|
||||
ENV PHP_CONF_DIR $PHP_HOME"/cli"
|
||||
ENV PHP_CONF_FILE $PHP_CONF_DIR"/php.ini"
|
||||
# mariadb
|
||||
ENV MARIADB_DATA_DIR "/home/data/mysql"
|
||||
ENV MARIADB_LOG_DIR "/home/LogFiles/mysql"
|
||||
# phpmyadmin
|
||||
ENV PHPMYADMIN_SOURCE "/usr/src/phpmyadmin"
|
||||
ENV PHPMYADMIN_HOME "/home/phpmyadmin"
|
||||
#Web Site Home
|
||||
ENV HOME_SITE "/home/site/wwwroot"
|
||||
|
||||
#
|
||||
ENV DOCKER_BUILD_HOME "/dockerbuild"
|
||||
|
||||
# ====================
|
||||
# Download and Install
|
||||
# ~. essentials
|
||||
# 1. php7.0-common/php7.0-fpm/php-pear/php7.0-apcu
|
||||
# 2. ssh
|
||||
# 3. drush
|
||||
# 4. composer
|
||||
# ====================
|
||||
COPY * /tmp/
|
||||
|
||||
# -------------
|
||||
# ~. essentials
|
||||
# -------------
|
||||
|
||||
RUN set -ex \
|
||||
&& essentials=" \
|
||||
ca-certificates \
|
||||
wget \
|
||||
" \
|
||||
&& apt-get update \
|
||||
&& apt-get install -y -V --no-install-recommends $essentials \
|
||||
&& rm -r /var/lib/apt/lists/* \
|
||||
#
|
||||
# ------------------
|
||||
# 1. php7.0-common/php7.0-fpm/php-pear/php7.0-apcu
|
||||
# ------------------
|
||||
&& phps=" \
|
||||
php7.0-common \
|
||||
php7.0-fpm \
|
||||
php-pear \
|
||||
php7.0-apcu \
|
||||
php7.0-gd \
|
||||
php7.0-dba \
|
||||
php7.0-mysql \
|
||||
php7.0-xml \
|
||||
" \
|
||||
&& apt-get update \
|
||||
&& apt-get install -y -V --no-install-recommends $phps \
|
||||
&& rm -r /var/lib/apt/lists/* \
|
||||
#
|
||||
# ------
|
||||
# 2. ssh
|
||||
# ------
|
||||
&& apt-get update \
|
||||
&& apt-get install -y --no-install-recommends openssh-server \
|
||||
&& echo "$SSH_PASSWD" | chpasswd \
|
||||
#
|
||||
# ------
|
||||
# 3. drush
|
||||
# ------
|
||||
&& php -r "readfile('http://files.drush.org/drush.phar');" > /usr/local/bin/drush \
|
||||
&& chmod +x /usr/local/bin/drush \
|
||||
#
|
||||
# ------
|
||||
# 4. composer
|
||||
# ------
|
||||
&& php -r "readfile('https://getcomposer.org/installer');" > /tmp/composer-setup.php \
|
||||
&& php -r "if (hash('SHA384', file_get_contents('/tmp/composer-setup.php')) === getenv('COMPOSER_SETUP_SHA')) { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('/tmp/composer-setup.php'); echo PHP_EOL; exit(1); } echo PHP_EOL;" \
|
||||
&& mkdir -p /composer/bin \
|
||||
&& php /tmp/composer-setup.php --install-dir=/usr/local/bin/ --filename=composer --version=${COMPOSER_VERSION} \
|
||||
&& rm /tmp/composer-setup.php \
|
||||
#
|
||||
# ------
|
||||
# 5. mariadb
|
||||
# ------
|
||||
&& apt-get install -y -V --no-install-recommends mariadb-server \
|
||||
#
|
||||
# -------------
|
||||
# 6. phpmyadmin
|
||||
# -------------
|
||||
&& mkdir -p $PHPMYADMIN_SOURCE \
|
||||
&& mv /tmp/phpMyAdmin.tar.gz $PHPMYADMIN_SOURCE/phpMyAdmin.tar.gz \
|
||||
&& mv /tmp/phpmyadmin-nginx.conf $PHPMYADMIN_SOURCE/phpmyadmin-nginx.conf
|
||||
|
||||
# ----------
|
||||
# ~. clean up
|
||||
# ----------
|
||||
RUN set -ex \
|
||||
&& apt-get autoremove -y
|
||||
|
||||
# =========
|
||||
# Configure
|
||||
# =========
|
||||
|
||||
RUN set -ex\
|
||||
&& test ! -d /var/www && mkdir -p /var/www \
|
||||
&& chown -R www-data:www-data /var/www \
|
||||
##
|
||||
##
|
||||
&& rm -rf /var/log/mysql \
|
||||
&& ln -s $MARIADB_LOG_DIR /var/log/mysql \
|
||||
##
|
||||
&& rm -rf /var/log/nginx \
|
||||
&& ln -s $NGINX_LOG_DIR /var/log/nginx \
|
||||
##
|
||||
&& ln -s ${HOME_SITE} /var/www/wwwroot \
|
||||
##
|
||||
&& ln -s ${PHPMYADMIN_HOME} /var/www/phpmyadmin
|
||||
|
||||
# ssh
|
||||
COPY sshd_config /etc/ssh/
|
||||
|
||||
# php
|
||||
COPY php.ini /etc/php/7.0/cli/php.ini
|
||||
COPY www.conf /etc/php/7.0/fpm/pool.d/www.conf
|
||||
|
||||
# nginx
|
||||
COPY nginx.conf /etc/nginx/nginx.conf
|
||||
COPY hostingstart.html /home/site/wwwroot/index.html
|
||||
|
||||
# phpmyadmin
|
||||
COPY phpmyadmin-config.inc.php $PHPMYADMIN_SOURCE/
|
||||
COPY mariadb.cnf /etc/mysql/
|
||||
|
||||
RUN \
|
||||
echo "<?php phpinfo();" > /home/site/wwwroot/index.php
|
||||
|
||||
# =====
|
||||
# final
|
||||
# =====
|
||||
COPY init_container.sh /usr/local/bin/
|
||||
RUN chmod +x /usr/local/bin/init_container.sh
|
||||
|
||||
EXPOSE 2222 80
|
||||
ENTRYPOINT ["init_container.sh"]
|
|
@ -0,0 +1,53 @@
|
|||
# Nginx Fpm
|
||||
This docker image contains nginx, php-fpm , drush and composer. You can find it in Docker hub here [https://hub.docker.com/r/appsvcorg/nginx-fpm/](https://hub.docker.com/r/appsvcorg/nginx-fpm/)
|
||||
It can run on both [Azure Web App on Linux](https://docs.microsoft.com/en-us/azure/app-service-web/app-service-linux-intro) and your Docker engines's host.
|
||||
|
||||
# Docker Images for App Service Linux
|
||||
This repository contains docker images that are used for App Service Linux. Some images may be maintained by our team and some maintained by contirbutors.
|
||||
|
||||
## Components
|
||||
This docker image currently contains the following components:
|
||||
|
||||
1. Nginx (1.13.8)
|
||||
2. PHP (7.0.27)
|
||||
3. Composer (1.6.1)
|
||||
4. Drush
|
||||
5. MariaDB ( 10.1.26/if using Local Database )
|
||||
4. Phpmyadmin ( 4.7.7/if using Local Database )
|
||||
|
||||
# How to Deploy to Azure
|
||||
1. Create a Web App for Containers
|
||||
2. Update App Setting ```WEBSITES_ENABLE_APP_SERVICE_STORAGE``` = true
|
||||
>If the ```WEBSITES_ENABLE_APP_SERVICE_STORAGE``` setting is false, the /home/ directory will not be shared across scale instances, and files that are written there will not be persisted across restarts.
|
||||
3. Browse http://[website]/hostingstart.html
|
||||
|
||||
# How to configure to use Local Database with web app
|
||||
1. Create a Web App for Containers
|
||||
2. Update App Setting ```WEBSITES_ENABLE_APP_SERVICE_STORAGE``` = true
|
||||
3. Add new App Settings
|
||||
|
||||
Name | Default Value
|
||||
---- | -------------
|
||||
DATABASE_TYPE | local
|
||||
DATABASE_USERNAME | some-string
|
||||
DATABASE_PASSWORD | some-string
|
||||
**Note: We create a database "azurelocaldb" when using local mysql . Hence use this name when setting up the app **
|
||||
|
||||
4. Browse http://[website]/phpmyadmin
|
||||
|
||||
## Limitations
|
||||
- Some unexpected issues may happen after you scale out your site to multiple instances, if you deploy a site on Azure with this docker image and use the MariaDB built in this docker image as the database.
|
||||
- The phpMyAdmin built in this docker image is available only when you use the MariaDB built in this docker image as the database.
|
||||
- Must include App Setting ```WEBSITES_ENABLE_APP_SERVICE_STORAGE``` = true since we need files to be persisted.
|
||||
|
||||
## Change Log
|
||||
- **Version 0.2**
|
||||
1. Supports local MySQL.
|
||||
2. Create default database - azurelocaldb.(You need set DATABASE_TYPE to **"local"**)
|
||||
3. Considering security, please set database authentication info on **"App settings"** when enable **"local"** mode.
|
||||
Note: the credentials below is also used by phpMyAdmin.
|
||||
- DATABASE_USERNAME | <*your phpMyAdmin user*>
|
||||
- DATABASE_PASSWORD | <*your phpMyAdmin password*>
|
||||
|
||||
# How to Contribute
|
||||
If you have feedback please create an issue but **do not send Pull requests** to these images since any changes to the images needs to tested before it is pushed to production.
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -0,0 +1,106 @@
|
|||
#!/bin/bash
|
||||
|
||||
# set -e
|
||||
|
||||
php -v
|
||||
setup_mariadb_data_dir(){
|
||||
test ! -d "$MARIADB_DATA_DIR" && echo "INFO: $MARIADB_DATA_DIR not found. creating ..." && mkdir -p "$MARIADB_DATA_DIR"
|
||||
|
||||
# check if 'mysql' database exists
|
||||
if [ ! -d "$MARIADB_DATA_DIR/mysql" ]; then
|
||||
echo "INFO: 'mysql' database doesn't exist under $MARIADB_DATA_DIR. So we think $MARIADB_DATA_DIR is empty."
|
||||
echo "Copying all data files from the original folder /var/lib/mysql to $MARIADB_DATA_DIR ..."
|
||||
cp -R --no-clobber /var/lib/mysql/. $MARIADB_DATA_DIR
|
||||
else
|
||||
echo "INFO: 'mysql' database already exists under $MARIADB_DATA_DIR."
|
||||
fi
|
||||
|
||||
rm -rf /var/lib/mysql
|
||||
ln -s $MARIADB_DATA_DIR /var/lib/mysql
|
||||
chown -R mysql:mysql $MARIADB_DATA_DIR
|
||||
test ! -d /run/mysqld && echo "INFO: /run/mysqld not found. creating ..." && mkdir -p /run/mysqld
|
||||
chown -R mysql:mysql /run/mysqld
|
||||
}
|
||||
|
||||
start_mariadb(){
|
||||
service mysql start
|
||||
|
||||
rm -f /tmp/mysql.sock
|
||||
ln -s /var/run/mysqld/mysqld.sock /tmp/mysql.sock
|
||||
|
||||
# create default database 'azurelocaldb'
|
||||
mysql -u root -e "CREATE DATABASE IF NOT EXISTS azurelocaldb; FLUSH PRIVILEGES;"
|
||||
}
|
||||
#unzip phpmyadmin
|
||||
setup_phpmyadmin(){
|
||||
test ! -d "$PHPMYADMIN_HOME" && echo "INFO: $PHPMYADMIN_HOME not found. creating..." && mkdir -p "$PHPMYADMIN_HOME"
|
||||
cd $PHPMYADMIN_SOURCE
|
||||
tar -xf phpMyAdmin.tar.gz -C $PHPMYADMIN_HOME --strip-components=1
|
||||
cp -R phpMyAdmin-config.inc.php $PHPMYADMIN_HOME/config.inc.php
|
||||
cp -R phpmyadmin-nginx.conf /etc/nginx/nginx.conf
|
||||
cd /
|
||||
rm -rf $PHPMYADMIN_SOURCE
|
||||
if [ ! $WEBSITES_ENABLE_APP_SERVICE_STORAGE ]; then
|
||||
echo "INFO: NOT in Azure, chown for "$PHPMYADMIN_HOME
|
||||
chown -R www-data:www-data $PHPMYADMIN_HOME
|
||||
fi
|
||||
}
|
||||
|
||||
# setup server root
|
||||
test ! -d "$HOME_SITE" && echo "INFO: $HOME_SITE not found. creating..." && mkdir -p "$HOME_SITE"
|
||||
if [ ! $WEBSITES_ENABLE_APP_SERVICE_STORAGE ]; then
|
||||
echo "INFO: NOT in Azure, chown for "$HOME_SITE
|
||||
chown -R www-data:www-data $HOME_SITE
|
||||
fi
|
||||
|
||||
# setup nginx log dir
|
||||
# http://nginx.org/en/docs/ngx_core_module.html#error_log
|
||||
# sed -i "s|error_log /var/log/error.log;|error_log stderr;|g" /etc/nginx/nginx.conf
|
||||
|
||||
echo "INFO: creating /run/php/php7.0-fpm.sock ..."
|
||||
test -e /run/php/php7.0-fpm.sock && rm -f /run/php/php7.0-fpm.sock
|
||||
mkdir -p /run/php
|
||||
touch /run/php/php7.0-fpm.sock
|
||||
chown www-data:www-data /run/php/php7.0-fpm.sock
|
||||
chmod 777 /run/php/php7.0-fpm.sock
|
||||
|
||||
DATABASE_TYPE=$(echo ${DATABASE_TYPE}|tr '[A-Z]' '[a-z]')
|
||||
if [ "${DATABASE_TYPE}" == "local" ]; then
|
||||
echo "Starting MariaDB and PHPMYADMIN..."
|
||||
echo 'mysql.default_socket = /run/mysqld/mysqld.sock' >> $PHP_CONF_FILE
|
||||
echo 'mysqli.default_socket = /run/mysqld/mysqld.sock' >> $PHP_CONF_FILE
|
||||
#setup MariaDB
|
||||
echo "INFO: loading local MariaDB and phpMyAdmin ..."
|
||||
echo "Setting up MariaDB data dir ..."
|
||||
setup_mariadb_data_dir
|
||||
echo "Setting up MariaDB log dir ..."
|
||||
test ! -d "$MARIADB_LOG_DIR" && echo "INFO: $MARIADB_LOG_DIR not found. creating ..." && mkdir -p "$MARIADB_LOG_DIR"
|
||||
chown -R mysql:mysql $MARIADB_LOG_DIR
|
||||
echo "Starting local MariaDB ..."
|
||||
start_mariadb
|
||||
|
||||
echo "Granting user for phpMyAdmin ..."
|
||||
# Set default value of username/password if they are't exist/null.
|
||||
DATABASE_USERNAME=${DATABASE_USERNAME:-phpmyadmin}
|
||||
DATABASE_PASSWORD=${DATABASE_PASSWORD:-MS173m_QN}
|
||||
echo "phpmyadmin username: "$DATABASE_USERNAME
|
||||
echo "phpmyadmin password: "$DATABASE_PASSWORD
|
||||
mysql -u root -e "GRANT ALL ON *.* TO \`$DATABASE_USERNAME\`@'localhost' IDENTIFIED BY '$DATABASE_PASSWORD' WITH GRANT OPTION; FLUSH PRIVILEGES;"
|
||||
echo "Installing phpMyAdmin ..."
|
||||
setup_phpmyadmin
|
||||
fi
|
||||
echo "Starting SSH ..."
|
||||
service ssh start
|
||||
|
||||
echo "Starting php-fpm ..."
|
||||
service php7.0-fpm start
|
||||
chmod 777 /run/php/php7.0-fpm.sock
|
||||
|
||||
echo "Starting Nginx ..."
|
||||
mkdir -p /home/LogFiles/nginx
|
||||
if test ! -e /home/LogFiles/nginx/error.log; then
|
||||
touch /home/LogFiles/nginx/error.log
|
||||
fi
|
||||
/usr/sbin/nginx
|
||||
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
# The MariaDB configuration file
|
||||
#
|
||||
# The MariaDB/MySQL tools read configuration files in the following order:
|
||||
# 1. "/etc/mysql/mariadb.cnf" (this file) to set global defaults,
|
||||
# 2. "/etc/mysql/conf.d/*.cnf" to set global options.
|
||||
# 3. "/etc/mysql/mariadb.conf.d/*.cnf" to set MariaDB-only options.
|
||||
# 4. "~/.my.cnf" to set user-specific options.
|
||||
#
|
||||
# If the same option is defined multiple times, the last one will apply.
|
||||
#
|
||||
# One can use all long options that the program supports.
|
||||
# Run program with --help to get a list of available options and with
|
||||
# --print-defaults to see which it would actually understand and use.
|
||||
|
||||
#
|
||||
# This group is read both both by the client and the server
|
||||
# use it for options that affect everything
|
||||
#
|
||||
[client-server]
|
||||
|
||||
# Import all .cnf files from configuration directory
|
||||
!includedir /etc/mysql/conf.d/
|
||||
!includedir /etc/mysql/mariadb.conf.d/
|
||||
|
||||
[mysqld_safe]
|
||||
log_error=/var/log/mysql/mysql_error.log
|
||||
|
||||
[mysqld]
|
||||
log_error=/var/log/mysql/mysql_error.log
|
|
@ -0,0 +1,104 @@
|
|||
worker_processes auto;
|
||||
pid /var/run/nginx.pid;
|
||||
daemon off;
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
||||
'$status $body_bytes_sent "$http_referer" '
|
||||
'"$http_user_agent" "$http_x_forwarded_for"';
|
||||
access_log off;
|
||||
tcp_nopush on;
|
||||
keepalive_timeout 65;
|
||||
gzip on;
|
||||
gzip_comp_level 1;
|
||||
gzip_proxied any;
|
||||
gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;
|
||||
|
||||
server {
|
||||
server_name www.example.com;
|
||||
root /home/site/wwwroot; ## <-- Your only path $
|
||||
error_log /home/LogFiles/nginx/error.log;
|
||||
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
|
||||
|
||||
location = /favicon.ico {
|
||||
log_not_found off;
|
||||
access_log off;
|
||||
}
|
||||
|
||||
location = /robots.txt {
|
||||
allow all;
|
||||
log_not_found off;
|
||||
access_log off;
|
||||
}
|
||||
|
||||
location ~ \..*/.*\.php$ {
|
||||
return 403;
|
||||
}
|
||||
|
||||
location ~ ^/sites/.*/private/ {
|
||||
return 403;
|
||||
}
|
||||
|
||||
# Block access to "hidden" files and directories whose names begin with a
|
||||
# period. This includes directories used by version control systems such
|
||||
# as Subversion or Git to store control files.
|
||||
location ~ (^|/)\. {
|
||||
return 403;
|
||||
}
|
||||
|
||||
location / {
|
||||
# try_files $uri @rewrite; # For Drupal <= 6
|
||||
try_files $uri /index.php?$query_string; # For Drupal >= 7
|
||||
}
|
||||
|
||||
location @rewrite {
|
||||
rewrite ^/(.*)$ /index.php?q=$1;
|
||||
}
|
||||
|
||||
# In Drupal 8, we must also match new paths where the '.php' appears in the middle,
|
||||
# such as update.php/selection. The rule we use is strict, and only allows this pattern
|
||||
# with the update.php front controller. This allows legacy path aliases in the form of
|
||||
# blog/index.php/legacy-path to continue to route to Drupal nodes. If you do not have
|
||||
# any paths like that, then you might prefer to use a laxer rule, such as:
|
||||
# location ~ \.php(/|$) {
|
||||
# The laxer rule will continue to work if Drupal uses this new URL pattern with front
|
||||
# controllers other than update.php in a future release.
|
||||
location ~ '\.php$|^/update.php' {
|
||||
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
|
||||
fastcgi_split_path_info ^(.+?\.php)(/.*)?$;
|
||||
fastcgi_connect_timeout 300;
|
||||
fastcgi_send_timeout 3600;
|
||||
fastcgi_read_timeout 3600;
|
||||
fastcgi_buffer_size 128k;
|
||||
fastcgi_buffers 4 256k;
|
||||
fastcgi_busy_buffers_size 256k;
|
||||
fastcgi_temp_file_write_size 256k;
|
||||
fastcgi_intercept_errors on;
|
||||
fastcgi_index index.php;
|
||||
fastcgi_param SCRIPT_FILENAME /home/site/wwwroot$fastcgi_script_name;
|
||||
include fastcgi_params;
|
||||
}
|
||||
|
||||
# Fighting with Styles? This little gem is amazing.
|
||||
# location ~ ^/sites/.*/files/imagecache/ { # For Drupal <= 6
|
||||
location ~ ^/sites/.*/files/styles/ { # For Drpal >= 7
|
||||
try_files $uri @rewrite;
|
||||
}
|
||||
|
||||
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
|
||||
expires max;
|
||||
log_not_found off;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
; http://php.net/manual/en/errorfunc.configuration.php
|
||||
log_errors=On
|
||||
error_log=/var/log/httpd/php-error.log
|
||||
#echo 'error_log=/var/log/apache2/php-error.log'; \
|
||||
display_errors=Off
|
||||
display_startup_errors=Off
|
||||
date.timezone=UTC
|
||||
; For drupal image thumbnails
|
||||
allow_url_fopen=On
|
||||
; to allow uploading larger files
|
||||
; see http://php.net/manual/en/features.file-upload.common-pitfalls.php
|
||||
; http://php.net/manual/en/ini.core.php#ini.post-max-size
|
||||
post_max_size=60M
|
||||
upload_max_filesize=20M
|
||||
; http://php.net/manual/en/info.configuration.php#ini.max-input-time
|
||||
max_input_time=300
|
||||
|
||||
extension=redis.so
|
||||
extension=apcu.so
|
Двоичный файл не отображается.
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
/* Servers configuration */
|
||||
$i = 0;
|
||||
|
||||
/* Server: localhost [1] */
|
||||
$i++;
|
||||
$cfg['PmaAbsoluteUri'] = 'localhost/phpmyadmin'
|
||||
|
||||
/* http://stackoverflow.com/questions/1819592/error-when-connecting-to-mysql-using-php-pdo/1819767#1819767 */
|
||||
$cfg['Servers'][$i]['host'] = 'localhost';
|
||||
$cfg['Servers'][$i]['port'] = '';
|
||||
$cfg['Servers'][$i]['connect_type'] = 'socket';
|
||||
$cfg['Servers'][$i]['auth_type'] = 'cookie';
|
||||
$cfg['Servers'][$i]['AllowRoot'] = false;
|
||||
$cfg['Servers'][$i]['AllowNoPassword'] = false;
|
||||
|
||||
/* End of servers configuration */
|
||||
|
||||
$cfg['blowfish_secret'] = '"|5o$cGlh7%j"f"BKN)5cY%-(&,T(yh%';
|
||||
$cfg['DefaultLang'] = 'en';
|
||||
$cfg['ServerDefault'] = 1;
|
||||
$cfg['UploadDir'] = '';
|
||||
$cfg['SaveDir'] = '';
|
||||
|
||||
/* https://boss.vvc.edu/database_access/doc/html/config.html#cfg_CheckConfigurationPermissions */
|
||||
$cfg['CheckConfigurationPermissions']=false;
|
||||
|
||||
?>
|
|
@ -0,0 +1,124 @@
|
|||
worker_processes auto;
|
||||
pid /var/run/nginx.pid;
|
||||
daemon off;
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
||||
'$status $body_bytes_sent "$http_referer" '
|
||||
'"$http_user_agent" "$http_x_forwarded_for"';
|
||||
access_log off;
|
||||
tcp_nopush on;
|
||||
keepalive_timeout 65;
|
||||
gzip on;
|
||||
gzip_comp_level 1;
|
||||
gzip_proxied any;
|
||||
gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;
|
||||
|
||||
server {
|
||||
server_name www.example.com;
|
||||
root /home/site/wwwroot; ## <-- Your only path $
|
||||
error_log /home/LogFiles/nginx/error.log;
|
||||
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
|
||||
# Phpmyadmin Configurations
|
||||
location /phpmyadmin {
|
||||
root /home/;
|
||||
index index.php index.html index.htm;
|
||||
location ~ ^/phpmyadmin/(.+\.php)$ {
|
||||
try_files $uri =404;
|
||||
root /home/;
|
||||
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
|
||||
fastcgi_index index.php;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
include fastcgi_params;
|
||||
}
|
||||
location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
|
||||
root /home/;
|
||||
}
|
||||
}
|
||||
|
||||
location /phpMyAdmin {
|
||||
rewrite ^/* /phpmyadmin last;
|
||||
}
|
||||
|
||||
location = /favicon.ico {
|
||||
log_not_found off;
|
||||
access_log off;
|
||||
}
|
||||
|
||||
location = /robots.txt {
|
||||
allow all;
|
||||
log_not_found off;
|
||||
access_log off;
|
||||
}
|
||||
|
||||
location ~ \..*/.*\.php$ {
|
||||
return 403;
|
||||
}
|
||||
|
||||
location ~ ^/sites/.*/private/ {
|
||||
return 403;
|
||||
}
|
||||
|
||||
# Block access to "hidden" files and directories whose names begin with a
|
||||
# period. This includes directories used by version control systems such
|
||||
# as Subversion or Git to store control files.
|
||||
location ~ (^|/)\. {
|
||||
return 403;
|
||||
}
|
||||
|
||||
location / {
|
||||
# try_files $uri @rewrite; # For Drupal <= 6
|
||||
try_files $uri /index.php?$query_string; # For Drupal >= 7
|
||||
}
|
||||
|
||||
location @rewrite {
|
||||
rewrite ^/(.*)$ /index.php?q=$1;
|
||||
}
|
||||
|
||||
# In Drupal 8, we must also match new paths where the '.php' appears in the middle,
|
||||
# such as update.php/selection. The rule we use is strict, and only allows this pattern
|
||||
# with the update.php front controller. This allows legacy path aliases in the form of
|
||||
# blog/index.php/legacy-path to continue to route to Drupal nodes. If you do not have
|
||||
# any paths like that, then you might prefer to use a laxer rule, such as:
|
||||
# location ~ \.php(/|$) {
|
||||
# The laxer rule will continue to work if Drupal uses this new URL pattern with front
|
||||
# controllers other than update.php in a future release.
|
||||
location ~ '\.php$|^/update.php' {
|
||||
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
|
||||
fastcgi_split_path_info ^(.+?\.php)(/.*)?$;
|
||||
fastcgi_connect_timeout 300;
|
||||
fastcgi_send_timeout 3600;
|
||||
fastcgi_read_timeout 3600;
|
||||
fastcgi_buffer_size 128k;
|
||||
fastcgi_buffers 4 256k;
|
||||
fastcgi_busy_buffers_size 256k;
|
||||
fastcgi_temp_file_write_size 256k;
|
||||
fastcgi_intercept_errors on;
|
||||
fastcgi_index index.php;
|
||||
fastcgi_param SCRIPT_FILENAME /home/site/wwwroot$fastcgi_script_name;
|
||||
include fastcgi_params;
|
||||
}
|
||||
|
||||
# Fighting with Styles? This little gem is amazing.
|
||||
# location ~ ^/sites/.*/files/imagecache/ { # For Drupal <= 6
|
||||
location ~ ^/sites/.*/files/styles/ { # For Drpal >= 7
|
||||
try_files $uri @rewrite;
|
||||
}
|
||||
|
||||
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
|
||||
expires max;
|
||||
log_not_found off;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
#
|
||||
# /etc/ssh/sshd_config
|
||||
#
|
||||
|
||||
Port 2222
|
||||
ListenAddress 0.0.0.0
|
||||
LoginGraceTime 180
|
||||
X11Forwarding yes
|
||||
Ciphers aes128-cbc,3des-cbc,aes256-cbc
|
||||
MACs hmac-sha1,hmac-sha1-96
|
||||
StrictModes yes
|
||||
SyslogFacility DAEMON
|
||||
PrintMotd no
|
||||
IgnoreRhosts no
|
||||
#deprecated option
|
||||
#RhostsAuthentication no
|
||||
PasswordAuthentication yes
|
||||
PermitEmptyPasswords no
|
||||
PermitRootLogin yes
|
|
@ -0,0 +1,15 @@
|
|||
[www]
|
||||
user = www-data
|
||||
group = www-data
|
||||
|
||||
listen = /run/php/php7.0-fpm.sock
|
||||
listen.owner = www-data
|
||||
listen.group = www-data
|
||||
listen.mode = 0660
|
||||
|
||||
pm = dynamic
|
||||
pm.max_children = 50
|
||||
pm.start_servers = 20
|
||||
pm.min_spare_servers = 5
|
||||
pm.max_spare_servers = 35
|
||||
|
|
@ -0,0 +1 @@
|
|||
0.2
|
|
@ -322,6 +322,8 @@ do
|
|||
echo "ERROR - This image can't be run Normally failed, Please double check......"
|
||||
exit -1
|
||||
fi
|
||||
docker stop testdocker
|
||||
docker rm testdocker
|
||||
# It's Merge, push/pull/run.
|
||||
else
|
||||
echo "========================================"
|
||||
|
|
Загрузка…
Ссылка в новой задаче