简单粗暴点吧
jenkins 镜像下载:docker pull jenkins:alpine
dockfile 原地址:https://gist.github.com/phith0n/373cc078a8b25a20432408d5d7556770
php5.dockerfile FROM alpine:3.3 MAINTAINER Didiet Noor <dnoor@kulina.id> (@lynxluna) # Patch APK Mirror to YKode RUN echo "http://dl-4.alpinelinux.org/alpine/v3.3/main" > /etc/apk/repositories ENV TIMEZONE Asia/Shanghai ENV PHP_MEMORY_LIMIT 512M ENV MAX_UPLOAD 50M ENV PHP_MAX_FILE_UPLOAD 200 ENV PHP_MAX_POST 100M RUN apk update && \ apk add tzdata && \ cp /usr/share/zoneinfo/${TIMEZONE} /etc/localtime && \ echo "${TIMEZONE}" > /etc/timezone && \ apk add php-intl \ php-mcrypt \ php-openssl \ php-gmp \ php-json \ php-dom \ php-pdo \ php-zip \ php-zlib \ php-mysqli \ php-bcmath \ php-gd \ php-xcache \ php-pdo_mysql \ php-gettext \ php-xmlreader \ php-xmlrpc \ php-bz2 \ php-memcache \ php-iconv \ php-curl \ php-ctype \ php-fpm \ php-phar \ php && \ curl -sS https://getcomposer.org/installer | \ php -- --install-dir=/usr/bin --filename=composer && \ sed -i -e "s/;daemonize\s*=\s*yes/daemonize = no/g" /etc/php/php-fpm.conf && \ sed -i -e "s/listen\s*=\s*127.0.0.1:9000/listen = 9000/g" /etc/php/php-fpm.conf && \ sed -i "s|;date.timezone =.*|date.timezone = ${TIMEZONE}|" /etc/php/php.ini && \ sed -i "s|memory_limit =.*|memory_limit = ${PHP_MEMORY_LIMIT}|" /etc/php/php.ini && \ sed -i "s|upload_max_filesize =.*|upload_max_filesize = ${MAX_UPLOAD}|" /etc/php/php.ini && \ sed -i "s|max_file_uploads =.*|max_file_uploads = ${PHP_MAX_FILE_UPLOAD}|" /etc/php/php.ini && \ sed -i "s|post_max_size =.*|max_file_uploads = ${PHP_MAX_POST}|" /etc/php/php.ini && \ sed -i "s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/" /etc/php/php.ini && \ mkdir /www && \ apk del tzdata && \ rm -rf /var/cache/apk/*
php7.dockerfile FROM alpine:edge MAINTAINER phithon <root@leavesongs.com> ENV TIMEZONE Asia/Shanghai ENV PHP_MEMORY_LIMIT 512M ENV MAX_UPLOAD 50M ENV PHP_MAX_FILE_UPLOAD 200 ENV PHP_MAX_POST 100M RUN apk update && \ apk add tzdata curl && \ cp /usr/share/zoneinfo/${TIMEZONE} /etc/localtime && \ echo "${TIMEZONE}" > /etc/timezone && \ apk --update --repository=http://dl-4.alpinelinux.org/alpine/edge/testing add \ php7 \ php7-common \ php7-intl \ php7-gd \ php7-mcrypt \ php7-openssl \ php7-gmp \ php7-json \ php7-dom \ php7-pdo \ php7-zip \ php7-zlib \ php7-mysqli \ php7-bcmath \ php7-pdo_mysql \ php7-gettext \ php7-xmlreader \ php7-xmlrpc \ php7-bz2 \ php7-iconv \ php7-curl \ php7-ctype \ php7-fpm \ php7-mbstring \ php7-session \ php7-phar && \ curl -sS https://getcomposer.org/installer | \ php7 -- --install-dir=/usr/bin --filename=composer && \ sed -i -e "s/;daemonize\s*=\s*yes/daemonize = no/g" /etc/php7/php-fpm.conf && \ sed -i -e "s/listen\s*=\s*127.0.0.1:9000/listen = 9000/g" /etc/php7/php-fpm.d/www.conf && \ sed -i "s|;date.timezone =.*|date.timezone = ${TIMEZONE}|" /etc/php7/php.ini && \ sed -i "s|memory_limit =.*|memory_limit = ${PHP_MEMORY_LIMIT}|" /etc/php7/php.ini && \ sed -i "s|upload_max_filesize =.*|upload_max_filesize = ${MAX_UPLOAD}|" /etc/php7/php.ini && \ sed -i "s|max_file_uploads =.*|max_file_uploads = ${PHP_MAX_FILE_UPLOAD}|" /etc/php7/php.ini && \ sed -i "s|post_max_size =.*|max_file_uploads = ${PHP_MAX_POST}|" /etc/php7/php.ini && \ sed -i "s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/" /etc/php7/php.ini && \ ln -s /usr/bin/php7 /usr/bin/php && \ mkdir /www && \ apk del tzdata curl && \ rm -rf /var/cache/apk/*
这里选择php5的版本
docker build -t alpine:v1 .
nginx-dockerfile:
FROM alpine:v1 ENV TIME_ZONE Asiz/Shanghai RUN mkdir /opt/www -p RUN mkdir /var/log/www -p RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories && \ apk update && \ apk -u add nginx &&\ apk -u add supervisor ADD nginx.conf /etc/nginx/ ADD default.conf /etc/nginx/conf.d/ ADD supervisord.conf /etc/supervisord.conf CMD ["supervisord", "-c", "/etc/supervisord.conf"]
nginx.conf #user nobody; worker_processes auto; error_log /var/log/nginx/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid; events { worker_connections 65535; use epoll; } http { include mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; tcp_nopush on; tcp_nodelay on; server_tokens off; keepalive_timeout 120; gzip on; gzip_min_length 1k; gzip_buffers 4 16k; gzip_http_version 1.1; gzip_comp_level 2; gzip_types text/plain text/css application/json application/javascript application/x-javascript text/javascript text/xml application/rss+xml application/atom+xml application/rdf+xml image/svg+xml; gzip_vary on; client_header_buffer_size 16k; large_client_header_buffers 16 32k; open_file_cache max=65535 inactive=60s; open_file_cache_valid 30s; open_file_cache_min_uses 1; fastcgi_connect_timeout 300; fastcgi_send_timeout 300; fastcgi_read_timeout 300; fastcgi_buffer_size 64k; fastcgi_buffers 4 64k; fastcgi_busy_buffers_size 128k; fastcgi_temp_file_write_size 128k; client_max_body_size 50m; client_body_buffer_size 256k; client_header_timeout 3m; client_body_timeout 3m; send_timeout 3m; include conf.d/*.conf; }
cat default.conf server { listen 80; server_name www.default.com; charset utf-8; root /opt/www; error_log /var/log/www/www.default.com.log.err; # access_log /var/log/www/www.default.com.log main; index index.html index.php; large_client_header_buffers 4 16k; client_max_body_size 300m; client_body_buffer_size 128k; proxy_connect_timeout 300; proxy_read_timeout 300; proxy_send_timeout 300; proxy_buffer_size 64k; proxy_buffers 4 32k; proxy_busy_buffers_size 64k; proxy_temp_file_write_size 64k; gzip on; location / { try_files $uri $uri/ /index.php?$query_string; } location ~ \.php { # try_files $uri =404; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; set $real_script_name $fastcgi_script_name; if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") { set $real_script_name $1; set $path_info $2; } fastcgi_param SCRIPT_FILENAME $document_root$real_script_name; fastcgi_param SCRIPT_NAME $real_script_name; fastcgi_param PATH_INFO $path_info; include fastcgi_params; } }
cat /etc/supervisord.conf
[supervisord]
nodaemon=true
[program:php]
command=php-fpm
stdout_events_enabled=true
stderr_events_enabled=true
[program:nginx]
startsecs=50
command=nginx -g "daemon off;"
[program:crond]
command=crond -f
autostart=true
autorestart=true
redirect_stderr=true
docker run -itd -p 0.0.0.0:80:80 d4012c88f6d0
dcoker exec -it 31118398060a sh