-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dockerfile
68 lines (59 loc) · 2.18 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
FROM node:20.12.2-alpine3.19 as builder
WORKDIR /usr/src/app
COPY package*.json .
RUN npm install
ARG NODE_ENV=production
ENV NODE_ENV=${NODE_ENV}
ARG SITE
ENV SITE=${SITE}
COPY . ./
RUN npm run build -- --site=${SITE}
FROM nginx:1.25.4
LABEL org.opencontainers.image.authors="[email protected]"
RUN ( \
echo "server {"; \
echo " listen 80;"; \
echo " #listen [::]:80;"; \
echo " server_name localhost;"; \
echo ""; \
echo " location / {"; \
echo " root /usr/share/nginx/html;"; \
echo " index index.html index.htm;"; \
echo ""; \
echo " # Configuration from https://serversforhackers.com/c/nginx-caching"; \
echo " # cache.appcache, your document html and data"; \
echo " location ~* \.(?:manifest|appcache|html?|xml|json)$ {"; \
echo " expires -1;"; \
echo " # access_log logs/static.log; # I don't usually include a static log"; \
echo " }"; \
echo ""; \
echo " location ~* \.(?:rss|atom)$ {"; \
echo " expires 1h;"; \
echo " add_header Cache-Control \"public\";"; \
echo " }"; \
echo ""; \
echo " # Media: images, icons, video, audio, HTC"; \
echo " location ~* \.(?:jpg|jpeg|gif|png|ico|webp|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc|otf|ttf|eot|woff|woff2)$ {"; \
echo " expires 30d;"; \
echo " access_log off;"; \
echo " add_header Cache-Control \"public\";"; \
echo " }"; \
echo ""; \
echo " # CSS and Javascript"; \
echo " location ~* \.(?:css|js)$ {"; \
echo " expires 90d;"; \
echo " access_log off;"; \
echo " add_header Cache-Control \"public\";"; \
echo " }"; \
echo ""; \
echo " include /etc/nginx/location.d/*.conf;"; \
echo " }"; \
echo ""; \
echo " error_page 500 502 503 504 /50x.html;"; \
echo " location = /50x.html {"; \
echo " root /usr/share/nginx/html;"; \
echo " }"; \
echo "}"; \
) > /etc/nginx/conf.d/default.conf; \
mkdir -p /etc/nginx/location.d
COPY --from=builder /usr/src/app/dist /usr/share/nginx/html