mirror of
https://gitea.smigz.com/smiggiddy/odin-codeprojects.git
synced 2025-06-27 11:20:40 -04:00
35 lines
No EOL
715 B
Docker
35 lines
No EOL
715 B
Docker
# Use a Node.js image as the base for building the React app
|
|
FROM node:18-alpine AS builder
|
|
|
|
# Set the working directory
|
|
WORKDIR /app
|
|
|
|
# Copy package.json and package-lock.json to install dependencies
|
|
COPY package*.json ./
|
|
|
|
# Install dependencies
|
|
RUN npm install
|
|
|
|
# Copy the rest of the application code
|
|
COPY . .
|
|
|
|
# Build the React app using Vite
|
|
RUN npm run build
|
|
|
|
# Use an official Nginx image to serve the static files
|
|
FROM nginx:stable-alpine
|
|
|
|
# Set the working directory
|
|
WORKDIR /usr/share/nginx/html
|
|
|
|
# Remove default Nginx static files
|
|
RUN rm -rf ./*
|
|
|
|
# Copy the build output from the builder stage
|
|
COPY --from=builder /app/dist .
|
|
|
|
# Expose port 80
|
|
EXPOSE 80
|
|
|
|
# Start Nginx
|
|
CMD ["nginx", "-g", "daemon off;"] |