-
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
31 additions
and
17 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,29 +1,44 @@ | ||
ARG NODE_VERSION=22.5.1 | ||
|
||
FROM node:${NODE_VERSION}-slim AS base | ||
# Create build stage | ||
FROM node:${NODE_VERSION}-slim AS build | ||
|
||
ARG PORT=3000 | ||
# Enable pnpm | ||
ENV PNPM_HOME="/pnpm" | ||
ENV PATH="$PNPM_HOME:$PATH" | ||
RUN corepack enable | ||
|
||
ENV NODE_ENV=production | ||
# Set the working directory inside the container | ||
WORKDIR /app | ||
|
||
# Copy package.json and pnpm-lock.yaml files to the working directory | ||
COPY ./package.json /app/ | ||
COPY ./pnpm-lock.yaml /app/ | ||
|
||
WORKDIR /src | ||
## Install dependencies | ||
RUN pnpm install --shamefully-hoist | ||
|
||
# Build | ||
FROM base AS build | ||
# Copy the rest of the application files to the working directory | ||
COPY . ./ | ||
|
||
COPY --link package.json package-lock.json ./ | ||
RUN npm install --omit=dev | ||
# Build the application | ||
RUN pnpm run build | ||
|
||
COPY --link . . | ||
# Create a new stage for the production image | ||
FROM node:${NODE_VERSION}-slim | ||
|
||
RUN npm run build | ||
RUN npm prune --production | ||
# Set the working directory inside the container | ||
WORKDIR /app | ||
|
||
# Run | ||
FROM base | ||
# Copy the output from the build stage to the working directory | ||
COPY --from=build /app/.output ./ | ||
|
||
ENV PORT=$PORT | ||
# Define environment variables | ||
ENV HOST=0.0.0.0 NODE_ENV=production | ||
ENV NODE_ENV=production | ||
|
||
COPY --from=build /src/.output /src/.output | ||
# Expose the port the application will run on | ||
EXPOSE 3000 | ||
|
||
CMD [ "node", ".output/server/index.mjs" ] | ||
# Start the application | ||
CMD ["node","/app/server/index.mjs"] |