Ngày đăng
May 5, 2024 8:12 AM
Tác giả
Opening package.json
and changing homepage property.
{
"name": "devopsvn",
"homepage": "/foo"
...
}
Opening .env
and changing REACT_APP_PUBLIC_URL with prefix path.
REACT_APP_PUBLIC_URL=/foo
Updating nginx.conf
server {
listen 80;
root /usr/share/nginx/html;
location / {
absolute_redirect off;
return 301 /foo$request_uri;
}
location /foo/ { # end with /
try_files $uri $uri/ /foo/index.html;
}
}
Change Dockerfile
FROM node:20-alpine as build
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build
FROM nginx:stable-alpine
# Update here
COPY --from=build /app/build /usr/share/nginx/html/foo
COPY nginx.conf /etc/nginx/nginx.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
Mastering your Site Reliability Engineering Skills with On-Call in Action.