質問編集履歴

1

dockefile追加

2018/10/17 08:47

投稿

hrsi_teratail
hrsi_teratail

スコア93

test CHANGED
File without changes
test CHANGED
@@ -217,3 +217,89 @@
217
217
 
218
218
 
219
219
  ```
220
+
221
+
222
+
223
+ dockefile
224
+
225
+ ```
226
+
227
+ FROM nginx:alpine
228
+
229
+
230
+
231
+ LABEL maintainer="Mahmoud Zalt <mahmoud@zalt.me>"
232
+
233
+
234
+
235
+ COPY nginx.conf /etc/nginx/
236
+
237
+
238
+
239
+ # If you're in China, or you need to change sources, will be set CHANGE_SOURCE to true in .env.
240
+
241
+
242
+
243
+ ARG CHANGE_SOURCE=false
244
+
245
+ RUN if [ ${CHANGE_SOURCE} = true ]; then \
246
+
247
+ # Change application source from dl-cdn.alpinelinux.org to aliyun source
248
+
249
+ sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/' /etc/apk/repositories \
250
+
251
+ ;fi
252
+
253
+
254
+
255
+ RUN apk update \
256
+
257
+ && apk upgrade \
258
+
259
+ && apk add --no-cache bash \
260
+
261
+ ## HTTTPS
262
+
263
+ && apk add --no-cache openssl \
264
+
265
+ ##
266
+
267
+ && adduser -D -H -u 1000 -s /bin/bash www-data
268
+
269
+
270
+
271
+ ARG PHP_UPSTREAM_CONTAINER=php-fpm
272
+
273
+ ARG PHP_UPSTREAM_PORT=9000
274
+
275
+
276
+
277
+ # Set upstream conf and remove the default conf
278
+
279
+ RUN echo "upstream php-upstream { server ${PHP_UPSTREAM_CONTAINER}:${PHP_UPSTREAM_PORT}; }" > /etc/nginx/conf.d/upstream.conf \
280
+
281
+ && rm /etc/nginx/conf.d/default.conf
282
+
283
+
284
+
285
+ # HTTPS
286
+
287
+ RUN mkdir /etc/nginx/ssl 2> /dev/null
288
+
289
+ RUN openssl genrsa -out "/etc/nginx/ssl/localhost.key" 2048 \
290
+
291
+ && openssl req -new -key "/etc/nginx/ssl/localhost.key" -out "/etc/nginx/ssl/localhost.csr" -subj "/CN= localhost/O= localhost/C=UK" \
292
+
293
+ && openssl x509 -req -days 365 -in "/etc/nginx/ssl/localhost.csr" -signkey "/etc/nginx/ssl/localhost.key" -out "/etc/nginx/ssl/localhost.crt"
294
+
295
+ ###
296
+
297
+
298
+
299
+ CMD ["nginx"]
300
+
301
+
302
+
303
+ EXPOSE 80 443
304
+
305
+ ```