Skip to content

Instantly share code, notes, and snippets.

@iansltx
Created March 1, 2016 03:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iansltx/119cae66ab1defa03762 to your computer and use it in GitHub Desktop.
Save iansltx/119cae66ab1defa03762 to your computer and use it in GitHub Desktop.
runit + php7 dev server + better ctrl-c response Docker
FROM alpine:3.3
# install packages
RUN echo "@testing http://dl-4.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories && \
apk add --update php7-common@testing php7-pdo_mysql@testing \
php7-pcntl@testing php7-json@testing php7-opcache@testing \
php7-mbstring@testing php7-fpm@testing php7@testing nginx runit@testing
# set up app
RUN mkdir /var/app
COPY index.php /var/app/index.php
# set up runit
RUN mkdir -p /etc/service/php-server && echo '#!/bin/sh' >> /etc/service/php-server/run && echo 'php7 -S 0.0.0.0:80 /var/app/index.php' >> /etc/service/php-server/run && chmod +x /etc/service/php-server/run
COPY runsvinit /sbin/runsvinit
RUN chmod +x /sbin/runsvinit
ENTRYPOINT ["/sbin/runsvinit"]
# ENTRYPOINT ["/sbin/runsvdir", "/etc/service"]
EXPOSE 80
<?php phpinfo();
#!/bin/sh
sv_stop() {
for s in $(ls -d /etc/service/*)
do
/sbin/sv stop $s
done
}
trap "sv_stop; exit" SIGTERM
/sbin/runsvdir /etc/service &
wait
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment