Add PHP support
Signed-off-by: Emmy D'Anello <emmy@luemy.eu>
This commit is contained in:
parent
b46254ff82
commit
0440fc6144
14
Dockerfile
14
Dockerfile
@ -1,7 +1,10 @@
|
||||
FROM python:3-alpine
|
||||
|
||||
RUN apk --update add git nginx && \
|
||||
rm /var/cache/apk/*
|
||||
ARG PHP_ENABLED
|
||||
ENV PHP_ENABLED=${PHP_ENABLED}
|
||||
ENV NGINX_SERVER_GIT_URL=""
|
||||
|
||||
RUN apk add --no-cache git nginx rsync; if [[ -n "$PHP_ENABLED" ]]; then apk add --no-cache php-fpm php-session php-pdo_mysql; fi
|
||||
|
||||
RUN pip install requests --no-cache-dir
|
||||
|
||||
@ -10,13 +13,16 @@ RUN mkdir -p /var/www/html
|
||||
|
||||
# Configure nginx
|
||||
RUN ln -sf /dev/stdout /var/log/nginx/access.log && ln -sf /dev/stderr /var/log/nginx/error.log
|
||||
COPY nginx.conf /etc/nginx/http.d/mkdocs-server.conf
|
||||
RUN rm /etc/nginx/http.d/default.conf
|
||||
COPY nginx*.conf /tmp/
|
||||
RUN if [[ -z "$PHP_ENABLED" ]]; then cp /tmp/nginx.conf /etc/nginx/http.d/server.conf; else cp /tmp/nginx-php.conf /etc/nginx/http.d/server-php.conf; fi; rm /etc/nginx/http.d/default.conf
|
||||
|
||||
COPY ./entrypoint.sh /hook
|
||||
COPY ./docker-hook /hook
|
||||
COPY ./update.sh /hook
|
||||
|
||||
RUN mkdir /conf
|
||||
VOLUME /conf
|
||||
|
||||
WORKDIR /var/www/html
|
||||
|
||||
ENTRYPOINT ["/hook/entrypoint.sh"]
|
||||
|
@ -3,6 +3,10 @@
|
||||
cd /var/www/html
|
||||
[ -d .git ] || git clone ${NGINX_SERVER_GIT_URL} .
|
||||
|
||||
chown -R nobody:nobody /conf
|
||||
rsync -arvP /conf/ /var/www/html/
|
||||
|
||||
git pull
|
||||
if [[ -n "$PHP_ENABLED" ]]; then php-fpm83; fi
|
||||
nginx&
|
||||
python /hook/docker-hook -c sh /hook/update.sh
|
||||
|
42
nginx-php.conf
Normal file
42
nginx-php.conf
Normal file
@ -0,0 +1,42 @@
|
||||
upstream trigger-ci {
|
||||
server 127.0.0.1:8555;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name static-server;
|
||||
root /var/www/html;
|
||||
index index.html index.htm index.php;
|
||||
error_page 404 /404.html;
|
||||
|
||||
location /trigger-ci.json {
|
||||
proxy_pass http://trigger-ci;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header Host $host;
|
||||
proxy_redirect off;
|
||||
}
|
||||
|
||||
location /.git* {
|
||||
return 404;
|
||||
}
|
||||
|
||||
location /README* {
|
||||
return 404;
|
||||
}
|
||||
|
||||
location ~ \.php$ {
|
||||
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
|
||||
|
||||
# Check that the PHP script exists before passing it
|
||||
try_files $fastcgi_script_name =404;
|
||||
|
||||
# Bypass the fact that try_files resets $fastcgi_path_info
|
||||
# see: http://trac.nginx.org/nginx/ticket/321
|
||||
set $path_info $fastcgi_path_info;
|
||||
fastcgi_param PATH_INFO $path_info;
|
||||
|
||||
fastcgi_index index.php;
|
||||
include fastcgi.conf;
|
||||
fastcgi_pass 127.0.0.1:9000;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user