init platform/launch
This commit is contained in:
parent
2c853cff68
commit
a79f40cec3
1 changed files with 38 additions and 0 deletions
38
infra/Dockerfile.react
Normal file
38
infra/Dockerfile.react
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
# Multi-stage build для React/Vue/Svelte SPA
|
||||
# Положи этот файл в корень своего проекта как "Dockerfile"
|
||||
|
||||
ARG NODE_VERSION=20
|
||||
ARG BUILD_DIR=dist
|
||||
|
||||
# ---------- 1. Build ----------
|
||||
FROM node:${NODE_VERSION}-alpine AS build
|
||||
WORKDIR /app
|
||||
|
||||
COPY package*.json ./
|
||||
RUN if [ -f package-lock.json ]; then npm ci; else npm install; fi
|
||||
|
||||
COPY . .
|
||||
RUN npm run build
|
||||
|
||||
# ---------- 2. Runtime ----------
|
||||
FROM nginx:alpine
|
||||
ARG BUILD_DIR
|
||||
|
||||
# SPA-friendly конфиг: любой неизвестный путь отдаёт index.html
|
||||
RUN printf 'server {\n\
|
||||
listen 80;\n\
|
||||
root /usr/share/nginx/html;\n\
|
||||
index index.html;\n\
|
||||
location / {\n\
|
||||
try_files $uri $uri/ /index.html;\n\
|
||||
}\n\
|
||||
location ~* \\.(?:js|css|svg|jpg|jpeg|png|gif|ico|woff2?)$ {\n\
|
||||
expires 30d;\n\
|
||||
add_header Cache-Control "public, immutable";\n\
|
||||
}\n\
|
||||
}\n' > /etc/nginx/conf.d/default.conf
|
||||
|
||||
COPY --from=build /app/${BUILD_DIR} /usr/share/nginx/html
|
||||
|
||||
EXPOSE 80
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
Loading…
Add table
Add a link
Reference in a new issue