forked from weserv/images
-
Notifications
You must be signed in to change notification settings - Fork 0
/
alpine.Dockerfile
76 lines (68 loc) · 2.56 KB
/
alpine.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
# Based on:
# https://hg.nginx.org/pkg-oss/file/tip/alpine/Makefile
# https://github.com/nginxinc/docker-nginx/blob/master/mainline/alpine/Dockerfile
FROM alpine:3.19
LABEL maintainer="Kleis Auke Wolthuizen <[email protected]>"
ARG NGINX_VERSION=1.25.4
# Copy the contents of this repository to the container
COPY . /var/www/imagesweserv
WORKDIR /var/www/imagesweserv
# Create nginx user/group first, to be consistent throughout docker variants
RUN addgroup -g 101 -S nginx \
&& adduser -S -D -H -u 101 -h /var/cache/nginx -s /sbin/nologin -G nginx -g nginx nginx \
# Bring in build dependencies
&& apk add --no-cache --virtual .build-deps \
build-base \
cmake \
git \
openssl-dev \
pcre2-dev \
vips-dev \
# Build CMake-based project
&& cmake -S . -B _build \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_TOOLS=ON \
-DNGX_VERSION=$NGINX_VERSION \
-DCUSTOM_NGX_FLAGS="--prefix=/etc/nginx;\
--sbin-path=/usr/sbin/nginx;\
--modules-path=/usr/lib/nginx/modules;\
--conf-path=/etc/nginx/nginx.conf;\
--error-log-path=/var/log/nginx/error.log;\
--http-log-path=/var/log/nginx/access.log;\
--http-client-body-temp-path=/var/cache/nginx/client_temp;\
--http-proxy-temp-path=/var/cache/nginx/proxy_temp;\
--http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp;\
--http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp;\
--http-scgi-temp-path=/var/cache/nginx/scgi_temp;\
--pid-path=/var/run/nginx.pid;\
--lock-path=/var/run/nginx.lock;\
--user=nginx;\
--group=nginx" \
&& cmake --build _build -- -j$(nproc) \
# Remove build directory and dependencies
&& rm -rf _build \
&& apk del .build-deps \
# Bring in runtime dependencies
&& apk add --no-cache \
openssl \
pcre2 \
vips-cpp \
vips-heif \
vips-magick \
vips-poppler \
# Bring in tzdata so users could set the timezones through the environment variables
&& apk add --no-cache tzdata \
# Ensure nginx cache directory exist with the correct permissions
&& mkdir -m 700 /var/cache/nginx \
# Forward request and error logs to docker log collector
&& ln -sf /dev/stdout /var/log/nginx/weserv-access.log \
&& ln -sf /dev/stderr /var/log/nginx/weserv-error.log \
# Copy nginx configuration to the appropriate location
&& cp ngx_conf/*.conf /etc/nginx
# Set default timezone (can be overridden with -e "TZ=Continent/City")
ENV TZ=Europe/Amsterdam \
# Increase the minimum stack size to 2MB
VIPS_MIN_STACK_SIZE=2m
EXPOSE 80
STOPSIGNAL SIGQUIT
CMD ["nginx", "-g", "daemon off;"]