-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
9 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,32 @@ | ||
# Stage 1: Build the react app | ||
FROM node:20 AS build | ||
FROM node:20-alpine AS build | ||
|
||
WORKDIR /usr/src/app | ||
|
||
# Copy package.json and package-lock.json to install dependencies | ||
COPY package*.json ./ | ||
|
||
# Install dependencies with legacy peer deps option | ||
RUN npm install --legacy-peer-deps || true | ||
# Install dependencies | ||
# Remove --legacy-peer-deps unless absolutely necessary | ||
RUN npm ci --only=production | ||
|
||
# Copy the rest of the application source code | ||
COPY . . | ||
|
||
# Build the app (if there are build commands in the package.json) | ||
# Build the app | ||
RUN npm run build | ||
|
||
# Stage 2: Serve the built app using nginx | ||
FROM nginx:alpine | ||
|
||
# Copy custom nginx configuration | ||
COPY ../spotnet.conf /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 | ||
|
||
# Expose the port Nginx will listen to | ||
EXPOSE 80 | ||
|
||
# Use CMD instead of ENTRYPOINT for more flexibility | ||
CMD ["nginx", "-g", "daemon off;"] |