-
Notifications
You must be signed in to change notification settings - Fork 0
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
2 changed files
with
19 additions
and
8 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
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,19 +1,30 @@ | ||
FROM node:18-alpine | ||
# Stage 1: Build the Vite app | ||
FROM node:16-alpine AS build | ||
|
||
WORKDIR /app | ||
|
||
# Copy package.json and package-lock.json | ||
COPY package*.json ./ | ||
|
||
# Install dependencies | ||
RUN npm install | ||
|
||
# Copy local code to the container | ||
COPY . . | ||
|
||
RUN sed -i 's|prettier -c . \&\& ||g' package.json | ||
# Build the app | ||
RUN npm run build | ||
|
||
RUN rm -rf node_modules build | ||
RUN npm install -g [email protected] | ||
RUN npm install | ||
# Stage 2: Serve the Vite app | ||
FROM node:16-alpine | ||
|
||
RUN npm run build | ||
WORKDIR /app | ||
|
||
# Install the 'serve' package for serving our static files | ||
RUN npm install -g serve | ||
|
||
CMD ["serve", "-l", "3001", "-n", "-s", "build"] | ||
# Copy the build output from the first stage | ||
COPY --from=build /app/dist /app/dist | ||
|
||
# Specify the command to run on container start | ||
CMD ["serve", "-s", "dist", "-l", "3001"] |