Skip to content

Commit 552fd42

Browse files
committed
refactor: optimize Dockerfile, NGINX config, and import syntax
1 parent a02ab68 commit 552fd42

File tree

4 files changed

+34
-25
lines changed

4 files changed

+34
-25
lines changed

Dockerfile

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Stage 1: Build Stage (oven/bun:1.1.44-alpine, ARM64)
2-
FROM oven/bun@sha256:de8a253c6b7b2cbde89697a951cc9828e5dbe1c3462abc157a9605db6fbdd6d9 AS builder
2+
FROM oven/bun:1.1.44-alpine AS builder
33

44
# Set working directory and copy necessary files
55
WORKDIR /app
@@ -8,11 +8,17 @@ WORKDIR /app
88
COPY . .
99

1010
# Install Git and dependencies, then build the project
11-
RUN apk update && apk add --no-cache git && \
12-
bun install && bun run build
11+
RUN --mount=type=cache,target=/var/cache/apk \
12+
apk update && apk add --no-cache git
13+
14+
RUN --mount=type=cache,target=/root/.bun \
15+
--mount=type=cache,target=/root/.cache/bun \
16+
bun install
17+
18+
RUN bun run build
1319

1420
# Stage 2: NGINX Unprivileged Setup (1.27.3-alpine-slim, ARM64)
15-
FROM nginxinc/nginx-unprivileged@sha256:ad8208f59f060b5e49638b15902af1965e2e53dc76395903fecfbee3bb0b9018 AS final
21+
FROM nginxinc/nginx-unprivileged:1.27.3-alpine-slim AS final
1622

1723
# Set working directory for NGINX and copy built files from the build stage
1824
WORKDIR /usr/share/nginx/html

docs/.vitepress/config.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { fileURLToPath, URL } from 'node:url'
22
import yaml from 'vite-plugin-yaml'
33
import { defineConfig } from 'vitepress'
44
import { useSidebar, useOpenapi } from 'vitepress-openapi'
5-
import spec from '../public/openapi.json' assert { type: 'json' }
5+
import spec from '../public/openapi.json' with { type: 'json' }
66
import container from 'markdown-it-container'
77
import { getHighlighter, bundledLanguages } from 'shiki'
88
import { join, dirname } from 'node:path'

docs/api-reference/api/operations/[operation].paths.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import spec from '../../../public/openapi.json' assert { type: 'json' }
1+
import spec from '../../../public/openapi.json' with { type: 'json' }
22

33
export default {
44
async paths() {
@@ -17,4 +17,4 @@ export default {
1717
params: { operation: op }
1818
}))
1919
}
20-
}
20+
}

nginx/nginx.conf

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,42 +11,45 @@ http {
1111
include /etc/nginx/mime.types;
1212
default_type application/octet-stream;
1313

14-
# Security headers
15-
add_header X-Content-Type-Options nosniff;
16-
add_header X-Frame-Options DENY;
17-
add_header X-XSS-Protection "1; mode=block";
14+
# Basic optimizations
15+
sendfile on;
16+
tcp_nopush on;
17+
keepalive_timeout 65;
18+
client_max_body_size 1m;
1819

1920
# Disable server tokens
2021
server_tokens off;
2122

22-
# Gzip compression
23-
gzip off;
24-
gzip_types
25-
text/plain
26-
application/json
27-
application/javascript
28-
text/css
29-
text/xml
30-
application/xml
31-
application/xml+rss
32-
text/javascript;
33-
3423
# Server block
3524
server {
3625
listen 80;
3726
server_name _;
3827

28+
# # Static files handling
29+
# location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
30+
# expires 7d;
31+
# add_header Cache-Control "public, no-transform";
32+
# }
33+
3934
include /etc/nginx/conf.d/redirects.conf;
4035

41-
location / {
42-
alias /usr/share/nginx/html/docs;
36+
location /docs {
37+
root /usr/share/nginx/html;
4338
index index.html;
4439
try_files $uri $uri/ $uri.html =404;
4540
}
4641

4742
location = /favicon.ico {
4843
rewrite ^/favicon.ico$ /docs/favicon.ico;
44+
access_log off;
45+
log_not_found off;
4946
}
5047

48+
# Deny access to hidden files
49+
location ~ /\. {
50+
deny all;
51+
access_log off;
52+
log_not_found off;
53+
}
5154
}
5255
}

0 commit comments

Comments
 (0)