Newer
Older
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
# ---------------------------------------------- Build Time Arguments --------------------------------------------------
ARG NGINX_VERSION="1.21"
# ======================================================================================================================
# ======================================================================================================================
# --- NGINX ---
# ======================================================================================================================
# ======================================================================================================================
FROM nginx:${NGINX_VERSION}-alpine AS nginx
RUN rm -rf /var/www/* /etc/nginx/conf.d/* && adduser -u 1000 -D -S -G www-data www-data
COPY nginx/nginx-* /usr/local/bin/
COPY nginx/ /etc/nginx/
RUN chown -R www-data /etc/nginx/ && chmod +x /usr/local/bin/nginx-*
# The PHP-FPM Host
## Localhost is the sensible default assuming image run on a k8S Pod
ENV PHP_FPM_HOST "localhost"
ENV PHP_FPM_PORT "9000"
ENV NGINX_LOG_FORMAT "json"
# For Documentation
EXPOSE 80
# Switch User
USER www-data
# Add Healthcheck
HEALTHCHECK CMD ["nginx-healthcheck"]
# Add Entrypoint
ENTRYPOINT ["nginx-entrypoint"]
# ======================================================================================================================
# --- NGINX PROD ---
# ======================================================================================================================
FROM nginx AS web
USER root
RUN SECURITY_UPGRADES="curl"; \
apk add --no-cache --upgrade ${SECURITY_UPGRADES}
USER www-data
# Copy Public folder + Assets that's going to be served from Nginx
COPY --chown=www-data:www-data --from=app /app/public /app/public
# ======================================================================================================================
# --- NGINX DEV ---
# ======================================================================================================================
FROM nginx AS web-dev
ENV NGINX_LOG_FORMAT "combined"
COPY --chown=www-data:www-data nginx/dev/*.conf /etc/nginx/conf.d/
COPY --chown=www-data:www-data nginx/dev/certs/ /etc/nginx/certs/