From 69e003af20c3441f72833ee05b0631aca0899cf6 Mon Sep 17 00:00:00 2001 From: appsvcbuild Date: Thu, 13 Jun 2019 17:28:07 -0700 Subject: [PATCH 1/2] appsvcbuild --- 5.6-apache/Dockerfile | 149 +++++--------------------- 5.6-apache/apache2.conf | 61 ----------- 5.6-apache/generateStartupCommand.sh | 14 --- 5.6-apache/init_container.sh | 28 +++-- 5.6-apache/ssh_setup.sh | 26 +++++ 7.0-apache/Dockerfile | 152 +++++--------------------- 7.0-apache/apache2.conf | 62 ----------- 7.0-apache/generateStartupCommand.sh | 14 --- 7.0-apache/init_container.sh | 28 +++-- 7.0-apache/ssh_setup.sh | 26 +++++ 7.2-apache/Dockerfile | 153 +++++---------------------- 7.2-apache/apache2.conf | 62 ----------- 7.2-apache/generateStartupCommand.sh | 14 --- 7.2-apache/init_container.sh | 28 +++-- 7.2-apache/ssh_setup.sh | 26 +++++ 7.3-apache/Dockerfile | 153 +++++---------------------- 7.3-apache/apache2.conf | 62 ----------- 7.3-apache/generateStartupCommand.sh | 14 --- 7.3-apache/init_container.sh | 28 +++-- 7.3-apache/ssh_setup.sh | 26 +++++ 20 files changed, 288 insertions(+), 838 deletions(-) delete mode 100644 5.6-apache/apache2.conf delete mode 100644 5.6-apache/generateStartupCommand.sh create mode 100644 5.6-apache/ssh_setup.sh delete mode 100644 7.0-apache/apache2.conf delete mode 100644 7.0-apache/generateStartupCommand.sh create mode 100644 7.0-apache/ssh_setup.sh delete mode 100644 7.2-apache/apache2.conf delete mode 100644 7.2-apache/generateStartupCommand.sh create mode 100644 7.2-apache/ssh_setup.sh delete mode 100644 7.3-apache/apache2.conf delete mode 100644 7.3-apache/generateStartupCommand.sh create mode 100644 7.3-apache/ssh_setup.sh diff --git a/5.6-apache/Dockerfile b/5.6-apache/Dockerfile index ecff16d0..07ca847a 100644 --- a/5.6-apache/Dockerfile +++ b/5.6-apache/Dockerfile @@ -1,140 +1,47 @@ -FROM php:5.6.40-apache +FROM mcr.microsoft.com/oryx/php:5.6-20190607.1 LABEL maintainer="Azure App Services Container Images " -ENV PHP_VERSION 5.6.40 -COPY apache2.conf /bin/ +ENV PHP_VERSION 5.6 + COPY init_container.sh /bin/ COPY hostingstart.html /home/site/wwwroot/hostingstart.html -RUN a2enmod rewrite expires include deflate - -# install the PHP extensions we need -RUN apt-get update \ - && apt-get install -y --no-install-recommends \ - libpng-dev \ - libjpeg-dev \ - libpq-dev \ - libmcrypt-dev \ - libldap2-dev \ - libldb-dev \ - libicu-dev \ - libgmp-dev \ - libmagickwand-dev \ - libc-client-dev \ - libtidy-dev \ - libkrb5-dev \ - libxslt-dev \ - unixodbc-dev \ - openssh-server \ - vim \ - curl \ - wget \ - tcptraceroute \ - && chmod 755 /bin/init_container.sh \ +RUN chmod 755 /bin/init_container.sh \ + && mkdir -p /home/LogFiles/ \ && echo "root:Docker!" | chpasswd \ - && echo "cd /home" >> /etc/bash.bashrc \ - && ln -s /usr/lib/x86_64-linux-gnu/libldap.so /usr/lib/libldap.so \ - && ln -s /usr/lib/x86_64-linux-gnu/liblber.so /usr/lib/liblber.so \ - && ln -s /usr/include/x86_64-linux-gnu/gmp.h /usr/include/gmp.h \ - && rm -rf /var/lib/apt/lists/* \ - && pecl install imagick-beta \ - && docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr \ - && docker-php-ext-configure imap --with-kerberos --with-imap-ssl \ - && docker-php-ext-configure pdo_odbc --with-pdo-odbc=unixODBC,/usr \ - && docker-php-ext-install gd \ - mysqli \ - opcache \ - pdo \ - pdo_mysql \ - pdo_pgsql \ - pgsql \ - ldap \ - intl \ - mcrypt \ - gmp \ - zip \ - bcmath \ - mbstring \ - pcntl \ - calendar \ - exif \ - gettext \ - imap \ - tidy \ - shmop \ - soap \ - sockets \ - sysvmsg \ - sysvsem \ - sysvshm \ - pdo_odbc \ - wddx \ - xmlrpc \ - xsl \ - && docker-php-ext-enable imagick - -# install odbc php ext -RUN apt-get update \ - && apt-get install unixodbc-dev - -RUN set -x \ - && docker-php-source extract \ - && cd /usr/src/php/ext/odbc \ - && phpize \ - && sed -ri 's@^ *test +"\$PHP_.*" *= *"no" *&& *PHP_.*=yes *$@#&@g' configure \ - && ./configure --with-unixODBC=shared,/usr \ - && docker-php-ext-install odbc + && echo "cd /home/site/wwwroot" >> /etc/bash.bashrc \ + && ln -s /home/site/wwwroot /var/www/html \ + && mkdir -p /opt/startup -RUN \ - rm -f /var/log/apache2/* \ - && rmdir /var/lock/apache2 \ - && rmdir /var/run/apache2 \ - && rmdir /var/log/apache2 \ - && chmod 777 /var/log \ - && chmod 777 /var/run \ - && chmod 777 /var/lock \ - && chmod 777 /bin/init_container.sh \ - && cp /bin/apache2.conf /etc/apache2/apache2.conf \ - && rm -rf /var/www/html \ - && rm -rf /var/log/apache2 \ - && mkdir -p /home/LogFiles \ - && ln -s /home/site/wwwroot /var/www/html \ - && ln -s /home/LogFiles /var/log/apache2 - -RUN { \ - echo 'opcache.memory_consumption=128'; \ - echo 'opcache.interned_strings_buffer=8'; \ - echo 'opcache.max_accelerated_files=4000'; \ - echo 'opcache.revalidate_freq=60'; \ - echo 'opcache.fast_shutdown=1'; \ - echo 'opcache.enable_cli=1'; \ - } > /usr/local/etc/php/conf.d/opcache-recommended.ini - -RUN { \ - echo 'error_log=/var/log/apache2/php-error.log'; \ - echo 'display_errors=Off'; \ - echo 'log_errors=On'; \ - echo 'display_startup_errors=Off'; \ - echo 'date.timezone=UTC'; \ - } > /usr/local/etc/php/conf.d/php.ini +# configure startup +COPY sshd_config /etc/ssh/ +COPY ssh_setup.sh /tmp +RUN mkdir -p /opt/startup \ + && chmod -R +x /opt/startup \ + && chmod -R +x /tmp/ssh_setup.sh \ + && (sleep 1;/tmp/ssh_setup.sh 2>&1 > /dev/null) \ + && rm -rf /tmp/* ENV PORT 8080 ENV SSH_PORT 2222 EXPOSE 2222 8080 COPY sshd_config /etc/ssh/ -ENV APACHE_RUN_USER www-data - -# setup default site -RUN mkdir -p /opt/startup -COPY generateStartupCommand.sh /opt/startup/generateStartupCommand.sh -RUN chmod 755 /opt/startup/generateStartupCommand.sh - ENV WEBSITE_ROLE_INSTANCE_ID localRoleInstance ENV WEBSITE_INSTANCE_ID localInstance ENV PATH ${PATH}:/home/site/wwwroot -WORKDIR /var/www/html +RUN sed -i 's!ErrorLog ${APACHE_LOG_DIR}/error.log!ErrorLog /dev/stderr!g' /etc/apache2/apache2.conf +RUN sed -i 's!User ${APACHE_RUN_USER}!User www-data!g' /etc/apache2/apache2.conf +RUN sed -i 's!User ${APACHE_RUN_GROUP}!Group www-data!g' /etc/apache2/apache2.conf -ENTRYPOINT ["/bin/init_container.sh"] +RUN { \ + echo 'DocumentRoot /home/site/wwwroot'; \ + echo 'DirectoryIndex default.htm default.html index.htm index.html index.php hostingstart.html'; \ + echo 'ServerName localhost'; \ + echo 'CustomLog /dev/stdout combined'; \ +} >> /etc/apache2/apache2.conf + +WORKDIR /home/site/wwwroot +ENTRYPOINT ["/bin/init_container.sh"] diff --git a/5.6-apache/apache2.conf b/5.6-apache/apache2.conf deleted file mode 100644 index 4f1add6a..00000000 --- a/5.6-apache/apache2.conf +++ /dev/null @@ -1,61 +0,0 @@ -# see http://sources.debian.net/src/apache2/2.4.10-1/debian/config-dir/apache2.conf - -Mutex file:/var/lock/apache2 default -PidFile /var/run/apache2/apache2.pid -Timeout 300 -KeepAlive On -MaxKeepAliveRequests 100 -KeepAliveTimeout 5 -User www-data -Group www-data -HostnameLookups Off -ErrorLog /dev/stderr -LogLevel warn - -IncludeOptional mods-enabled/*.load -IncludeOptional mods-enabled/*.conf - -IncludeOptional conf-enabled/*.conf -IncludeOptional sites-enabled/*.conf - -# ports.conf -Listen {PORT} - - - Options FollowSymLinks - AllowOverride None - Require all denied - - - - AllowOverride All - Require all granted - - -DocumentRoot /var/www/html - -AccessFileName .htaccess - - Require all denied - - -LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined -LogFormat "\"%{X-Client-IP}i\" %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined -LogFormat "%h %l %u %t \"%r\" %>s %O" common -LogFormat "%{Referer}i -> %U" referer -LogFormat "%{User-agent}i" agent - -CustomLog /dev/stdout combined - - - SetHandler application/x-httpd-php - - -# Multiple DirectoryIndex directives within the same context will add -# to the list of resources to look for rather than replace -# https://httpd.apache.org/docs/current/mod/mod_dir.html#directoryindex -DirectoryIndex disabled -DirectoryIndex default.htm default.html index.htm index.html index.php hostingstart.html - -ServerTokens Prod -ServerSignature Off diff --git a/5.6-apache/generateStartupCommand.sh b/5.6-apache/generateStartupCommand.sh deleted file mode 100644 index fb412641..00000000 --- a/5.6-apache/generateStartupCommand.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -CMDFILE="/opt/startup/startupCommand" -DEFAULT_COMMAND="/usr/sbin/apache2ctl -D FOREGROUND" - -touch "$CMDFILE" - -CUSTOM_STARTUP_COMMAND=`cat $CMDFILE` - -if [ -z "$CUSTOM_STARTUP_COMMAND" ] -then - startupCommand="$DEFAULT_COMMAND" - echo "$startupCommand" >> "$CMDFILE" -fi diff --git a/5.6-apache/init_container.sh b/5.6-apache/init_container.sh index 727a527a..6a9fa7dd 100644 --- a/5.6-apache/init_container.sh +++ b/5.6-apache/init_container.sh @@ -17,16 +17,24 @@ cat /etc/motd # Get environment variables to show up in SSH session eval $(printenv | sed -n "s/^\([^=]\+\)=\(.*\)$/export \1=\2/p" | sed 's/"/\\\"/g' | sed '/=/s//="/' | sed 's/$/"/' >> /etc/profile) +# starting sshd process sed -i "s/SSH_PORT/$SSH_PORT/g" /etc/ssh/sshd_config -service ssh start -sed -i "s/{PORT}/$PORT/g" /etc/apache2/apache2.conf -mkdir /var/lock/apache2 -mkdir /var/run/apache2 +/usr/sbin/sshd -echo "$@" > /opt/startup/startupCommand -/opt/startup/generateStartupCommand.sh -chmod 755 /opt/startup/startupCommand +appPath="/home/site/wwwroot" +runFromPath="/tmp/webapp" +startupCommandPath="/opt/startup/startup.sh" +userStartupCommand="$@" +if [ -z "$userStartupCommand" ] +then + userStartupCommand="apache2-foreground"; +else + userStartupCommand="$userStartupCommand; apache2-foreground;" +fi -STARTUPCOMMAND=$(cat /opt/startup/startupCommand) -echo "Running $STARTUPCOMMAND" -eval "exec $STARTUPCOMMAND" +oryxArgs="-appPath $appPath -output $startupCommandPath \ + -bindPort $PORT -startupCommand '$userStartupCommand'" + +echo "Running oryx $oryxArgs" +eval oryx $oryxArgs +$startupCommandPath diff --git a/5.6-apache/ssh_setup.sh b/5.6-apache/ssh_setup.sh new file mode 100644 index 00000000..8bc40cc2 --- /dev/null +++ b/5.6-apache/ssh_setup.sh @@ -0,0 +1,26 @@ +#!/bin/sh + +if [ ! -f "/etc/ssh/ssh_host_rsa_key" ]; then + # generate fresh rsa key + ssh-keygen -f /etc/ssh/ssh_host_rsa_key -N '' -t rsa +fi + +if [ ! -f "/etc/ssh/ssh_host_dsa_key" ]; then + # generate fresh dsa key + ssh-keygen -f /etc/ssh/ssh_host_dsa_key -N '' -t dsa +fi + +if [ ! -f "/etc/ssh/ssh_host_ecdsa_key" ]; then + # generate fresh ecdsa key + ssh-keygen -f /etc/ssh/ssh_host_ecdsa_key -N '' -t dsa +fi + +if [ ! -f "/etc/ssh/ssh_host_ed25519_key" ]; then + # generate fresh ecdsa key + ssh-keygen -f /etc/ssh/ssh_host_ed25519_key -N '' -t dsa +fi + +#prepare run dir +if [ ! -d "/var/run/sshd" ]; then + mkdir -p /var/run/sshd +fi diff --git a/7.0-apache/Dockerfile b/7.0-apache/Dockerfile index 6e308872..ec35e422 100644 --- a/7.0-apache/Dockerfile +++ b/7.0-apache/Dockerfile @@ -1,143 +1,47 @@ -FROM php:7.0.33-apache +FROM mcr.microsoft.com/oryx/php:7.0-20190607.1 LABEL maintainer="Azure App Services Container Images " -ENV PHP_VERSION 7.0.33 -COPY apache2.conf /bin/ +ENV PHP_VERSION 7.0 + COPY init_container.sh /bin/ COPY hostingstart.html /home/site/wwwroot/hostingstart.html -RUN a2enmod rewrite expires include deflate - -# install the PHP extensions we need -RUN apt-get update \ - && apt-get install -y --no-install-recommends \ - libpng-dev \ - libjpeg-dev \ - libpq-dev \ - libmcrypt-dev \ - libldap2-dev \ - libldb-dev \ - libicu-dev \ - libgmp-dev \ - libmagickwand-dev \ - libc-client-dev \ - libtidy-dev \ - libkrb5-dev \ - libxslt-dev \ - unixodbc-dev \ - openssh-server \ - vim \ - curl \ - wget \ - tcptraceroute \ - && chmod 755 /bin/init_container.sh \ +RUN chmod 755 /bin/init_container.sh \ + && mkdir -p /home/LogFiles/ \ && echo "root:Docker!" | chpasswd \ - && echo "cd /home" >> /etc/bash.bashrc \ - && ln -s /usr/lib/x86_64-linux-gnu/libldap.so /usr/lib/libldap.so \ - && ln -s /usr/lib/x86_64-linux-gnu/liblber.so /usr/lib/liblber.so \ - && ln -s /usr/include/x86_64-linux-gnu/gmp.h /usr/include/gmp.h \ - && rm -rf /var/lib/apt/lists/* \ - && pecl install imagick-beta \ - && pecl install sqlsrv-5.3.0 pdo_sqlsrv-5.3.0 \ - && echo extension=pdo_sqlsrv.so >> `php --ini | grep "Scan for additional .ini files" | sed -e "s|.*:\s*||"`/30-pdo_sqlsrv.ini \ - && echo extension=sqlsrv.so >> `php --ini | grep "Scan for additional .ini files" | sed -e "s|.*:\s*||"`/20-sqlsrv.ini \ - && docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr \ - && docker-php-ext-configure imap --with-kerberos --with-imap-ssl \ - && docker-php-ext-configure pdo_odbc --with-pdo-odbc=unixODBC,/usr \ - && docker-php-ext-install gd \ - mysqli \ - opcache \ - pdo \ - pdo_mysql \ - pdo_pgsql \ - pgsql \ - ldap \ - intl \ - mcrypt \ - gmp \ - zip \ - bcmath \ - mbstring \ - pcntl \ - calendar \ - exif \ - gettext \ - imap \ - tidy \ - shmop \ - soap \ - sockets \ - sysvmsg \ - sysvsem \ - sysvshm \ - pdo_odbc \ - wddx \ - xmlrpc \ - xsl \ - && docker-php-ext-enable imagick - -# install odbc php ext -RUN apt-get update \ - && apt-get install unixodbc-dev - -RUN set -x \ - && docker-php-source extract \ - && cd /usr/src/php/ext/odbc \ - && phpize \ - && sed -ri 's@^ *test +"\$PHP_.*" *= *"no" *&& *PHP_.*=yes *$@#&@g' configure \ - && ./configure --with-unixODBC=shared,/usr \ - && docker-php-ext-install odbc - -RUN \ - rm -f /var/log/apache2/* \ - && rmdir /var/lock/apache2 \ - && rmdir /var/run/apache2 \ - && rmdir /var/log/apache2 \ - && chmod 777 /var/log \ - && chmod 777 /var/run \ - && chmod 777 /var/lock \ - && chmod 777 /bin/init_container.sh \ - && cp /bin/apache2.conf /etc/apache2/apache2.conf \ - && rm -rf /var/www/html \ - && rm -rf /var/log/apache2 \ - && mkdir -p /home/LogFiles \ - && ln -s /home/site/wwwroot /var/www/html \ - && ln -s /home/LogFiles /var/log/apache2 - - -RUN { \ - echo 'opcache.memory_consumption=128'; \ - echo 'opcache.interned_strings_buffer=8'; \ - echo 'opcache.max_accelerated_files=4000'; \ - echo 'opcache.revalidate_freq=60'; \ - echo 'opcache.fast_shutdown=1'; \ - echo 'opcache.enable_cli=1'; \ - } > /usr/local/etc/php/conf.d/opcache-recommended.ini + && echo "cd /home/site/wwwroot" >> /etc/bash.bashrc \ + && ln -s /home/site/wwwroot /var/www/html \ + && mkdir -p /opt/startup -RUN { \ - echo 'error_log=/var/log/apache2/php-error.log'; \ - echo 'display_errors=Off'; \ - echo 'log_errors=On'; \ - echo 'display_startup_errors=Off'; \ - echo 'date.timezone=UTC'; \ - } > /usr/local/etc/php/conf.d/php.ini +# configure startup +COPY sshd_config /etc/ssh/ +COPY ssh_setup.sh /tmp +RUN mkdir -p /opt/startup \ + && chmod -R +x /opt/startup \ + && chmod -R +x /tmp/ssh_setup.sh \ + && (sleep 1;/tmp/ssh_setup.sh 2>&1 > /dev/null) \ + && rm -rf /tmp/* ENV PORT 8080 ENV SSH_PORT 2222 EXPOSE 2222 8080 COPY sshd_config /etc/ssh/ -ENV APACHE_RUN_USER www-data - -# setup default site -RUN mkdir -p /opt/startup -COPY generateStartupCommand.sh /opt/startup/generateStartupCommand.sh -RUN chmod 755 /opt/startup/generateStartupCommand.sh - ENV WEBSITE_ROLE_INSTANCE_ID localRoleInstance ENV WEBSITE_INSTANCE_ID localInstance ENV PATH ${PATH}:/home/site/wwwroot -WORKDIR /var/www/html +RUN sed -i 's!ErrorLog ${APACHE_LOG_DIR}/error.log!ErrorLog /dev/stderr!g' /etc/apache2/apache2.conf +RUN sed -i 's!User ${APACHE_RUN_USER}!User www-data!g' /etc/apache2/apache2.conf +RUN sed -i 's!User ${APACHE_RUN_GROUP}!Group www-data!g' /etc/apache2/apache2.conf + +RUN { \ + echo 'DocumentRoot /home/site/wwwroot'; \ + echo 'DirectoryIndex default.htm default.html index.htm index.html index.php hostingstart.html'; \ + echo 'ServerName localhost'; \ + echo 'CustomLog /dev/stdout combined'; \ +} >> /etc/apache2/apache2.conf + +WORKDIR /home/site/wwwroot ENTRYPOINT ["/bin/init_container.sh"] diff --git a/7.0-apache/apache2.conf b/7.0-apache/apache2.conf deleted file mode 100644 index 1b70420d..00000000 --- a/7.0-apache/apache2.conf +++ /dev/null @@ -1,62 +0,0 @@ -# see http://sources.debian.net/src/apache2/2.4.10-1/debian/config-dir/apache2.conf - -Mutex file:/var/lock/apache2 default -PidFile /var/run/apache2/apache2.pid -Timeout 300 -KeepAlive On -MaxKeepAliveRequests 100 -KeepAliveTimeout 5 -User www-data -Group www-data -HostnameLookups Off -ErrorLog /dev/stderr -LogLevel warn - -IncludeOptional mods-enabled/*.load -IncludeOptional mods-enabled/*.conf - -IncludeOptional conf-enabled/*.conf -IncludeOptional sites-enabled/*.conf - -# ports.conf -Listen {PORT} - - - Options FollowSymLinks - AllowOverride None - Require all denied - - - - AllowOverride All - Require all granted - - -DocumentRoot /var/www/html - -AccessFileName .htaccess - - Require all denied - - -LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined -LogFormat "\"%{X-Client-IP}i\" %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined -LogFormat "%h %l %u %t \"%r\" %>s %O" common -LogFormat "%{Referer}i -> %U" referer -LogFormat "%{User-agent}i" agent - -CustomLog /dev/stdout combined - - - SetHandler application/x-httpd-php - - -# Multiple DirectoryIndex directives within the same context will add -# to the list of resources to look for rather than replace -# https://httpd.apache.org/docs/current/mod/mod_dir.html#directoryindex -DirectoryIndex disabled -DirectoryIndex default.htm default.html index.htm index.html index.php hostingstart.html - -ServerTokens Prod -ServerSignature Off - diff --git a/7.0-apache/generateStartupCommand.sh b/7.0-apache/generateStartupCommand.sh deleted file mode 100644 index fb412641..00000000 --- a/7.0-apache/generateStartupCommand.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -CMDFILE="/opt/startup/startupCommand" -DEFAULT_COMMAND="/usr/sbin/apache2ctl -D FOREGROUND" - -touch "$CMDFILE" - -CUSTOM_STARTUP_COMMAND=`cat $CMDFILE` - -if [ -z "$CUSTOM_STARTUP_COMMAND" ] -then - startupCommand="$DEFAULT_COMMAND" - echo "$startupCommand" >> "$CMDFILE" -fi diff --git a/7.0-apache/init_container.sh b/7.0-apache/init_container.sh index 727a527a..6a9fa7dd 100644 --- a/7.0-apache/init_container.sh +++ b/7.0-apache/init_container.sh @@ -17,16 +17,24 @@ cat /etc/motd # Get environment variables to show up in SSH session eval $(printenv | sed -n "s/^\([^=]\+\)=\(.*\)$/export \1=\2/p" | sed 's/"/\\\"/g' | sed '/=/s//="/' | sed 's/$/"/' >> /etc/profile) +# starting sshd process sed -i "s/SSH_PORT/$SSH_PORT/g" /etc/ssh/sshd_config -service ssh start -sed -i "s/{PORT}/$PORT/g" /etc/apache2/apache2.conf -mkdir /var/lock/apache2 -mkdir /var/run/apache2 +/usr/sbin/sshd -echo "$@" > /opt/startup/startupCommand -/opt/startup/generateStartupCommand.sh -chmod 755 /opt/startup/startupCommand +appPath="/home/site/wwwroot" +runFromPath="/tmp/webapp" +startupCommandPath="/opt/startup/startup.sh" +userStartupCommand="$@" +if [ -z "$userStartupCommand" ] +then + userStartupCommand="apache2-foreground"; +else + userStartupCommand="$userStartupCommand; apache2-foreground;" +fi -STARTUPCOMMAND=$(cat /opt/startup/startupCommand) -echo "Running $STARTUPCOMMAND" -eval "exec $STARTUPCOMMAND" +oryxArgs="-appPath $appPath -output $startupCommandPath \ + -bindPort $PORT -startupCommand '$userStartupCommand'" + +echo "Running oryx $oryxArgs" +eval oryx $oryxArgs +$startupCommandPath diff --git a/7.0-apache/ssh_setup.sh b/7.0-apache/ssh_setup.sh new file mode 100644 index 00000000..8bc40cc2 --- /dev/null +++ b/7.0-apache/ssh_setup.sh @@ -0,0 +1,26 @@ +#!/bin/sh + +if [ ! -f "/etc/ssh/ssh_host_rsa_key" ]; then + # generate fresh rsa key + ssh-keygen -f /etc/ssh/ssh_host_rsa_key -N '' -t rsa +fi + +if [ ! -f "/etc/ssh/ssh_host_dsa_key" ]; then + # generate fresh dsa key + ssh-keygen -f /etc/ssh/ssh_host_dsa_key -N '' -t dsa +fi + +if [ ! -f "/etc/ssh/ssh_host_ecdsa_key" ]; then + # generate fresh ecdsa key + ssh-keygen -f /etc/ssh/ssh_host_ecdsa_key -N '' -t dsa +fi + +if [ ! -f "/etc/ssh/ssh_host_ed25519_key" ]; then + # generate fresh ecdsa key + ssh-keygen -f /etc/ssh/ssh_host_ed25519_key -N '' -t dsa +fi + +#prepare run dir +if [ ! -d "/var/run/sshd" ]; then + mkdir -p /var/run/sshd +fi diff --git a/7.2-apache/Dockerfile b/7.2-apache/Dockerfile index fa56f17f..1bc96e4b 100644 --- a/7.2-apache/Dockerfile +++ b/7.2-apache/Dockerfile @@ -1,144 +1,47 @@ -FROM php:7.2.15-apache +FROM mcr.microsoft.com/oryx/php:7.2-20190607.1 LABEL maintainer="Azure App Services Container Images " -ENV PHP_VERSION 7.2.15 -COPY apache2.conf /bin/ +ENV PHP_VERSION 7.2 + COPY init_container.sh /bin/ COPY hostingstart.html /home/site/wwwroot/hostingstart.html -RUN a2enmod rewrite expires include deflate - -# install the PHP extensions we need -RUN apt-get update \ - && apt-get install -y --no-install-recommends \ - libpng-dev \ - libjpeg-dev \ - libpq-dev \ - libmcrypt-dev \ - libldap2-dev \ - libldb-dev \ - libicu-dev \ - libgmp-dev \ - libmagickwand-dev \ - libc-client-dev \ - libtidy-dev \ - libkrb5-dev \ - libxslt-dev \ - unixodbc-dev \ - openssh-server \ - vim \ - curl \ - wget \ - tcptraceroute \ - && chmod 755 /bin/init_container.sh \ +RUN chmod 755 /bin/init_container.sh \ + && mkdir -p /home/LogFiles/ \ && echo "root:Docker!" | chpasswd \ - && echo "cd /home" >> /etc/bash.bashrc \ - && ln -s /usr/lib/x86_64-linux-gnu/libldap.so /usr/lib/libldap.so \ - && ln -s /usr/lib/x86_64-linux-gnu/liblber.so /usr/lib/liblber.so \ - && ln -s /usr/include/x86_64-linux-gnu/gmp.h /usr/include/gmp.h \ - && rm -rf /var/lib/apt/lists/* \ - && pecl install imagick-beta \ - && pecl install mcrypt-1.0.1 \ - && pecl install sqlsrv pdo_sqlsrv \ - && echo extension=pdo_sqlsrv.so >> `php --ini | grep "Scan for additional .ini files" | sed -e "s|.*:\s*||"`/30-pdo_sqlsrv.ini \ - && echo extension=sqlsrv.so >> `php --ini | grep "Scan for additional .ini files" | sed -e "s|.*:\s*||"`/20-sqlsrv.ini \ - && docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr \ - && docker-php-ext-configure imap --with-kerberos --with-imap-ssl \ - && docker-php-ext-configure pdo_odbc --with-pdo-odbc=unixODBC,/usr \ - && docker-php-ext-install gd \ - mysqli \ - opcache \ - pdo \ - pdo_mysql \ - pdo_pgsql \ - pgsql \ - ldap \ - intl \ - gmp \ - zip \ - bcmath \ - mbstring \ - pcntl \ - calendar \ - exif \ - gettext \ - imap \ - tidy \ - shmop \ - soap \ - sockets \ - sysvmsg \ - sysvsem \ - sysvshm \ - pdo_odbc \ - wddx \ - xmlrpc \ - xsl \ - && docker-php-ext-enable imagick \ - && docker-php-ext-enable mcrypt - -# install odbc php ext -RUN apt-get update \ - && apt-get install unixodbc-dev - -RUN set -x \ - && docker-php-source extract \ - && cd /usr/src/php/ext/odbc \ - && phpize \ - && sed -ri 's@^ *test +"\$PHP_.*" *= *"no" *&& *PHP_.*=yes *$@#&@g' configure \ - && ./configure --with-unixODBC=shared,/usr \ - && docker-php-ext-install odbc - -RUN \ - rm -f /var/log/apache2/* \ - && rmdir /var/lock/apache2 \ - && rmdir /var/run/apache2 \ - && rmdir /var/log/apache2 \ - && chmod 777 /var/log \ - && chmod 777 /var/run \ - && chmod 777 /var/lock \ - && chmod 777 /bin/init_container.sh \ - && cp /bin/apache2.conf /etc/apache2/apache2.conf \ - && rm -rf /var/www/html \ - && rm -rf /var/log/apache2 \ - && mkdir -p /home/LogFiles \ - && ln -s /home/site/wwwroot /var/www/html \ - && ln -s /home/LogFiles /var/log/apache2 - - -RUN { \ - echo 'opcache.memory_consumption=128'; \ - echo 'opcache.interned_strings_buffer=8'; \ - echo 'opcache.max_accelerated_files=4000'; \ - echo 'opcache.revalidate_freq=60'; \ - echo 'opcache.fast_shutdown=1'; \ - echo 'opcache.enable_cli=1'; \ - } > /usr/local/etc/php/conf.d/opcache-recommended.ini + && echo "cd /home/site/wwwroot" >> /etc/bash.bashrc \ + && ln -s /home/site/wwwroot /var/www/html \ + && mkdir -p /opt/startup -RUN { \ - echo 'error_log=/var/log/apache2/php-error.log'; \ - echo 'display_errors=Off'; \ - echo 'log_errors=On'; \ - echo 'display_startup_errors=Off'; \ - echo 'date.timezone=UTC'; \ - } > /usr/local/etc/php/conf.d/php.ini +# configure startup +COPY sshd_config /etc/ssh/ +COPY ssh_setup.sh /tmp +RUN mkdir -p /opt/startup \ + && chmod -R +x /opt/startup \ + && chmod -R +x /tmp/ssh_setup.sh \ + && (sleep 1;/tmp/ssh_setup.sh 2>&1 > /dev/null) \ + && rm -rf /tmp/* ENV PORT 8080 ENV SSH_PORT 2222 EXPOSE 2222 8080 COPY sshd_config /etc/ssh/ -ENV APACHE_RUN_USER www-data - -# setup default site -RUN mkdir -p /opt/startup -COPY generateStartupCommand.sh /opt/startup/generateStartupCommand.sh -RUN chmod 755 /opt/startup/generateStartupCommand.sh - ENV WEBSITE_ROLE_INSTANCE_ID localRoleInstance ENV WEBSITE_INSTANCE_ID localInstance ENV PATH ${PATH}:/home/site/wwwroot -WORKDIR /var/www/html +RUN sed -i 's!ErrorLog ${APACHE_LOG_DIR}/error.log!ErrorLog /dev/stderr!g' /etc/apache2/apache2.conf +RUN sed -i 's!User ${APACHE_RUN_USER}!User www-data!g' /etc/apache2/apache2.conf +RUN sed -i 's!User ${APACHE_RUN_GROUP}!Group www-data!g' /etc/apache2/apache2.conf + +RUN { \ + echo 'DocumentRoot /home/site/wwwroot'; \ + echo 'DirectoryIndex default.htm default.html index.htm index.html index.php hostingstart.html'; \ + echo 'ServerName localhost'; \ + echo 'CustomLog /dev/stdout combined'; \ +} >> /etc/apache2/apache2.conf + +WORKDIR /home/site/wwwroot ENTRYPOINT ["/bin/init_container.sh"] diff --git a/7.2-apache/apache2.conf b/7.2-apache/apache2.conf deleted file mode 100644 index 1b70420d..00000000 --- a/7.2-apache/apache2.conf +++ /dev/null @@ -1,62 +0,0 @@ -# see http://sources.debian.net/src/apache2/2.4.10-1/debian/config-dir/apache2.conf - -Mutex file:/var/lock/apache2 default -PidFile /var/run/apache2/apache2.pid -Timeout 300 -KeepAlive On -MaxKeepAliveRequests 100 -KeepAliveTimeout 5 -User www-data -Group www-data -HostnameLookups Off -ErrorLog /dev/stderr -LogLevel warn - -IncludeOptional mods-enabled/*.load -IncludeOptional mods-enabled/*.conf - -IncludeOptional conf-enabled/*.conf -IncludeOptional sites-enabled/*.conf - -# ports.conf -Listen {PORT} - - - Options FollowSymLinks - AllowOverride None - Require all denied - - - - AllowOverride All - Require all granted - - -DocumentRoot /var/www/html - -AccessFileName .htaccess - - Require all denied - - -LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined -LogFormat "\"%{X-Client-IP}i\" %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined -LogFormat "%h %l %u %t \"%r\" %>s %O" common -LogFormat "%{Referer}i -> %U" referer -LogFormat "%{User-agent}i" agent - -CustomLog /dev/stdout combined - - - SetHandler application/x-httpd-php - - -# Multiple DirectoryIndex directives within the same context will add -# to the list of resources to look for rather than replace -# https://httpd.apache.org/docs/current/mod/mod_dir.html#directoryindex -DirectoryIndex disabled -DirectoryIndex default.htm default.html index.htm index.html index.php hostingstart.html - -ServerTokens Prod -ServerSignature Off - diff --git a/7.2-apache/generateStartupCommand.sh b/7.2-apache/generateStartupCommand.sh deleted file mode 100644 index fb412641..00000000 --- a/7.2-apache/generateStartupCommand.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -CMDFILE="/opt/startup/startupCommand" -DEFAULT_COMMAND="/usr/sbin/apache2ctl -D FOREGROUND" - -touch "$CMDFILE" - -CUSTOM_STARTUP_COMMAND=`cat $CMDFILE` - -if [ -z "$CUSTOM_STARTUP_COMMAND" ] -then - startupCommand="$DEFAULT_COMMAND" - echo "$startupCommand" >> "$CMDFILE" -fi diff --git a/7.2-apache/init_container.sh b/7.2-apache/init_container.sh index 727a527a..6a9fa7dd 100644 --- a/7.2-apache/init_container.sh +++ b/7.2-apache/init_container.sh @@ -17,16 +17,24 @@ cat /etc/motd # Get environment variables to show up in SSH session eval $(printenv | sed -n "s/^\([^=]\+\)=\(.*\)$/export \1=\2/p" | sed 's/"/\\\"/g' | sed '/=/s//="/' | sed 's/$/"/' >> /etc/profile) +# starting sshd process sed -i "s/SSH_PORT/$SSH_PORT/g" /etc/ssh/sshd_config -service ssh start -sed -i "s/{PORT}/$PORT/g" /etc/apache2/apache2.conf -mkdir /var/lock/apache2 -mkdir /var/run/apache2 +/usr/sbin/sshd -echo "$@" > /opt/startup/startupCommand -/opt/startup/generateStartupCommand.sh -chmod 755 /opt/startup/startupCommand +appPath="/home/site/wwwroot" +runFromPath="/tmp/webapp" +startupCommandPath="/opt/startup/startup.sh" +userStartupCommand="$@" +if [ -z "$userStartupCommand" ] +then + userStartupCommand="apache2-foreground"; +else + userStartupCommand="$userStartupCommand; apache2-foreground;" +fi -STARTUPCOMMAND=$(cat /opt/startup/startupCommand) -echo "Running $STARTUPCOMMAND" -eval "exec $STARTUPCOMMAND" +oryxArgs="-appPath $appPath -output $startupCommandPath \ + -bindPort $PORT -startupCommand '$userStartupCommand'" + +echo "Running oryx $oryxArgs" +eval oryx $oryxArgs +$startupCommandPath diff --git a/7.2-apache/ssh_setup.sh b/7.2-apache/ssh_setup.sh new file mode 100644 index 00000000..8bc40cc2 --- /dev/null +++ b/7.2-apache/ssh_setup.sh @@ -0,0 +1,26 @@ +#!/bin/sh + +if [ ! -f "/etc/ssh/ssh_host_rsa_key" ]; then + # generate fresh rsa key + ssh-keygen -f /etc/ssh/ssh_host_rsa_key -N '' -t rsa +fi + +if [ ! -f "/etc/ssh/ssh_host_dsa_key" ]; then + # generate fresh dsa key + ssh-keygen -f /etc/ssh/ssh_host_dsa_key -N '' -t dsa +fi + +if [ ! -f "/etc/ssh/ssh_host_ecdsa_key" ]; then + # generate fresh ecdsa key + ssh-keygen -f /etc/ssh/ssh_host_ecdsa_key -N '' -t dsa +fi + +if [ ! -f "/etc/ssh/ssh_host_ed25519_key" ]; then + # generate fresh ecdsa key + ssh-keygen -f /etc/ssh/ssh_host_ed25519_key -N '' -t dsa +fi + +#prepare run dir +if [ ! -d "/var/run/sshd" ]; then + mkdir -p /var/run/sshd +fi diff --git a/7.3-apache/Dockerfile b/7.3-apache/Dockerfile index 5588d919..906e3369 100644 --- a/7.3-apache/Dockerfile +++ b/7.3-apache/Dockerfile @@ -1,144 +1,47 @@ -FROM php:7.3.2-apache +FROM mcr.microsoft.com/oryx/php:7.3-20190607.1 LABEL maintainer="Azure App Services Container Images " -ENV PHP_VERSION 7.3.2 -COPY apache2.conf /bin/ +ENV PHP_VERSION 7.3 + COPY init_container.sh /bin/ COPY hostingstart.html /home/site/wwwroot/hostingstart.html -RUN a2enmod rewrite expires include deflate - -# install the PHP extensions we need -RUN apt-get update \ - && apt-get install -y --no-install-recommends \ - libpng-dev \ - libjpeg-dev \ - libpq-dev \ - libldap2-dev \ - libldb-dev \ - libicu-dev \ - libgmp-dev \ - libmagickwand-dev \ - libc-client-dev \ - libtidy-dev \ - libkrb5-dev \ - libxslt-dev \ - libzip-dev \ - unixodbc-dev \ - openssh-server \ - openssl \ - libssl-dev \ - vim \ - curl \ - wget \ - tcptraceroute \ - && chmod 755 /bin/init_container.sh \ +RUN chmod 755 /bin/init_container.sh \ + && mkdir -p /home/LogFiles/ \ && echo "root:Docker!" | chpasswd \ - && echo "cd /home" >> /etc/bash.bashrc \ - && ln -s /usr/lib/x86_64-linux-gnu/libldap.so /usr/lib/libldap.so \ - && ln -s /usr/lib/x86_64-linux-gnu/liblber.so /usr/lib/liblber.so \ - && ln -s /usr/include/x86_64-linux-gnu/gmp.h /usr/include/gmp.h \ - && rm -rf /var/lib/apt/lists/* \ - && pecl install imagick-beta \ - && pecl install sqlsrv pdo_sqlsrv \ - && echo extension=pdo_sqlsrv.so >> `php --ini | grep "Scan for additional .ini files" | sed -e "s|.*:\s*||"`/30-pdo_sqlsrv.ini \ - && echo extension=sqlsrv.so >> `php --ini | grep "Scan for additional .ini files" | sed -e "s|.*:\s*||"`/20-sqlsrv.ini \ - && docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr \ - && docker-php-ext-configure imap --with-kerberos --with-imap-ssl \ - && docker-php-ext-configure pdo_odbc --with-pdo-odbc=unixODBC,/usr \ - && docker-php-ext-install gd \ - mysqli \ - opcache \ - pdo \ - pdo_mysql \ - pdo_pgsql \ - pgsql \ - ldap \ - intl \ - gmp \ - zip \ - bcmath \ - mbstring \ - pcntl \ - calendar \ - exif \ - gettext \ - imap \ - tidy \ - shmop \ - soap \ - sockets \ - sysvmsg \ - sysvsem \ - sysvshm \ - pdo_odbc \ - wddx \ - xmlrpc \ - xsl \ - && docker-php-ext-enable imagick - -# install odbc php ext -RUN apt-get update \ - && apt-get install unixodbc-dev - -RUN set -x \ - && docker-php-source extract \ - && cd /usr/src/php/ext/odbc \ - && phpize \ - && sed -ri 's@^ *test +"\$PHP_.*" *= *"no" *&& *PHP_.*=yes *$@#&@g' configure \ - && ./configure --with-unixODBC=shared,/usr \ - && docker-php-ext-install odbc - -RUN \ - rm -f /var/log/apache2/* \ - && rmdir /var/lock/apache2 \ - && rmdir /var/run/apache2 \ - && rmdir /var/log/apache2 \ - && chmod 777 /var/log \ - && chmod 777 /var/run \ - && chmod 777 /var/lock \ - && chmod 777 /bin/init_container.sh \ - && cp /bin/apache2.conf /etc/apache2/apache2.conf \ - && rm -rf /var/www/html \ - && rm -rf /var/log/apache2 \ - && mkdir -p /home/LogFiles \ - && ln -s /home/site/wwwroot /var/www/html \ - && ln -s /home/LogFiles /var/log/apache2 - - -RUN { \ - echo 'opcache.memory_consumption=128'; \ - echo 'opcache.interned_strings_buffer=8'; \ - echo 'opcache.max_accelerated_files=4000'; \ - echo 'opcache.revalidate_freq=60'; \ - echo 'opcache.fast_shutdown=1'; \ - echo 'opcache.enable_cli=1'; \ - } > /usr/local/etc/php/conf.d/opcache-recommended.ini + && echo "cd /home/site/wwwroot" >> /etc/bash.bashrc \ + && ln -s /home/site/wwwroot /var/www/html \ + && mkdir -p /opt/startup -RUN { \ - echo 'error_log=/var/log/apache2/php-error.log'; \ - echo 'display_errors=Off'; \ - echo 'log_errors=On'; \ - echo 'display_startup_errors=Off'; \ - echo 'date.timezone=UTC'; \ - } > /usr/local/etc/php/conf.d/php.ini +# configure startup +COPY sshd_config /etc/ssh/ +COPY ssh_setup.sh /tmp +RUN mkdir -p /opt/startup \ + && chmod -R +x /opt/startup \ + && chmod -R +x /tmp/ssh_setup.sh \ + && (sleep 1;/tmp/ssh_setup.sh 2>&1 > /dev/null) \ + && rm -rf /tmp/* ENV PORT 8080 ENV SSH_PORT 2222 EXPOSE 2222 8080 COPY sshd_config /etc/ssh/ -ENV APACHE_RUN_USER www-data - -# setup default site -RUN mkdir -p /opt/startup -COPY generateStartupCommand.sh /opt/startup/generateStartupCommand.sh -RUN chmod 755 /opt/startup/generateStartupCommand.sh - ENV WEBSITE_ROLE_INSTANCE_ID localRoleInstance ENV WEBSITE_INSTANCE_ID localInstance ENV PATH ${PATH}:/home/site/wwwroot -WORKDIR /var/www/html +RUN sed -i 's!ErrorLog ${APACHE_LOG_DIR}/error.log!ErrorLog /dev/stderr!g' /etc/apache2/apache2.conf +RUN sed -i 's!User ${APACHE_RUN_USER}!User www-data!g' /etc/apache2/apache2.conf +RUN sed -i 's!User ${APACHE_RUN_GROUP}!Group www-data!g' /etc/apache2/apache2.conf + +RUN { \ + echo 'DocumentRoot /home/site/wwwroot'; \ + echo 'DirectoryIndex default.htm default.html index.htm index.html index.php hostingstart.html'; \ + echo 'ServerName localhost'; \ + echo 'CustomLog /dev/stdout combined'; \ +} >> /etc/apache2/apache2.conf + +WORKDIR /home/site/wwwroot ENTRYPOINT ["/bin/init_container.sh"] diff --git a/7.3-apache/apache2.conf b/7.3-apache/apache2.conf deleted file mode 100644 index 1b70420d..00000000 --- a/7.3-apache/apache2.conf +++ /dev/null @@ -1,62 +0,0 @@ -# see http://sources.debian.net/src/apache2/2.4.10-1/debian/config-dir/apache2.conf - -Mutex file:/var/lock/apache2 default -PidFile /var/run/apache2/apache2.pid -Timeout 300 -KeepAlive On -MaxKeepAliveRequests 100 -KeepAliveTimeout 5 -User www-data -Group www-data -HostnameLookups Off -ErrorLog /dev/stderr -LogLevel warn - -IncludeOptional mods-enabled/*.load -IncludeOptional mods-enabled/*.conf - -IncludeOptional conf-enabled/*.conf -IncludeOptional sites-enabled/*.conf - -# ports.conf -Listen {PORT} - - - Options FollowSymLinks - AllowOverride None - Require all denied - - - - AllowOverride All - Require all granted - - -DocumentRoot /var/www/html - -AccessFileName .htaccess - - Require all denied - - -LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined -LogFormat "\"%{X-Client-IP}i\" %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined -LogFormat "%h %l %u %t \"%r\" %>s %O" common -LogFormat "%{Referer}i -> %U" referer -LogFormat "%{User-agent}i" agent - -CustomLog /dev/stdout combined - - - SetHandler application/x-httpd-php - - -# Multiple DirectoryIndex directives within the same context will add -# to the list of resources to look for rather than replace -# https://httpd.apache.org/docs/current/mod/mod_dir.html#directoryindex -DirectoryIndex disabled -DirectoryIndex default.htm default.html index.htm index.html index.php hostingstart.html - -ServerTokens Prod -ServerSignature Off - diff --git a/7.3-apache/generateStartupCommand.sh b/7.3-apache/generateStartupCommand.sh deleted file mode 100644 index fb412641..00000000 --- a/7.3-apache/generateStartupCommand.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -CMDFILE="/opt/startup/startupCommand" -DEFAULT_COMMAND="/usr/sbin/apache2ctl -D FOREGROUND" - -touch "$CMDFILE" - -CUSTOM_STARTUP_COMMAND=`cat $CMDFILE` - -if [ -z "$CUSTOM_STARTUP_COMMAND" ] -then - startupCommand="$DEFAULT_COMMAND" - echo "$startupCommand" >> "$CMDFILE" -fi diff --git a/7.3-apache/init_container.sh b/7.3-apache/init_container.sh index 727a527a..6a9fa7dd 100644 --- a/7.3-apache/init_container.sh +++ b/7.3-apache/init_container.sh @@ -17,16 +17,24 @@ cat /etc/motd # Get environment variables to show up in SSH session eval $(printenv | sed -n "s/^\([^=]\+\)=\(.*\)$/export \1=\2/p" | sed 's/"/\\\"/g' | sed '/=/s//="/' | sed 's/$/"/' >> /etc/profile) +# starting sshd process sed -i "s/SSH_PORT/$SSH_PORT/g" /etc/ssh/sshd_config -service ssh start -sed -i "s/{PORT}/$PORT/g" /etc/apache2/apache2.conf -mkdir /var/lock/apache2 -mkdir /var/run/apache2 +/usr/sbin/sshd -echo "$@" > /opt/startup/startupCommand -/opt/startup/generateStartupCommand.sh -chmod 755 /opt/startup/startupCommand +appPath="/home/site/wwwroot" +runFromPath="/tmp/webapp" +startupCommandPath="/opt/startup/startup.sh" +userStartupCommand="$@" +if [ -z "$userStartupCommand" ] +then + userStartupCommand="apache2-foreground"; +else + userStartupCommand="$userStartupCommand; apache2-foreground;" +fi -STARTUPCOMMAND=$(cat /opt/startup/startupCommand) -echo "Running $STARTUPCOMMAND" -eval "exec $STARTUPCOMMAND" +oryxArgs="-appPath $appPath -output $startupCommandPath \ + -bindPort $PORT -startupCommand '$userStartupCommand'" + +echo "Running oryx $oryxArgs" +eval oryx $oryxArgs +$startupCommandPath diff --git a/7.3-apache/ssh_setup.sh b/7.3-apache/ssh_setup.sh new file mode 100644 index 00000000..8bc40cc2 --- /dev/null +++ b/7.3-apache/ssh_setup.sh @@ -0,0 +1,26 @@ +#!/bin/sh + +if [ ! -f "/etc/ssh/ssh_host_rsa_key" ]; then + # generate fresh rsa key + ssh-keygen -f /etc/ssh/ssh_host_rsa_key -N '' -t rsa +fi + +if [ ! -f "/etc/ssh/ssh_host_dsa_key" ]; then + # generate fresh dsa key + ssh-keygen -f /etc/ssh/ssh_host_dsa_key -N '' -t dsa +fi + +if [ ! -f "/etc/ssh/ssh_host_ecdsa_key" ]; then + # generate fresh ecdsa key + ssh-keygen -f /etc/ssh/ssh_host_ecdsa_key -N '' -t dsa +fi + +if [ ! -f "/etc/ssh/ssh_host_ed25519_key" ]; then + # generate fresh ecdsa key + ssh-keygen -f /etc/ssh/ssh_host_ed25519_key -N '' -t dsa +fi + +#prepare run dir +if [ ! -d "/var/run/sshd" ]; then + mkdir -p /var/run/sshd +fi From 016cac68c061d48c93e63755e61de29db99e3ccb Mon Sep 17 00:00:00 2001 From: blimp Date: Fri, 12 Jul 2019 16:48:56 -0700 Subject: [PATCH 2/2] blimp --- 5.6-apache/Dockerfile | 16 +++++++++++++--- 7.0-apache/Dockerfile | 16 +++++++++++++--- 7.2-apache/Dockerfile | 16 +++++++++++++--- 7.3-apache/Dockerfile | 16 +++++++++++++--- 4 files changed, 52 insertions(+), 12 deletions(-) diff --git a/5.6-apache/Dockerfile b/5.6-apache/Dockerfile index 07ca847a..64ca6aaf 100644 --- a/5.6-apache/Dockerfile +++ b/5.6-apache/Dockerfile @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/oryx/php:5.6-20190607.1 +FROM mcr.microsoft.com/oryx/php:5.6-20190708.2 LABEL maintainer="Azure App Services Container Images " ENV PHP_VERSION 5.6 @@ -34,13 +34,23 @@ ENV PATH ${PATH}:/home/site/wwwroot RUN sed -i 's!ErrorLog ${APACHE_LOG_DIR}/error.log!ErrorLog /dev/stderr!g' /etc/apache2/apache2.conf RUN sed -i 's!User ${APACHE_RUN_USER}!User www-data!g' /etc/apache2/apache2.conf RUN sed -i 's!User ${APACHE_RUN_GROUP}!Group www-data!g' /etc/apache2/apache2.conf - RUN { \ echo 'DocumentRoot /home/site/wwwroot'; \ echo 'DirectoryIndex default.htm default.html index.htm index.html index.php hostingstart.html'; \ echo 'ServerName localhost'; \ - echo 'CustomLog /dev/stdout combined'; \ + echo 'CustomLog /dev/stderr combined'; \ } >> /etc/apache2/apache2.conf +RUN rm -f /usr/local/etc/php/conf.d/php.ini \ + && { \ + echo 'error_log=/dev/stderr'; \ + echo 'display_errors=Off'; \ + echo 'log_errors=On'; \ + echo 'display_startup_errors=Off'; \ + echo 'date.timezone=UTC'; \ + echo 'zend_extension=opcache'; \ + } > /usr/local/etc/php/conf.d/php.ini + +RUN rm -f /etc/apache2/conf-enabled/other-vhosts-access-log.conf WORKDIR /home/site/wwwroot diff --git a/7.0-apache/Dockerfile b/7.0-apache/Dockerfile index ec35e422..70351a6d 100644 --- a/7.0-apache/Dockerfile +++ b/7.0-apache/Dockerfile @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/oryx/php:7.0-20190607.1 +FROM mcr.microsoft.com/oryx/php:7.0-20190708.2 LABEL maintainer="Azure App Services Container Images " ENV PHP_VERSION 7.0 @@ -34,13 +34,23 @@ ENV PATH ${PATH}:/home/site/wwwroot RUN sed -i 's!ErrorLog ${APACHE_LOG_DIR}/error.log!ErrorLog /dev/stderr!g' /etc/apache2/apache2.conf RUN sed -i 's!User ${APACHE_RUN_USER}!User www-data!g' /etc/apache2/apache2.conf RUN sed -i 's!User ${APACHE_RUN_GROUP}!Group www-data!g' /etc/apache2/apache2.conf - RUN { \ echo 'DocumentRoot /home/site/wwwroot'; \ echo 'DirectoryIndex default.htm default.html index.htm index.html index.php hostingstart.html'; \ echo 'ServerName localhost'; \ - echo 'CustomLog /dev/stdout combined'; \ + echo 'CustomLog /dev/stderr combined'; \ } >> /etc/apache2/apache2.conf +RUN rm -f /usr/local/etc/php/conf.d/php.ini \ + && { \ + echo 'error_log=/dev/stderr'; \ + echo 'display_errors=Off'; \ + echo 'log_errors=On'; \ + echo 'display_startup_errors=Off'; \ + echo 'date.timezone=UTC'; \ + echo 'zend_extension=opcache'; \ + } > /usr/local/etc/php/conf.d/php.ini + +RUN rm -f /etc/apache2/conf-enabled/other-vhosts-access-log.conf WORKDIR /home/site/wwwroot diff --git a/7.2-apache/Dockerfile b/7.2-apache/Dockerfile index 1bc96e4b..39955c7f 100644 --- a/7.2-apache/Dockerfile +++ b/7.2-apache/Dockerfile @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/oryx/php:7.2-20190607.1 +FROM mcr.microsoft.com/oryx/php:7.2-20190708.2 LABEL maintainer="Azure App Services Container Images " ENV PHP_VERSION 7.2 @@ -34,13 +34,23 @@ ENV PATH ${PATH}:/home/site/wwwroot RUN sed -i 's!ErrorLog ${APACHE_LOG_DIR}/error.log!ErrorLog /dev/stderr!g' /etc/apache2/apache2.conf RUN sed -i 's!User ${APACHE_RUN_USER}!User www-data!g' /etc/apache2/apache2.conf RUN sed -i 's!User ${APACHE_RUN_GROUP}!Group www-data!g' /etc/apache2/apache2.conf - RUN { \ echo 'DocumentRoot /home/site/wwwroot'; \ echo 'DirectoryIndex default.htm default.html index.htm index.html index.php hostingstart.html'; \ echo 'ServerName localhost'; \ - echo 'CustomLog /dev/stdout combined'; \ + echo 'CustomLog /dev/stderr combined'; \ } >> /etc/apache2/apache2.conf +RUN rm -f /usr/local/etc/php/conf.d/php.ini \ + && { \ + echo 'error_log=/dev/stderr'; \ + echo 'display_errors=Off'; \ + echo 'log_errors=On'; \ + echo 'display_startup_errors=Off'; \ + echo 'date.timezone=UTC'; \ + echo 'zend_extension=opcache'; \ + } > /usr/local/etc/php/conf.d/php.ini + +RUN rm -f /etc/apache2/conf-enabled/other-vhosts-access-log.conf WORKDIR /home/site/wwwroot diff --git a/7.3-apache/Dockerfile b/7.3-apache/Dockerfile index 906e3369..822fc90e 100644 --- a/7.3-apache/Dockerfile +++ b/7.3-apache/Dockerfile @@ -1,4 +1,4 @@ -FROM mcr.microsoft.com/oryx/php:7.3-20190607.1 +FROM mcr.microsoft.com/oryx/php:7.3-20190708.2 LABEL maintainer="Azure App Services Container Images " ENV PHP_VERSION 7.3 @@ -34,13 +34,23 @@ ENV PATH ${PATH}:/home/site/wwwroot RUN sed -i 's!ErrorLog ${APACHE_LOG_DIR}/error.log!ErrorLog /dev/stderr!g' /etc/apache2/apache2.conf RUN sed -i 's!User ${APACHE_RUN_USER}!User www-data!g' /etc/apache2/apache2.conf RUN sed -i 's!User ${APACHE_RUN_GROUP}!Group www-data!g' /etc/apache2/apache2.conf - RUN { \ echo 'DocumentRoot /home/site/wwwroot'; \ echo 'DirectoryIndex default.htm default.html index.htm index.html index.php hostingstart.html'; \ echo 'ServerName localhost'; \ - echo 'CustomLog /dev/stdout combined'; \ + echo 'CustomLog /dev/stderr combined'; \ } >> /etc/apache2/apache2.conf +RUN rm -f /usr/local/etc/php/conf.d/php.ini \ + && { \ + echo 'error_log=/dev/stderr'; \ + echo 'display_errors=Off'; \ + echo 'log_errors=On'; \ + echo 'display_startup_errors=Off'; \ + echo 'date.timezone=UTC'; \ + echo 'zend_extension=opcache'; \ + } > /usr/local/etc/php/conf.d/php.ini + +RUN rm -f /etc/apache2/conf-enabled/other-vhosts-access-log.conf WORKDIR /home/site/wwwroot