[feat:1.16.1] 删除Alpine系统Dockerfile文件

This commit is contained in:
2020-04-21 10:06:34 +08:00
parent e74161921e
commit a809277291
6 changed files with 0 additions and 359 deletions
-4
View File
@@ -1,4 +0,0 @@
.git
.gitignore
README.md
LICENSE
-113
View File
@@ -1,113 +0,0 @@
FROM endial/alpine:v3.11
LABEL \
"Version"="v1.16.1" \
"Description"="Docker image for Nginx 1.16.1 based on Alpine 3.11." \
"Dockerfile"="https://github.com/endial/docker-nginx" \
"Vendor"="Endial Fang (endial@126.com)"
ENV NGINX_VERSION 1.16.1
ENV NJS_VERSION 0.3.8
ENV PKG_RELEASE 1
RUN set -x \
&& addgroup -S -g 1001 nginx \
&& adduser -S -G nginx -D -u 1001 -H -h /var/cache/nginx -s /sbin/nologin -g nginx nginx \
&& apkArch="$(cat /etc/apk/arch)" \
&& nginxPackages=" \
nginx=${NGINX_VERSION}-r${PKG_RELEASE} \
nginx-module-xslt=${NGINX_VERSION}-r${PKG_RELEASE} \
nginx-module-geoip=${NGINX_VERSION}-r${PKG_RELEASE} \
nginx-module-image-filter=${NGINX_VERSION}-r${PKG_RELEASE} \
nginx-module-njs=${NGINX_VERSION}.${NJS_VERSION}-r${PKG_RELEASE} \
" \
&& case "$apkArch" in \
x86_64) \
set -x \
&& KEY_SHA512="e7fa8303923d9b95db37a77ad46c68fd4755ff935d0a534d26eba83de193c76166c68bfe7f65471bf8881004ef4aa6df3e34689c305662750c0172fca5d8552a *stdin" \
&& apk add --no-cache --virtual .cert-deps \
openssl \
&& wget -O /tmp/nginx_signing.rsa.pub https://nginx.org/keys/nginx_signing.rsa.pub \
&& if [ "$(openssl rsa -pubin -in /tmp/nginx_signing.rsa.pub -text -noout | openssl sha512 -r)" = "$KEY_SHA512" ]; then \
echo "key verification succeeded!"; \
mv /tmp/nginx_signing.rsa.pub /etc/apk/keys/; \
else \
echo "key verification failed!"; \
exit 1; \
fi \
&& apk del .cert-deps \
&& apk add -X "https://nginx.org/packages/alpine/v$(egrep -o '^[0-9]+\.[0-9]+' /etc/alpine-release)/main" --no-cache $nginxPackages \
;; \
*) \
set -x \
&& tempDir="$(mktemp -d)" \
&& chown nobody:nobody $tempDir \
&& apk add --no-cache --virtual .build-deps \
gcc \
libc-dev \
make \
openssl-dev \
pcre-dev \
zlib-dev \
linux-headers \
libxslt-dev \
gd-dev \
geoip-dev \
perl-dev \
libedit-dev \
mercurial \
bash \
alpine-sdk \
findutils \
&& su nobody -s /bin/sh -c " \
export HOME=${tempDir} \
&& cd ${tempDir} \
&& hg clone https://hg.nginx.org/pkg-oss \
&& cd pkg-oss \
&& hg up -r 450 \
&& cd alpine \
&& make all \
&& apk index -o ${tempDir}/packages/alpine/${apkArch}/APKINDEX.tar.gz ${tempDir}/packages/alpine/${apkArch}/*.apk \
&& abuild-sign -k ${tempDir}/.abuild/abuild-key.rsa ${tempDir}/packages/alpine/${apkArch}/APKINDEX.tar.gz \
" \
&& cp ${tempDir}/.abuild/abuild-key.rsa.pub /etc/apk/keys/ \
&& apk del .build-deps \
&& apk add -X ${tempDir}/packages/alpine/ --no-cache $nginxPackages \
;; \
esac \
&& if [ -n "$tempDir" ]; then rm -rf "$tempDir"; fi \
&& if [ -n "/etc/apk/keys/abuild-key.rsa.pub" ]; then rm -f /etc/apk/keys/abuild-key.rsa.pub; fi \
&& if [ -n "/etc/apk/keys/nginx_signing.rsa.pub" ]; then rm -f /etc/apk/keys/nginx_signing.rsa.pub; fi \
# Bring in gettext so we can get `envsubst`, then throw
# the rest away. To do this, we need to install `gettext`
# then move `envsubst` out of the way so `gettext` can
# be deleted completely, then move `envsubst` back.
&& apk add --no-cache --virtual .gettext gettext \
&& mv /usr/bin/envsubst /tmp/ \
\
&& runDeps="$( \
scanelf --needed --nobanner /tmp/envsubst \
| awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' \
| sort -u \
| xargs -r apk info --installed \
| sort -u \
)" \
&& apk add --no-cache $runDeps \
&& apk del .gettext \
&& mv /tmp/envsubst /usr/local/bin/ \
&& apk add --no-cache tzdata \
&& mkdir -p /var/log/nginx \
&& mkdir -p /etc/nginx \
&& ln -sf /dev/stdout /var/log/nginx/access.log \
&& ln -sf /dev/stderr /var/log/nginx/error.log
COPY ./nginx /etc/nginx/
VOLUME ["/srv/www", "/srv/conf", "/srv/cert", "/var/log", "/var/run"]
EXPOSE 80 443
STOPSIGNAL SIGTERM
ENTRYPOINT ["/etc/nginx/entrypoint.sh"]
CMD ["nginx", "-g", "daemon off;", "-c", "/srv/conf/nginx/nginx.conf"]
-58
View File
@@ -1,58 +0,0 @@
# Nginx Alpine
基于的 Alpine(v3.11) 系统的 Nginx 镜像,用于提供 WEB(nginx) 服务。
## 基本信息
* 镜像地址:endial/nginx-alpine:v1.16.1
* 依赖镜像:endial/alpine:v3.11
## 数据卷
```
/srv/www # 站点源文件
/srv/conf # nginx 配置文件,配置文件存放在 nginx 子目录中
/var/log # 日志文件,nginx 日志存放在子目录 nginx 中
/var/run # 进程运行PID文件,及Socket通讯文件
```
## 使用说明
定义环境变量:
```shell
# 确定数据卷存储位置,可使用分散的目录或集中存储
export DOCKER_VOLUME_BASE=</volumes/path>
```
- 注意修改主文件路径为实际路径
### 运行容器
生成并运行一个新的容器:
```bash
docker run -d --name nginx \
-p 80:80 \
-v $DOCKER_VOLUME_BASE/srv/www:/srv/www:ro \
-v $DOCKER_VOLUME_BASE/var/log:/var/log \
-v $DOCKER_VOLUME_BASE/srv/conf:/srv/conf \
endial/nginx-alpine:v1.16.1
```
如果存在`dvc`数据容器,可以使用以下命令:
```bash
docker run -d --name nginx \
-p 80:80 \
--volumes-from dvc \
endial/nginx-alpine:v1.16.1
```
-26
View File
@@ -1,26 +0,0 @@
#!/bin/sh
# docker entrypoint script
echo "[i] Initial Container"
if [ ! -d /var/log/nginx ]; then
echo "[i] Create directory: /var/log/nginx"
mkdir -p /var/log/nginx
fi
if [ ! -d /srv/www/default ]; then
echo "[i] Create directory: /srv/www/default, copy default HTML files"
mkdir -p /srv/www/default
cp -rf /etc/nginx/default/* /srv/www/default/
fi
if [ ! -d /srv/conf/nginx ]; then
echo "[i] Create directory: /srv/conf/nginx, copy default Ningx config files"
mkdir -p /srv/conf/nginx
cp /etc/nginx/nginx.conf /srv/conf/nginx/
cp /etc/nginx/mime.types /srv/conf/nginx/
cp -rf /etc/nginx/conf.d /srv/conf/nginx/
fi
echo "[i] Start nginx with parameter: $@"
exec "$@"
-44
View File
@@ -1,44 +0,0 @@
server {
listen 80;
server_name localhost;
# charset utf-8; ## DON'T need, set in nginx.conf
access_log /var/log/nginx/default.access.log main;
location / {
root /srv/www/default;
index index.html index.htm index.php;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root /srv/www/default;
fastcgi_pass unix:/var/run/php5/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
-114
View File
@@ -1,114 +0,0 @@
# /etc/nginx/nginx.conf
#user nginx;
user root;
# Set number of worker processes automatically based on number of CPU cores.
worker_processes auto;
# Enables the use of JIT for regular expressions to speed-up their processing.
pcre_jit on;
# Configures default error logger.
error_log /var/log/nginx/error.log warn;
# Includes files with directives to load dynamic modules.
include /etc/nginx/modules/*.conf;
pid /var/run/nginx.pid;
worker_rlimit_nofile 32767;
events {
use epoll;
# The maximum number of simultaneous connections that can be opened by
# a worker process.
worker_connections 32767;
}
http {
# 如果启用Ruby支持,需要编译支持Ruby的版本,在这里配置启用对应版本的Passenger
# passenger_root /usr/local/rvm/gems/ruby-2.1.3/gems/passenger-4.0.57;
# passenger_ruby /usr/local/rvm/gems/ruby-2.1.3/wrappers/ruby;
# Includes mapping of file name extensions to MIME types of responses
# and defines the default type.
include /srv/conf/nginx/mime.types;
default_type application/octet-stream;
charset UTF-8;
# Name servers used to resolve names of upstream servers into addresses.
# It's also needed when using tcpsocket and udpsocket in Lua modules.
#resolver 208.67.222.222 208.67.220.220;
# Don't tell nginx version to clients.
server_tokens off;
# Specifies the maximum accepted body size of a client request, as
# indicated by the request header Content-Length. If the stated content
# length is greater than this size, then the client receives the HTTP
# error code 413. Set to 0 to disable.
client_max_body_size 100m;
# Timeout for keep-alive connections. Server will close connections after
# this time.
keepalive_timeout 65;
# Sendfile copies data between one FD and other from within the kernel,
# which is more efficient than read() + write().
sendfile on;
# Don't buffer data-sends (disable Nagle algorithm).
# Good for sending frequent small bursts of data in real time.
tcp_nodelay on;
# Causes nginx to attempt to send its HTTP response head in one packet,
# instead of using partial frames.
tcp_nopush on;
# Path of the file with Diffie-Hellman parameters for EDH ciphers.
#ssl_dhparam /etc/ssl/nginx/dh2048.pem;
# Specifies that our cipher suits should be preferred over client ciphers.
ssl_prefer_server_ciphers on;
# Enables a shared SSL cache with size that can hold around 8000 sessions.
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 5m;
# Enable gzipping of responses.
gzip on;
# Set the Vary HTTP header as defined in the RFC 2616.
gzip_vary on;
gzip_disable "msie6";
gzip_proxied any;
gzip_min_length 1000;
gzip_comp_level 6;
gzip_buffers 8 16k;
gzip_http_version 1.1;
# 压缩类型,添加一个类型 application/javascript,默认就已经包含text/html,所以下面就不用再写了
gzip_types text/plain text/css text/xml application/javascript application/json application/rss+xml;
# Enable checking the existence of precompressed files.
#gzip_static on;
# Specifies the main log format.
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
# Sets the path, format, and configuration for a buffered log write.
access_log /var/log/nginx/access.log main;
error_log /var/log/nginx/error.log warn;
#access_log off;
#error_log /dev/null;
# Includes virtual hosts configs.
include /srv/conf/nginx/conf.d/*.conf;
}