-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
53 lines (36 loc) · 1023 Bytes
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# Stage 1: Base Image
FROM node:18 AS base
# Set working directory
WORKDIR /app
# Copy package.json and package-lock.json for installation
COPY package*.json ./
# Install dependencies
RUN npm install
# Copy the rest of the app
COPY . .
# Stage 2: Development
FROM base AS dev
# Set environment to development
ENV NODE_ENV=development
# Expose Vite default port
EXPOSE 5173
# Start the Vite development server
CMD ["npm", "run", "dev", "--", "--host"]
# Stage 3: Production Build
FROM base AS build
# Set environment to production
ENV NODE_ENV=production
# Build the app
RUN npm run build
# Stage 4: Production - Nginx for serving static files
FROM nginx:alpine AS prod
# Set environment to production
ENV NODE_ENV=production
# Copy built files from the build stage
COPY --from=build /app/dist /usr/share/nginx/html
# Copy custom Nginx configuration, if needed (optional)
COPY nginx.conf /etc/nginx/nginx.conf
# Expose port 80 for the Nginx server
EXPOSE 80
# Start Nginx
CMD ["nginx", "-g", "daemon off;"]