Skip to content

Commit f38092e

Browse files
adding docker file data for deployment.
1 parent eb0cb16 commit f38092e

File tree

1 file changed

+55
-15
lines changed

1 file changed

+55
-15
lines changed

docker/Dockerfile

Lines changed: 55 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,48 @@
1+
# FROM node:18-alpine AS base
2+
3+
# # Create app directory
4+
# WORKDIR /app
5+
6+
# # Install pnpm globally
7+
# RUN npm install -g pnpm
8+
9+
# # Copy package.json first
10+
# COPY apps/api/package*.json ./apps/api/
11+
12+
# # Update swagger version in package.json
13+
# RUN sed -i 's/"@nestjs\/swagger": "[^"]*"/"@nestjs\/swagger": "^11.1.0"/g' ./apps/api/package.json
14+
15+
# # Install dependencies
16+
# WORKDIR /app/apps/api
17+
# RUN npm install --legacy-peer-deps
18+
19+
# # Install global NestJS CLI
20+
# RUN npm install -g @nestjs/cli@$(node -p "require('./package.json').devDependencies['@nestjs/cli'].replace('^', '')")
21+
22+
# # Copy source code without node_modules
23+
# COPY apps/api/src ./src
24+
# COPY apps/api/tsconfig*.json ./
25+
# COPY apps/api/nest-cli.json ./
26+
27+
# # Build the application
28+
# RUN npm run build
29+
30+
# # Production stage
31+
# FROM node:18-alpine AS production
32+
33+
# WORKDIR /app/apps/api
34+
35+
# COPY --from=base /app/apps/api/package*.json ./
36+
# COPY --from=base /app/apps/api/node_modules ./node_modules
37+
# COPY --from=base /app/apps/api/dist ./dist
38+
# RUN test -f /app/apps/api/.env && cp /app/apps/api/.env ./.env || echo "No .env file found"
39+
40+
# EXPOSE 3000
41+
42+
# CMD ["node", "dist/main.js"]
43+
44+
# FOR DEPLOYMENT!!
45+
146
FROM node:18-alpine AS base
247

348
# Create app directory
@@ -7,36 +52,31 @@ WORKDIR /app
752
RUN npm install -g pnpm
853

954
# Copy package.json first
10-
COPY apps/api/package*.json ./apps/api/
11-
12-
# Update swagger version in package.json
13-
RUN sed -i 's/"@nestjs\/swagger": "[^"]*"/"@nestjs\/swagger": "^11.1.0"/g' ./apps/api/package.json
55+
COPY package*.json ./
1456

1557
# Install dependencies
16-
WORKDIR /app/apps/api
1758
RUN npm install --legacy-peer-deps
1859

1960
# Install global NestJS CLI
2061
RUN npm install -g @nestjs/cli@$(node -p "require('./package.json').devDependencies['@nestjs/cli'].replace('^', '')")
2162

22-
# Copy source code without node_modules
23-
COPY apps/api/src ./src
24-
COPY apps/api/tsconfig*.json ./
25-
COPY apps/api/nest-cli.json ./
63+
# Copy source code
64+
COPY src ./src
65+
COPY tsconfig*.json ./
66+
COPY nest-cli.json ./
2667

2768
# Build the application
2869
RUN npm run build
2970

3071
# Production stage
3172
FROM node:18-alpine AS production
3273

33-
WORKDIR /app/apps/api
74+
WORKDIR /app
3475

35-
COPY --from=base /app/apps/api/package*.json ./
36-
COPY --from=base /app/apps/api/node_modules ./node_modules
37-
COPY --from=base /app/apps/api/dist ./dist
38-
RUN test -f /app/apps/api/.env && cp /app/apps/api/.env ./.env || echo "No .env file found"
76+
COPY --from=base /app/package*.json ./
77+
COPY --from=base /app/node_modules ./node_modules
78+
COPY --from=base /app/dist ./dist
3979

4080
EXPOSE 3000
4181

42-
CMD ["node", "dist/main.js"]
82+
CMD ["node", "dist/main.js"]

0 commit comments

Comments
 (0)