forked from wetfish/wiki
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.nginx
93 lines (77 loc) · 2.29 KB
/
Dockerfile.nginx
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
82
83
84
85
86
87
88
89
90
91
92
93
# Note: This comment was in the previous dockerfile
# Note: Not 100% sure why
#
# Small note, make sure to create upload/thumbs prior to running this!
#
# builder container
FROM docker.io/debian:bookworm-slim AS builder
# install some packages
RUN set -exu \
&& DEBIAN_FRONTEND=noninteractive apt-get -yq update \
&& DEBIAN_FRONTEND=noninteractive apt-get -yq install \
libjpeg-dev \
libpng-dev \
libfreetype6-dev \
software-properties-common \
ca-certificates \
lsb-release \
apt-transport-https \
curl
# setup nodejs repo
RUN set -exu \
&& curl -fsSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | gpg --dearmor | apt-key add - \
&& echo "deb https://deb.nodesource.com/node_14.x bookworm main" | tee /etc/apt/sources.list.d/nodesource.list
# setup php8.0 repo
RUN set -exu \
&& echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list \
&& curl -fsSL https://packages.sury.org/php/apt.gpg | apt-key add -
# install php8.0, some extensions, and nodejs
RUN set -exu \
&& DEBIAN_FRONTEND=noninteractive apt-get -yq update \
&& DEBIAN_FRONTEND=noninteractive apt-get -yq install \
php8.0 \
php8.0-fpm \
php8.0-mysqli \
php8.0-mysql \
php8.0-exif \
php8.0-gd \
nodejs \
npm
# clean apt caches
RUN set -exu \
&& DEBIAN_FRONTEND=noninteractive apt-get -yq clean
# create a builder user
RUN set -exu \
&& addgroup --gid 1101 builder \
&& adduser \
--uid 1101 \
--ingroup builder \
--shell /sbin/nologin \
--disabled-password \
builder
# copy in sources
COPY ./wwwroot /var/www
# make sure our user owns the wwwroot
RUN set -exu \
&& chown -R builder:builder /var/www
# switch to our nonroot user
USER builder
# run npm install
WORKDIR /var/www/src
RUN set -exu \
&& cd /var/www/src \
&& npm install
#
# runtime container
FROM docker.io/nginx:1.22.1-alpine
USER root
# copy npm install'ed wwwroot from npm build container
COPY --from=builder /var/www /var/www
RUN set -exu \
&& chown -R nginx:nginx /var/www
# taken from nginx dockerfile here
# https://github.com/nginxinc/docker-nginx/blob/fef51235521d1cdf8b05d8cb1378a526d2abf421/stable/alpine/Dockerfile
ENTRYPOINT ["/docker-entrypoint.sh"]
EXPOSE 80
STOPSIGNAL SIGQUIT
CMD ["nginx", "-g", "daemon off;"]