-
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
6d6eb06
commit 999c726
Showing
3 changed files
with
47 additions
and
3 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,41 @@ | ||
# Stage 1: Build Stage | ||
FROM node:18-alpine AS build | ||
|
||
# Set the working directory in the container | ||
WORKDIR /app | ||
|
||
# Copy package.json and yarn.lock to the container | ||
COPY package.json yarn.lock ./ | ||
|
||
# Install project dependencies | ||
RUN yarn install --frozen-lockfile | ||
|
||
# Copy the rest of the application code to the container | ||
COPY . . | ||
|
||
# Build the Nest.js application | ||
RUN NODE_OPTIONS=--max-old-space-size=8192 yarn build | ||
|
||
# Stage 2: Production Stage | ||
FROM node:18-alpine AS production | ||
|
||
# Set the working directory in the container | ||
WORKDIR /app | ||
|
||
# Copy only the necessary files from the build stage | ||
COPY --from=build /app/dist ./dist | ||
COPY package.json yarn.lock ./ | ||
|
||
# Install only production dependencies | ||
RUN yarn install --frozen-lockfile --production | ||
|
||
# Expose the ports that the Nest.js app will run on | ||
EXPOSE 3000 | ||
EXPOSE 50051 | ||
|
||
# Start the Nest.js application | ||
CMD ["yarn", "start:prod"] | ||
|
||
# Healthcheck to check the application's health on port 5000 | ||
HEALTHCHECK --interval=30s --timeout=10s \ | ||
CMD curl -f http://localhost:3000/health || exit 1 |
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 |
---|---|---|
|
@@ -5,9 +5,10 @@ | |
"author": "zigBalthazar <[email protected]>", | ||
"license": "MIT", | ||
"scripts": { | ||
"build": "nest build", | ||
"build:prod": "tsc -p tsconfig.build.json", | ||
"start:dev": "ts-node src/main.ts", | ||
"start:prod": "node dist/main.js", | ||
"start:prod": "node dist/src/main.js", | ||
"new": "hygen new", | ||
"watch:dev": "ts-node-dev src/main.ts", | ||
"debug:dev": "cross-env TS_NODE_CACHE=false ts-node-dev --inspect --ignore '/^src/.*\\.spec\\.ts$/' src/main.ts", | ||
|