Skip to content

Commit ed1ee69

Browse files
committed
Add composer
1 parent 75b5beb commit ed1ee69

File tree

4 files changed

+31
-9
lines changed

4 files changed

+31
-9
lines changed

Dockerfile

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,29 @@ ARG OLS_VERSION=1.6.18
22
ARG PHP_VERSION=lsphp74
33
FROM litespeedtech/openlitespeed:$OLS_VERSION-$PHP_VERSION
44

5-
#install SSH
5+
# Install Package Requirement
66
RUN set -ex; \
77
apt-get update; \
88
apt-get install -y --no-install-recommends \
9+
wget \
910
rsync \
1011
unzip \
1112
inotify-tools \
1213
openssh-server; \
1314
rm -rf /var/lib/apt/lists/*
1415

15-
RUN set -ex; \
16-
echo "root:Docker!" | chpasswd; \
17-
rm -f /etc/ssh/sshd_config
18-
16+
# Setup SSH
17+
#RUN set -ex; \
18+
# rm -f /etc/ssh/sshd_config
1919
COPY sshd_config /etc/ssh/
2020
COPY ssh_setup.sh /etc/ssh/
21-
RUN chmod -R +x /etc/ssh/ssh_setup.sh; \
22-
(sleep 1;. /etc/ssh/ssh_setup.sh 2>&1 > /dev/null); \
23-
rm -rf /etc/ssh/ssh_setup.sh
21+
RUN set -ex; \
22+
echo "root:Docker!" | chpasswd; \
23+
chmod -R +x /etc/ssh/ssh_setup.sh; \
24+
(sleep 1;. /etc/ssh/ssh_setup.sh 2>&1 > /dev/null); \
25+
rm -rf /etc/ssh/ssh_setup.sh
2426

27+
# Install oSync
2528
ADD https://github.com/deajan/osync/archive/v1.3-beta3.tar.gz /root/osync.tar.gz
2629
COPY sync.conf /usr/src/php/
2730
RUN set -ex; \
@@ -37,6 +40,17 @@ RUN set -ex; \
3740
rm -rf osync*; \
3841
chmod 444 /usr/src/php/sync.conf
3942

43+
# Install composer
44+
RUN set -ex; \
45+
EXPECTED_CHECKSUM="$(wget -q -O - https://composer.github.io/installer.sig)"; \
46+
curl -o composer-setup.php -fSL "https://getcomposer.org/installer"; \
47+
echo "$EXPECTED_CHECKSUM *composer-setup.php" | sha384sum -c -; \
48+
mkdir -p /usr/src/composer; \
49+
php composer-setup.php --install-dir=/usr/src/composer; \
50+
rm composer-setup.php; \
51+
ln -s /usr/src/composer/composer.phar /usr/local/bin/composer
52+
53+
# Configure LiteSpeed
4054
COPY phpsite.conf /usr/local/lsws/conf/templates/
4155
COPY httpd_config.conf /usr/local/lsws/conf/
4256
RUN chown 999:999 /usr/local/lsws/conf -R

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@ Because FTP transactions are handled outside of the container to the durable sto
1616
| Linux | Ubuntu 18.04 |
1717
| OpenLiteSpeed | 1.6.18 |
1818
| PHP | 7.4 |
19+
| Composer | latest |
1920

2021
* SSH has been enabled on port 2222 to be able to SSH to the container in Azure App Service.
2122
* A cron/scheduled task is setup to run `/home/site/cron.sh`, if it exists, every 10 minutes. Set `PHP_CRON` environment variable to a valid [cron formated](https://en.wikipedia.org/wiki/Cron) schedule to change from the default execute interval. The last `cron.sh` task run is logged to `/home/site/cron.log`
23+
* If a composer.lock file is found in the root of your site, `composer install` will be run to install any non-dev required packages.
2224

2325
## Container storage for site
2426

infra.arm.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@
4141
],
4242
"linuxFxVersion": "DOCKER|johnwcarew/azure-app-service-openlitespeed-php:1.6.18-lsphp74",
4343
"appCommandLine": "",
44-
"alwaysOn": true
44+
"alwaysOn": true,
45+
"http20Enabled": true
4546
},
4647
"serverFarmId": "[concat('/subscriptions/', parameters('subscriptionId'),'/resourcegroups/', parameters('serverFarmResourceGroup'), '/providers/Microsoft.Web/serverfarms/', parameters('hostingPlanName'))]",
4748
"clientAffinityEnabled": false

init-php-env.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ fi
5252
echo -e >&2 "${GREEN}Monitoring .htaccess changes.${NC}"
5353
(while read line; do if [ "$line" == ".htaccess" ]; then sleep 5; echo -e "${ORANGE}$line modified, gracefully restarting litespeed${NC}"; /usr/local/lsws/bin/lswsctrl try-restart; fi; done < <(inotifywait -m -e modify -e move -e create -e delete --format "%f" "/var/www/vhosts/site-local/wwwroot/")) &
5454

55+
if [ -f /home/site/wwwroot/composer.lock ]; then
56+
echo -e >&2 "${GREEN}Installing composer packages.${NC}"
57+
composer install --no-dev --optimize-autoloader --no-interaction --working-dir=/home/site/wwwroot/
58+
fi
59+
5560
SYNC_MAIN="/usr/src/maintenance/sync_maintenance.html"
5661
if [ -f /home/site/sync_maintenance.html ]; then
5762
echo -e >&2 "${ORANGE}Using custom sync maintenance page.${NC}"

0 commit comments

Comments
 (0)