Skip to content

Commit df2f166

Browse files
authored
Extract nginx config from Dockerfile into separate file (#21)
1 parent 19a576e commit df2f166

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

Dockerfile

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,24 +24,7 @@ RUN pnpm run build
2424
# Final stage - minimal nginx
2525
FROM nginx:alpine
2626

27-
# Static site routing + caching for static assets
28-
RUN printf 'server {\n\
29-
listen 80;\n\
30-
root /usr/share/nginx/html;\n\
31-
error_page 404 /404.html;\n\
32-
location / {\n\
33-
try_files $uri $uri/ $uri.html =404;\n\
34-
}\n\
35-
location ~* \\.md$ {\n\
36-
types { text/plain md; }\n\
37-
add_header Content-Disposition "inline";\n\
38-
}\n\
39-
location ~* \\.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2)$ {\n\
40-
expires 1y;\n\
41-
add_header Cache-Control "public, immutable";\n\
42-
}\n\
43-
}' > /etc/nginx/conf.d/default.conf
44-
27+
COPY nginx.conf /etc/nginx/conf.d/default.conf
4528
COPY --from=build /app/dist /usr/share/nginx/html
4629

4730
EXPOSE 80

nginx.conf

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
server {
2+
listen 80;
3+
root /usr/share/nginx/html;
4+
error_page 404 /404.html;
5+
6+
location / {
7+
try_files $uri $uri/ $uri.html =404;
8+
}
9+
10+
location ~* \.md$ {
11+
types { text/plain md; }
12+
add_header Content-Disposition "inline";
13+
}
14+
15+
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2)$ {
16+
expires 1y;
17+
add_header Cache-Control "public, immutable";
18+
}
19+
}

0 commit comments

Comments
 (0)