Skip to content

Commit

Permalink
adjust nginx file
Browse files Browse the repository at this point in the history
  • Loading branch information
djeck1432 committed Oct 2, 2024
1 parent 0cc459e commit b3f2cc9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
26 changes: 10 additions & 16 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,22 @@ FROM node:20-alpine AS build

WORKDIR /usr/src/app

# Copy package.json and package-lock.json to install dependencies
COPY package*.json ./
WORKDIR /app

# Install dependencies
# Remove --legacy-peer-deps unless absolutely necessary
RUN npm ci --only=production
COPY . /app

# Copy the rest of the application source code
COPY . .
RUN yarn
#build the project for production
RUN yarn build

# Build the app
RUN npm run build

# Stage 2: Serve the built app using nginx
FROM nginx:alpine
# copy the build folder from react to the root of nginx (www)
COPY --from=build /app/build /usr/share/nginx/html

RUN rm /etc/nginx/conf.d/default.conf

# Copy the built files from the previous stage to the nginx container
COPY --from=build /usr/src/app/build /usr/share/nginx/html
COPY nginx/nginx.conf /etc/nginx/conf.d

# Expose the port Nginx will listen to
EXPOSE 80

# Use CMD instead of ENTRYPOINT for more flexibility
# start nginx
CMD ["nginx", "-g", "daemon off;"]
7 changes: 6 additions & 1 deletion spotnet.conf
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,15 @@ server {
error_log /var/log/nginx/error.log;

location / {
root /usr/share/nginx/html;
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}

location = /50x.html {
root /usr/share/nginx/html;
}

# Proxy requests to FastAPI backend API
location /api/ {
proxy_pass http://backend_app;
Expand Down

0 comments on commit b3f2cc9

Please sign in to comment.