-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
81 lines (59 loc) · 1.72 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#
# 此 Dockerfile 使用了多阶段构建,同时构建了 PHP 及 NGINX 两个镜像
#
# @link https://docs.docker.com/engine/reference/builder/
# @link https://docs.docker.com/develop/develop-images/multistage-build/
#
#
# 约定,只有 git 打了 tag 才能将对应的镜像部署到生产环境
#
ARG PHP_VERSION=7.2.0-fpm-alpine
ARG NGINX_VERSION=1.15.1
#
# 安装 composer 依赖
#
FROM khs1994/php:${PHP_VERSION} as composer
COPY . /app/EXAMPLE/
RUN cd /app/EXAMPLE \
#
# 安装 composer 依赖
#
&& if [ -f composer.json ];then \
echo "Composer packages installing..."; \
composer install --no-dev; \
echo "Composer packages install success"; \
else \
echo "composer.json NOT exists"; \
fi
#
# 将 PHP 项目打入 PHP 镜像
#
FROM khs1994/php:${PHP_VERSION} as php
COPY --from=composer /app /app
CMD ["php-fpm", "-R", "-d", "variables_order='EGPCS'"]
#
# $ docker build -t khs1994/php:7.2.0-swarm-GIT_TAG-alpine --target=php .
#
# @link https://docs.docker.com/develop/develop-images/multistage-build/#stop-at-a-specific-build-stage
#
#
# 将 PHP 项目打入 NGINX 镜像
#
#
# Debian 镜像缺少网络相关工具,这里为了方便测试 LinuxKit 继续使用 Alpine 镜像
#
#
# Nginx 配置文件统一通过 configs 管理,严禁将配置文件打入镜像
#
# FROM nginx:1.15.1-alpine
FROM nginx:${NGINX_VERSION} as nginx
COPY --from=php /app /app
ADD https://raw.githubusercontent.com/khs1994-docker/lnmp-nginx-conf-demo/master/wait-for-php.sh /wait-for-php.sh
RUN rm -rf /etc/nginx/conf.d \
&& chmod +x /wait-for-php.sh
CMD ["/wait-for-php.sh"]
#
# $ docker build -t khs1994/nginx:1.15.0-swarm-GIT_TAG-alpine .
#
# @link
#