-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
40 lines (25 loc) · 869 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
# Stage 1: Build the application using Node.js
FROM node:18-alpine AS build
# Set the working directory inside the container
WORKDIR /app
# Copy the package.json and package-lock.json to the working directory
COPY package*.json ./
# Install dependencies
RUN npm install
# Copy the rest of the application code to the working directory
COPY . .
# Build the application using Vite
RUN npm run build
# Stage 2: Serve the built application using a lightweight web server
FROM node:18-alpine AS production
# Install `serve` to serve the build directory
RUN npm install -g serve
# Set the working directory inside the container
WORKDIR /app
# Copy the build output from the previous stage
COPY --from=build /app/dist ./dist
# copy env varibales
# Expose the port that `serve` will use
EXPOSE ${PORT:-5000}
# Start the server
CMD serve -s dist -l ${PORT:-5000}