Update Dockerfile

This commit is contained in:
2025-12-25 10:38:12 +00:00
parent 51db445c20
commit c698deea10

View File

@@ -3,28 +3,37 @@ FROM node:22-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm i ---force
RUN npm install --force
COPY . .
RUN npm run build
FROM nginx:alpine
# Default html tozalaymiz
RUN rm -rf /usr/share/nginx/html/*
COPY --from=builder /app/.next /usr/share/nginx/html
# ❗ MUHIM: .next emas, out papka
COPY --from=builder /app/out /usr/share/nginx/html
# Default nginx configni ochiramiz
RUN rm /etc/nginx/conf.d/default.conf
RUN echo 'server { \
listen 80; \
server_name _; \
root /usr/share/nginx/html; \
index index.html; \
location / { \
try_files $uri /index.html; \
} \
error_page 404 /index.html; \
}' > /etc/nginx/conf.d/default.conf
# nginx.conf ni bevosita Dockerfile ichida yozamiz
RUN printf '%s\n' \
'server {' \
' listen 80;' \
' server_name _;' \
'' \
' root /usr/share/nginx/html;' \
' index index.html;' \
'' \
' location / {' \
' try_files $uri $uri/ /index.html;' \
' }' \
'}' \
> /etc/nginx/conf.d/default.conf
EXPOSE 80