30 lines
751 B
Docker
30 lines
751 B
Docker
|
|
# Use node image for the build stage
|
||
|
|
FROM node:18-alpine AS build
|
||
|
|
|
||
|
|
# Set working directory in the container to /app
|
||
|
|
WORKDIR /app
|
||
|
|
|
||
|
|
# Copy only the package.json and package-lock.json first for caching
|
||
|
|
COPY package.json package-lock.json ./
|
||
|
|
|
||
|
|
# Install dependencies (legacy peer deps is needed for react highlight, we get rid of it soon)
|
||
|
|
RUN npm install --legacy-peer-deps
|
||
|
|
|
||
|
|
# Copy the entire project (including frontend code)
|
||
|
|
COPY . .
|
||
|
|
|
||
|
|
# Build the frontend
|
||
|
|
RUN npm run build
|
||
|
|
|
||
|
|
# Use NGINX for serving the built frontend in production
|
||
|
|
FROM nginx:stable-alpine
|
||
|
|
|
||
|
|
# Copy the build output from the previous stage
|
||
|
|
COPY --from=build /app/build /usr/share/nginx/html
|
||
|
|
|
||
|
|
# Expose the frontend port
|
||
|
|
EXPOSE 3000
|
||
|
|
|
||
|
|
# Start NGINX server
|
||
|
|
CMD ["nginx", "-g", "daemon off;"]
|