質問編集履歴
1
dockefile追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -107,4 +107,47 @@
|
|
107
107
|
access_log /var/log/nginx/abc_access.log;
|
108
108
|
}
|
109
109
|
|
110
|
+
```
|
111
|
+
|
112
|
+
dockefile
|
113
|
+
```
|
114
|
+
FROM nginx:alpine
|
115
|
+
|
116
|
+
LABEL maintainer="Mahmoud Zalt <mahmoud@zalt.me>"
|
117
|
+
|
118
|
+
COPY nginx.conf /etc/nginx/
|
119
|
+
|
120
|
+
# If you're in China, or you need to change sources, will be set CHANGE_SOURCE to true in .env.
|
121
|
+
|
122
|
+
ARG CHANGE_SOURCE=false
|
123
|
+
RUN if [ ${CHANGE_SOURCE} = true ]; then \
|
124
|
+
# Change application source from dl-cdn.alpinelinux.org to aliyun source
|
125
|
+
sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/' /etc/apk/repositories \
|
126
|
+
;fi
|
127
|
+
|
128
|
+
RUN apk update \
|
129
|
+
&& apk upgrade \
|
130
|
+
&& apk add --no-cache bash \
|
131
|
+
## HTTTPS
|
132
|
+
&& apk add --no-cache openssl \
|
133
|
+
##
|
134
|
+
&& adduser -D -H -u 1000 -s /bin/bash www-data
|
135
|
+
|
136
|
+
ARG PHP_UPSTREAM_CONTAINER=php-fpm
|
137
|
+
ARG PHP_UPSTREAM_PORT=9000
|
138
|
+
|
139
|
+
# Set upstream conf and remove the default conf
|
140
|
+
RUN echo "upstream php-upstream { server ${PHP_UPSTREAM_CONTAINER}:${PHP_UPSTREAM_PORT}; }" > /etc/nginx/conf.d/upstream.conf \
|
141
|
+
&& rm /etc/nginx/conf.d/default.conf
|
142
|
+
|
143
|
+
# HTTPS
|
144
|
+
RUN mkdir /etc/nginx/ssl 2> /dev/null
|
145
|
+
RUN openssl genrsa -out "/etc/nginx/ssl/localhost.key" 2048 \
|
146
|
+
&& openssl req -new -key "/etc/nginx/ssl/localhost.key" -out "/etc/nginx/ssl/localhost.csr" -subj "/CN= localhost/O= localhost/C=UK" \
|
147
|
+
&& openssl x509 -req -days 365 -in "/etc/nginx/ssl/localhost.csr" -signkey "/etc/nginx/ssl/localhost.key" -out "/etc/nginx/ssl/localhost.crt"
|
148
|
+
###
|
149
|
+
|
150
|
+
CMD ["nginx"]
|
151
|
+
|
152
|
+
EXPOSE 80 443
|
110
153
|
```
|