-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
82 lines (64 loc) · 2.02 KB
/
Copy pathDockerfile
File metadata and controls
82 lines (64 loc) · 2.02 KB
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
77
78
79
80
81
82
ARG NODE_VERSION=24.13.0-slim
ARG NGINXINC_IMAGE_TAG=alpine3.22
FROM node:${NODE_VERSION} AS dependencies
WORKDIR /app
COPY package.json package-lock.json* .npmrc* ./
COPY turbo.json ./
COPY apps/web/package*.json ./apps/web/
COPY packages/ui/package*.json ./packages/ui/
# Install project dependencies with frozen lockfile for reproducible builds
RUN --mount=type=cache,target=/root/.npm \
npm ci --no-audit --no-fund
FROM node:${NODE_VERSION} AS builder
WORKDIR /app
COPY --from=dependencies /app/node_modules ./node_modules
COPY . .
ENV NODE_ENV=production
RUN --mount=type=cache,target=/app/apps/web/.next/cache \
npm run build --workspace=web
FROM nginxinc/nginx-unprivileged:${NGINXINC_IMAGE_TAG} AS runner
WORKDIR /app
RUN echo 'worker_processes 1; \
pid /tmp/nginx.pid; \
events { \
worker_connections 1024; \
} \
http { \
include /etc/nginx/mime.types; \
default_type application/octet-stream; \
access_log /dev/stdout; \
error_log /dev/stderr; \
sendfile on; \
tcp_nopush on; \
tcp_nodelay on; \
keepalive_timeout 65; \
gzip on; \
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; \
gzip_min_length 256; \
server { \
listen 8080; \
server_name localhost; \
root /usr/share/nginx/html; \
index index.html; \
location / { \
try_files $uri $uri.html $uri/ =404; \
} \
location ~ ^/(.+)/$ { \
rewrite ^/(.+)/$ /$1.html break; \
} \
location ~ ^/_next/ { \
try_files $uri =404; \
expires 1y; \
add_header Cache-Control "public, immutable"; \
} \
error_page 404 /404.html; \
location = /404.html { \
internal; \
} \
} \
} \
' > /etc/nginx/nginx.conf
COPY --from=builder /app/apps/web/out /usr/share/nginx/html
USER nginx
EXPOSE 8080
CMD ["nginx", "-c", "/etc/nginx/nginx.conf", "-g", "daemon off;"]