Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
157 changes: 37 additions & 120 deletions 5.6-apache/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,140 +1,57 @@
FROM php:5.6.40-apache
FROM mcr.microsoft.com/oryx/php:5.6-20190708.2
LABEL maintainer="Azure App Services Container Images <[email protected]>"

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
&& echo "cd /home/site/wwwroot" >> /etc/bash.bashrc \
&& ln -s /home/site/wwwroot /var/www/html \
&& mkdir -p /opt/startup

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
# 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/*

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
ENV PORT 8080
ENV SSH_PORT 2222
EXPOSE 2222 8080
COPY sshd_config /etc/ssh/

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
ENV WEBSITE_ROLE_INSTANCE_ID localRoleInstance
ENV WEBSITE_INSTANCE_ID localInstance
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 'error_log=/var/log/apache2/php-error.log'; \
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/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

ENV PORT 8080
ENV SSH_PORT 2222
EXPOSE 2222 8080
COPY sshd_config /etc/ssh/

ENV APACHE_RUN_USER www-data
RUN rm -f /etc/apache2/conf-enabled/other-vhosts-access-log.conf

# 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
WORKDIR /home/site/wwwroot

ENTRYPOINT ["/bin/init_container.sh"]

61 changes: 0 additions & 61 deletions 5.6-apache/apache2.conf

This file was deleted.

14 changes: 0 additions & 14 deletions 5.6-apache/generateStartupCommand.sh

This file was deleted.

28 changes: 18 additions & 10 deletions 5.6-apache/init_container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
26 changes: 26 additions & 0 deletions 5.6-apache/ssh_setup.sh
Original file line number Diff line number Diff line change
@@ -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
Loading