-
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
1 parent
253e034
commit 3453442
Showing
4 changed files
with
178 additions
and
87 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Use a specific version tag instead of lts-alpine to ensure reproducibility | ||
FROM node:18-alpine AS builder | ||
WORKDIR /app | ||
|
||
# Install pnpm | ||
RUN apk add --no-cache curl && \ | ||
curl -fsSL https://get.pnpm.io/v6.16.js | node - add --global pnpm | ||
|
||
# Export the PATH variable where pnpm is installed | ||
ENV PATH /root/.pnpm/bin:$PATH | ||
|
||
# Files required by pnpm install | ||
COPY . . | ||
|
||
# Install dependencies | ||
RUN pnpm install --frozen-lockfile | ||
|
||
# Build the app and prune dev dependencies | ||
RUN pnpm run build | ||
RUN ls -al | ||
# Use a separate stage to minimize the final image size | ||
FROM node:18-alpine | ||
# It's a good practice to not run the application as root; use the node user instead | ||
USER node | ||
|
||
WORKDIR /app | ||
|
||
# Copy the build output and node_modules from the previous stage | ||
COPY --from=builder --chown=node:node /app/build /app | ||
COPY --from=builder --chown=node:node /app/node_modules /app/node_modules | ||
COPY --from=builder --chown=node:node /app/package.json /app/package.json | ||
|
||
# Expose the port the app runs on | ||
EXPOSE 3000 | ||
|
||
CMD ["node","./index.js"] |
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
Oops, something went wrong.