-
Notifications
You must be signed in to change notification settings - Fork 1
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
1ba0919
commit d3c49ac
Showing
1 changed file
with
1 addition
and
18 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 |
---|---|---|
@@ -1,48 +1,31 @@ | ||
# Stage 1: Base Stage | ||
FROM node:18-alpine AS base | ||
WORKDIR /app | ||
|
||
# Copy package files and install dependencies | ||
COPY package*.json ./ | ||
RUN npm ci | ||
|
||
# Copy the rest of the application files | ||
COPY . . | ||
COPY package.json /app | ||
|
||
# Stage 2: Development Stage | ||
FROM base AS development | ||
ENV NODE_ENV=development | ||
# Install development dependencies | ||
RUN npm install | ||
# Expose port if necessary | ||
EXPOSE 3000 | ||
# Start the development server | ||
CMD ["npm", "run", "dev"] | ||
|
||
# Stage 3: Test Stage | ||
FROM base AS test | ||
ENV NODE_ENV=test | ||
# Install development dependencies | ||
RUN npm install | ||
# Run tests | ||
CMD ["npm", "run", "test"] | ||
|
||
# Stage 4: Build Stage | ||
FROM base AS build | ||
ENV NODE_ENV=production | ||
# Build the application (TypeScript compilation) | ||
RUN npm run build | ||
|
||
# Stage 5: Production Stage | ||
FROM node:18-alpine AS production | ||
WORKDIR /app | ||
ENV NODE_ENV=production | ||
# Copy only necessary files from the build stage | ||
COPY --from=build /app/dist ./dist | ||
COPY package*.json ./ | ||
# Install only production dependencies | ||
RUN npm ci --only=production | ||
# Expose port if necessary | ||
EXPOSE 3000 | ||
# Start the application | ||
CMD ["npm", "run", "start"] |