Skip to content

Commit 0961efa

Browse files
committed
Switch to nginx:alpine for 63 MB image
1 parent 3183e62 commit 0961efa

File tree

3 files changed

+28
-9
lines changed

3 files changed

+28
-9
lines changed

Containerfile

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
1-
FROM oven/bun:1 AS base
1+
FROM oven/bun:1 AS build
22
WORKDIR /app
3-
4-
# Install dependencies
53
COPY package.json bun.lock* ./
64
RUN bun install --frozen-lockfile --production
7-
8-
# Copy source and build
95
COPY . .
106
RUN bun run build
117

12-
# Production
8+
FROM nginx:alpine
9+
COPY --from=build /app/public /usr/share/nginx/html
10+
COPY nginx.conf /etc/nginx/conf.d/default.conf
1311
EXPOSE 3000
14-
ENV NODE_ENV=production
15-
CMD ["bun", "run", "src/server.ts"]

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ API endpoints, analytics, Sentry, newsletters, about pages, or 200 MB of node_mo
3535
| Client payload | ~2 MB | ~555 KB |
3636
| Startup time | 1.2s | 36ms |
3737
| Memory (idle) | 290 MB | 26 MB |
38-
| Docker image | 6.4 GB | 275 MB |
38+
| Docker image | 6.4 GB | 63 MB |
3939
| node_modules | 1.3 GB | 83 MB |
4040

4141
## Self-hosting

nginx.conf

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
server {
2+
listen 3000;
3+
root /usr/share/nginx/html;
4+
index index.html;
5+
6+
# Security headers
7+
add_header Content-Security-Policy "default-src 'none'; script-src 'self'; style-src 'self'; img-src 'self' data:; font-src 'self'; frame-src blob:; object-src blob:; connect-src 'self'; base-uri 'self'; form-action 'none'" always;
8+
add_header X-Content-Type-Options "nosniff" always;
9+
add_header X-Frame-Options "DENY" always;
10+
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
11+
add_header Permissions-Policy "camera=(), microphone=(), geolocation=()" always;
12+
13+
# SPA fallback
14+
location / {
15+
try_files $uri $uri/ /index.html;
16+
}
17+
18+
# Cache static assets
19+
location ~* \.(js|css|ttf|woff|woff2|svg|png|jpg)$ {
20+
expires 1y;
21+
add_header Cache-Control "public, immutable";
22+
}
23+
}

0 commit comments

Comments
 (0)