brestok commited on
Commit
bd4972d
·
1 Parent(s): 7a7cbfb
Files changed (2) hide show
  1. .dockerignore +6 -0
  2. Dockerfile +25 -16
.dockerignore ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ node_modules
2
+ build
3
+ .git
4
+ .idea
5
+ .claude
6
+ .env*.local
Dockerfile CHANGED
@@ -1,25 +1,34 @@
1
- FROM node:22-slim
2
-
3
- RUN apt-get update && apt-get install -y --no-install-recommends libgl1 \
4
- && rm -rf /var/lib/apt/lists/*
5
 
6
  WORKDIR /app
7
- RUN chown node:node /app
8
-
9
- USER node
10
- ENV PATH="/home/node/.local/bin:$PATH"
11
 
12
- COPY --chown=node package*.json ./
13
- # Install dev deps so Nest CLI is available during build (even if NODE_ENV=production is set externally)
 
14
  RUN npm ci --include=dev
15
 
16
- COPY --chown=node . /app
 
 
 
 
17
  RUN npm run build
18
- # Trim dev dependencies for the runtime image
19
- RUN npm prune --omit=dev
20
 
21
- ENV NODE_ENV=production
22
- ENV PORT=7860
 
 
 
 
 
 
 
 
 
 
 
 
23
  EXPOSE 7860
24
 
25
- CMD ["node", "dist/main.js"]
 
1
+ # --- Build the static bundle ---
2
+ FROM node:22-slim AS build
 
 
3
 
4
  WORKDIR /app
 
 
 
 
5
 
6
+ # .npmrc must be present for `npm ci`: it enables legacy-peer-deps, without
7
+ # which react-scripts@5's stale typescript peer range blocks the install.
8
+ COPY package*.json .npmrc ./
9
  RUN npm ci --include=dev
10
 
11
+ COPY . .
12
+
13
+ # CRA inlines REACT_APP_* at build time; .env.local is not in the repo.
14
+ ARG REACT_APP_API_URL=https://brestok-vika-server.hf.space
15
+ ENV REACT_APP_API_URL=$REACT_APP_API_URL
16
  RUN npm run build
 
 
17
 
18
+ # --- Serve it (Hugging Face Spaces expects port 7860) ---
19
+ FROM nginxinc/nginx-unprivileged:1.27-alpine
20
+
21
+ COPY --from=build /app/build /usr/share/nginx/html
22
+
23
+ USER root
24
+ RUN printf '%s\n' \
25
+ 'server {' \
26
+ ' listen 7860;' \
27
+ ' root /usr/share/nginx/html;' \
28
+ ' location / { try_files $uri /index.html; }' \
29
+ '}' > /etc/nginx/conf.d/default.conf
30
+ USER 101
31
+
32
  EXPOSE 7860
33
 
34
+ CMD ["nginx", "-g", "daemon off;"]