Created
January 23, 2020 08:45
-
-
Save petrikoz/9d70047a0019fd25eb47173274d0dd92 to your computer and use it in GitHub Desktop.
Dockerfile for run uWSGI with PHP plugin in Alpine
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[uwsgi] | |
inherit = base | |
main_plugin = | |
embedded_plugins = null | |
plugin_dir = /usr/lib/uwsgi | |
plugin_build_dir = . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM alpine | |
MAINTAINER Petr Zelenin (https://github.com/petrikoz) | |
# uWSGI | |
ENV UWSGI_SRC_DIR /opt/uwsgi | |
ENV UWSGI_USER uwsgi | |
ENV UWSGI_VASSAL /etc/uwsgi/conf.d/vassal-php.ini | |
COPY --chown=nobody:nobody alpine.buildconf ${UWSGI_SRC_DIR}/alpine.buildconf | |
RUN set -x \ | |
&& apk add --no-cache php7-embed uwsgi-http \ | |
&& apk add --no-cache --virtual .build-deps \ | |
argon2-dev \ | |
build-base \ | |
libxml2-dev \ | |
linux-headers \ | |
php7-dev \ | |
python3 \ | |
&& uwsgiVersion="$(uwsgi --version)" \ | |
&& buildDir="uwsgi-${uwsgiVersion}" \ | |
&& chown -R ${UWSGI_USER}:${UWSGI_USER} ${UWSGI_SRC_DIR} \ | |
&& su ${UWSGI_USER} -s /bin/sh -c " \ | |
cd ${UWSGI_SRC_DIR} \ | |
&& wget -qO- \"https://projects.unbit.it/downloads/${buildDir}.tar.gz\" | tar xz \ | |
&& cd ${buildDir} \ | |
&& mv ${UWSGI_SRC_DIR}/alpine.buildconf buildconf/alpine.ini \ | |
&& UWSGICONFIG_PHPPATH=/usr/bin/php-config \ | |
UWSGICONFIG_PHPLIBDIR=\" $(/usr/bin/php-config --extension-dir)/session.a\" \ | |
python3 uwsgiconfig.py --plugin plugins/php alpine php \ | |
&& ls -l \ | |
" \ | |
&& mv ${UWSGI_SRC_DIR}/${buildDir}/php_plugin.so /usr/lib/uwsgi \ | |
&& rm -rf ${UWSGI_SRC_DIR} \ | |
&& apk del .build-deps | |
COPY --chown=${UWSGI_USER}:${UWSGI_USER} uwsgi.ini ${UWSGI_VASSAL} | |
# Project | |
ENV PROJECT_DIR /code | |
RUN mkdir -p ${PROJECT_DIR} && chown -R ${UWSGI_USER}:${UWSGI_USER} ${PROJECT_DIR} | |
WORKDIR ${PROJECT_DIR} | |
# Entrypoint | |
EXPOSE 8000 | |
CMD uwsgi --ini ${UWSGI_VASSAL} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[uwsgi] | |
; load the required plugins, php is loaded as the default (0) modifier | |
plugins = http,0:php | |
; bind the http router to port | |
http = :8000 | |
master = true | |
; drop privileges | |
uid = uwsgi | |
gid = uwsgi | |
; our working dir | |
project_dir = /code | |
; chdir to it (just for fun) | |
chdir = %(project_dir) | |
; check for static files in it | |
check-static = %(project_dir) | |
; ...but skip .php and .inc extensions | |
static-skip-ext = .php | |
static-skip-ext = .inc | |
; search for index.html when a dir is requested | |
static-index = index.html | |
; jail our php environment to project_dir | |
php-docroot = %(project_dir) | |
; ... and to the .php and .inc extensions | |
php-allowed-ext = .php | |
php-allowed-ext = .inc | |
; and search for index.php and index.inc if required | |
php-index = index.php | |
php-index = index.inc | |
; set php timezone | |
php-set = date.timezone=Asia/Yekaterinburg |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment