Skip to content

Instantly share code, notes, and snippets.

@johannes85
Created May 31, 2021 11:46
Show Gist options
  • Save johannes85/9ba23b890355c2424a8c18359780d7d1 to your computer and use it in GitHub Desktop.
Save johannes85/9ba23b890355c2424a8c18359780d7d1 to your computer and use it in GitHub Desktop.
?vendor/autoload.php
{
"require": {
"xp-forge/web": "2.8.0",
"xp-framework/core": "^9.5.3",
"xp-framework/networking": "^9.3.0"
}
}
FROM debian:buster
RUN apt-get update && apt-get install -y apt-transport-https lsb-release ca-certificates curl gnupg
RUN \
curl https://baltocdn.com/xp-framework/signing.asc | apt-key add - && \
echo 'deb https://baltocdn.com/xp-framework/xp-runners/reference/ all main' | tee -a /etc/apt/sources.list.d/xp.list && \
echo 'deb https://packages.sury.org/php/ buster main' > /etc/apt/sources.list.d/php.list && \
curl https://packages.sury.org/php/apt.gpg | apt-key add
RUN apt-get update && apt-get install -y \
php7.3-bcmath \
php7.3-bz2 \
php7.3-cli \
php7.3-curl \
php7.3-gd \
php7.3-imap \
php7.3-mbstring \
php7.3-json \
php7.3-ldap \
php7.3-mysql \
php7.3-pgsql \
php7.3-xsl \
php7.3-zip \
php7.3-redis \
php7.3-soap \
xp-runners \
netcat \
&& rm -rf /var/lib/apt/lists/*
# Set default php version
RUN update-alternatives --set php /usr/bin/php7.3
ENV COMPOSER_ALLOW_SUPERUSER 1
ENV COMPOSER_HOME /opt/docker
ENV COMPOSER_VERSION 1.8.0
RUN curl --silent --fail --location --retry 3 --output /tmp/installer.php --url https://raw.githubusercontent.com/composer/getcomposer.org/b9cc694e39b669376d7a033fb348324b945bce05/web/installer \
&& php -r " \
\$signature = 'c5b9b6d368201a9db6f74e2611495f369991b72d9c8cbd3ffbc63edff210eb73d46ffbfce88669ad33695ef77dc76976'; \
\$hash = hash('sha384', file_get_contents('/tmp/installer.php')); \
if (!hash_equals(\$signature, \$hash)) { \
unlink('/tmp/installer.php'); \
echo 'Integrity check failed, installer is either corrupt or worse.' . PHP_EOL; \
exit(1); \
}" \
&& php /tmp/installer.php --no-ansi --install-dir=/usr/bin --filename=composer --version=${COMPOSER_VERSION} \
&& composer --ansi --version --no-interaction \
&& rm -f /tmp/installer.php
COPY . /app
WORKDIR /app
RUN composer install && chmod +x test.sh
CMD ./test.sh
<?php
class Service extends \web\Application {
/**
* Application routing
*
* @return array
*/
protected function routes() {
return [
'/' => function($req, $res) {
$res->answer(200, 'OK');
$res->send('Hello '.$req->param('name', 'Guest'), 'text/plain');
}
];
}
}
/usr/bin/xp web Service &
echo "Waiting for server..."
sleep 3;
echo "Opening http://127.0.0.1:8080..."
curl -v http://127.0.0.1:8080
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment