fix docker and nginx file
This commit is contained in:
30
Dockerfile
30
Dockerfile
@@ -1,12 +1,18 @@
|
||||
FROM nginx:alpine
|
||||
# Move to Nginx's public folder
|
||||
WORKDIR /usr/share/nginx/html
|
||||
# 1. CRUCIAL: Remove Nginx's default "Welcome" page files completely
|
||||
RUN rm -rf ./*
|
||||
# 2. Copy your compiled static assets into the root folder.
|
||||
# NOTE: If your folder is named "dist" instead of "build", change "build/" to "dist/"
|
||||
COPY build/ .
|
||||
# 3. Copy your custom Nginx configuration (which you already have in your log)
|
||||
COPY nginx.conf /etc/nginx/nginx.conf
|
||||
EXPOSE 80
|
||||
CMD ["nginx", "-g", "daemon off;"]
|
||||
FROM node:20-alpine
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy the standalone build output
|
||||
COPY build/ ./
|
||||
|
||||
# Next.js standalone collects all needed node_modules during build,
|
||||
# so no `npm install` is necessary here.
|
||||
|
||||
# Expose the port that server.js listens on
|
||||
EXPOSE 3000
|
||||
|
||||
ENV PORT=3000
|
||||
ENV HOSTNAME="0.0.0.0"
|
||||
ENV NODE_ENV=production
|
||||
|
||||
CMD ["node", "server.js"]
|
||||
49
nginx.conf
49
nginx.conf
@@ -1,15 +1,34 @@
|
||||
events {}
|
||||
http {
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
server {
|
||||
listen 80;
|
||||
server_name localhost;
|
||||
location / {
|
||||
root /usr/share/nginx/html;
|
||||
index index.html index.htm;
|
||||
# This line forces Nginx to pass routing back to React Router
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
}
|
||||
}
|
||||
# This nginx.conf is NOT used by the Dockerfile (which runs Node.js directly).
|
||||
# It is kept here as a reference in case you add an Nginx reverse proxy layer
|
||||
# in front of the Node.js container (e.g., on the host or in Dokploy).
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
upstream nextjs {
|
||||
server 127.0.0.1:3000;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name doormile.com www.doormile.com;
|
||||
|
||||
# Proxy all requests to the Next.js standalone server
|
||||
location / {
|
||||
proxy_pass http://nextjs;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection 'upgrade';
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_cache_bypass $http_upgrade;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user