Skip to content

Commit 1f5871c

Browse files
authored
Merge pull request #1 from sourcecode71/ecosystem
All are working fine
2 parents 85f0946 + 7dc43f1 commit 1f5871c

26 files changed

+476
-86
lines changed

.dockerignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
node_modules
2+
dist
3+
.git
4+
*.log
5+
.env.local
6+
.env.docker.local
7+
Dockerfile
8+
docker-compose*
9+
npm-debug.log
10+
build
11+
coverage
12+
test

docker-compose.dev.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
version: '3.8'
2+
3+
services:
4+
app:
5+
image: notifylog:dev
6+
build:
7+
context: .
8+
dockerfile: docker/dev/Dockerfile.windows
9+
volumes:
10+
- type: bind
11+
source: D:\Github_profile\SmartEduHub-Repo\NotifyLog # host path (Windows OK)
12+
target: /app # <= POSIX path
13+
consistency: cached
14+
- type: volume
15+
source: app_node_modules
16+
target: /app/node_modules
17+
ports:
18+
- "3000:3000"
19+
environment:
20+
- NODE_ENV=development
21+
- MONGO_URL=mongodb://mongo:27017/notifylog
22+
23+
mongo:
24+
image: mongo:6.0
25+
ports:
26+
- "27017:27017"
27+
volumes:
28+
- mongo_data:/data/db
29+
30+
volumes:
31+
app_node_modules:
32+
name: notifylog_app_node_modules
33+
mongo_data:

docker-compose.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
version: '3.8'
2+
3+
services:
4+
app:
5+
image: notifylog:prod
6+
build:
7+
context: .
8+
dockerfile: docker/prod/Dockerfile.windows
9+
ports:
10+
- "3000:3000"
11+
environment:
12+
- NODE_ENV=production
13+
- MONGO_URL=mongodb://mongo:27017/notifylog-prod
14+
restart: unless-stopped
15+
networks:
16+
- backend
17+
18+
mongo:
19+
image: mongo:6.0
20+
ports:
21+
- "27017:27017"
22+
volumes:
23+
- mongo_data:/data/db
24+
environment:
25+
MONGO_INITDB_ROOT_USERNAME: root
26+
MONGO_INITDB_ROOT_PASSWORD: your_secure_password
27+
MONGO_INITDB_DATABASE: notifylog-prod
28+
restart: unless-stopped
29+
networks:
30+
- backend
31+
32+
volumes:
33+
mongo_data:
34+
driver: local
35+
name: notifylog_mongo_data
36+
37+
networks:
38+
backend:
39+
driver: nat

docker/dev/Dockerfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM node:20-alpine
2+
3+
WORKDIR /usr/src/app
4+
5+
# Install dependencies
6+
COPY package*.json ./
7+
RUN npm install
8+
9+
# Install NestJS CLI globally
10+
RUN npm install -g @nestjs/cli
11+
12+
# Copy config files
13+
COPY tsconfig*.json ./
14+
COPY nest-cli.json ./
15+
16+
EXPOSE 3000 9229
17+
18+
CMD ["npm", "run", "start:dev"]

docker/dev/Dockerfile.windows

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM node:20-alpine
2+
3+
WORKDIR /app # POSIX path
4+
5+
COPY package*.json ./
6+
RUN npm install
7+
8+
COPY . .
9+
10+
CMD ["npm", "run", "start:dev"]

docker/prod/Dockerfile

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Stage 1: Build
2+
FROM node:20-alpine AS builder
3+
4+
WORKDIR /usr/src/app
5+
6+
# Install dependencies
7+
COPY package*.json ./
8+
COPY tsconfig*.json ./
9+
RUN npm ci --omit=dev
10+
11+
# Copy source
12+
COPY src ./src
13+
COPY nest-cli.json ./
14+
15+
# Build
16+
RUN npm run build
17+
18+
# Stage 2: Run
19+
FROM node:20-alpine
20+
21+
WORKDIR /usr/src/app
22+
23+
# Install production dependencies
24+
COPY package*.json ./
25+
RUN npm ci --omit=dev
26+
27+
# Copy built files
28+
COPY --from=builder /usr/src/app/dist ./dist
29+
30+
# Set timezone
31+
RUN apk add --no-cache tzdata
32+
ENV TZ=UTC
33+
34+
# Health check
35+
HEALTHCHECK --interval=30s --timeout=5s \
36+
CMD wget --spider http://localhost:3000/api/health || exit 1
37+
38+
EXPOSE 3000
39+
CMD ["node", "dist/main"]

docker/prod/Dockerfile.windows

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Stage 1: Build
2+
FROM node:18.16.0-windowsservercore AS builder
3+
WORKDIR C:/app
4+
COPY package*.json ./
5+
RUN npm ci --only=production
6+
COPY . .
7+
RUN npm run build
8+
9+
# Stage 2: Run
10+
FROM node:18.16.0-windowsservercore
11+
WORKDIR C:/app
12+
COPY --from=builder C:/app/node_modules ./node_modules
13+
COPY --from=builder C:/app/dist ./dist
14+
COPY --from=builder C:/app/package*.json ./
15+
16+
EXPOSE 3000
17+
CMD ["node", "dist/main"]

ecosystem.config.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// ecosystem.config.js
2+
module.exports = {
3+
apps: [
4+
{
5+
name: 'notify-server',
6+
script: './dist/main.js',
7+
instances: 1,
8+
autorestart: true,
9+
watch: false,
10+
max_memory_restart: '200M',
11+
env: {
12+
NODE_ENV: 'production',
13+
},
14+
},
15+
],
16+
};
17+
module.exports = {
18+
apps: [
19+
{
20+
name: 'notify-server',
21+
script: './dist/main.js',
22+
instances: 1, // or "max" for all CPUs
23+
autorestart: true,
24+
watch: false, // Set true if you want hot reload in dev
25+
max_memory_restart: '200M',
26+
env: {
27+
NODE_ENV: 'production',
28+
},
29+
},
30+
],
31+
};

jest-stare/index.html

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ <h2>Snapshots</h2>
154154
&quot;unmatched&quot;: 0,
155155
&quot;updated&quot;: 0
156156
},
157-
&quot;startTime&quot;: 1748358209653,
157+
&quot;startTime&quot;: 1748763027193,
158158
&quot;success&quot;: false,
159159
&quot;testResults&quot;: [
160160
{
@@ -165,10 +165,10 @@ <h2>Snapshots</h2>
165165
&quot;numTodoTests&quot;: 0,
166166
&quot;openHandles&quot;: [],
167167
&quot;perfStats&quot;: {
168-
&quot;end&quot;: 1748358215417,
169-
&quot;runtime&quot;: 5113,
170-
&quot;slow&quot;: true,
171-
&quot;start&quot;: 1748358210304
168+
&quot;end&quot;: 1748763032488,
169+
&quot;runtime&quot;: 4644,
170+
&quot;slow&quot;: false,
171+
&quot;start&quot;: 1748763027844
172172
},
173173
&quot;skipped&quot;: false,
174174
&quot;snapshot&quot;: {
@@ -180,14 +180,14 @@ <h2>Snapshots</h2>
180180
&quot;unmatched&quot;: 0,
181181
&quot;updated&quot;: 0
182182
},
183-
&quot;testFilePath&quot;: &quot;D:\\Github_profile\\SmartEduHub-Repo\\NotifyLog\\test\\logger\\log.controller.spec.ts&quot;,
183+
&quot;testFilePath&quot;: &quot;D:\\Github_profile\\SmartEduHub-Repo\\NotifyLog\\src\\test\\logger\\log.controller.spec.ts&quot;,
184184
&quot;testResults&quot;: [
185185
{
186186
&quot;ancestorTitles&quot;: [
187187
&quot;LogController&quot;,
188188
&quot;getLogs&quot;
189189
],
190-
&quot;duration&quot;: 19,
190+
&quot;duration&quot;: 20,
191191
&quot;failureDetails&quot;: [],
192192
&quot;failureMessages&quot;: [],
193193
&quot;fullName&quot;: &quot;LogController getLogs should return logs with default pagination&quot;,
@@ -203,7 +203,7 @@ <h2>Snapshots</h2>
203203
&quot;LogController&quot;,
204204
&quot;getLogById&quot;
205205
],
206-
&quot;duration&quot;: 2,
206+
&quot;duration&quot;: 3,
207207
&quot;failureDetails&quot;: [],
208208
&quot;failureMessages&quot;: [],
209209
&quot;fullName&quot;: &quot;LogController getLogById should return a log by ID&quot;,
@@ -219,7 +219,7 @@ <h2>Snapshots</h2>
219219
&quot;LogController&quot;,
220220
&quot;getLogById&quot;
221221
],
222-
&quot;duration&quot;: 13,
222+
&quot;duration&quot;: 12,
223223
&quot;failureDetails&quot;: [],
224224
&quot;failureMessages&quot;: [],
225225
&quot;fullName&quot;: &quot;LogController getLogById should throw NotFoundException if log not found&quot;,
@@ -251,7 +251,7 @@ <h2>Snapshots</h2>
251251
&quot;LogController&quot;,
252252
&quot;deleteLogById&quot;
253253
],
254-
&quot;duration&quot;: 3,
254+
&quot;duration&quot;: 2,
255255
&quot;failureDetails&quot;: [],
256256
&quot;failureMessages&quot;: [],
257257
&quot;fullName&quot;: &quot;LogController deleteLogById should throw NotFoundException if log not found&quot;,
@@ -267,7 +267,7 @@ <h2>Snapshots</h2>
267267
&quot;LogController&quot;,
268268
&quot;getLogStats&quot;
269269
],
270-
&quot;duration&quot;: 4,
270+
&quot;duration&quot;: 1,
271271
&quot;failureDetails&quot;: [],
272272
&quot;failureMessages&quot;: [],
273273
&quot;fullName&quot;: &quot;LogController getLogStats should return log statistics&quot;,
@@ -283,7 +283,7 @@ <h2>Snapshots</h2>
283283
&quot;LogController&quot;,
284284
&quot;getLogStats&quot;
285285
],
286-
&quot;duration&quot;: 2,
286+
&quot;duration&quot;: 1,
287287
&quot;failureDetails&quot;: [],
288288
&quot;failureMessages&quot;: [],
289289
&quot;fullName&quot;: &quot;LogController getLogStats should return stats without filters&quot;,
@@ -305,10 +305,10 @@ <h2>Snapshots</h2>
305305
&quot;numTodoTests&quot;: 0,
306306
&quot;openHandles&quot;: [],
307307
&quot;perfStats&quot;: {
308-
&quot;end&quot;: 1748358215656,
309-
&quot;runtime&quot;: 5359,
310-
&quot;slow&quot;: true,
311-
&quot;start&quot;: 1748358210297
308+
&quot;end&quot;: 1748763032803,
309+
&quot;runtime&quot;: 4959,
310+
&quot;slow&quot;: false,
311+
&quot;start&quot;: 1748763027844
312312
},
313313
&quot;skipped&quot;: false,
314314
&quot;snapshot&quot;: {
@@ -320,14 +320,14 @@ <h2>Snapshots</h2>
320320
&quot;unmatched&quot;: 0,
321321
&quot;updated&quot;: 0
322322
},
323-
&quot;testFilePath&quot;: &quot;D:\\Github_profile\\SmartEduHub-Repo\\NotifyLog\\test\\notification\\notification.controller.spec.ts&quot;,
323+
&quot;testFilePath&quot;: &quot;D:\\Github_profile\\SmartEduHub-Repo\\NotifyLog\\src\\test\\notification\\notification.controller.spec.ts&quot;,
324324
&quot;testResults&quot;: [
325325
{
326326
&quot;ancestorTitles&quot;: [
327327
&quot;NotificationController&quot;,
328328
&quot;send&quot;
329329
],
330-
&quot;duration&quot;: 26,
330+
&quot;duration&quot;: 22,
331331
&quot;failureDetails&quot;: [],
332332
&quot;failureMessages&quot;: [],
333333
&quot;fullName&quot;: &quot;NotificationController send should send notification and log successfully&quot;,
@@ -343,7 +343,7 @@ <h2>Snapshots</h2>
343343
&quot;NotificationController&quot;,
344344
&quot;send&quot;
345345
],
346-
&quot;duration&quot;: 9,
346+
&quot;duration&quot;: 7,
347347
&quot;failureDetails&quot;: [],
348348
&quot;failureMessages&quot;: [],
349349
&quot;fullName&quot;: &quot;NotificationController send should throw error if strategy send fails&quot;,
@@ -450,7 +450,7 @@ <h2>Snapshots</h2>
450450
],
451451
&quot;rootDir&quot;: &quot;D:\\Github_profile\\SmartEduHub-Repo\\NotifyLog&quot;,
452452
&quot;runTestsByPath&quot;: false,
453-
&quot;seed&quot;: 283750242,
453+
&quot;seed&quot;: -1306355599,
454454
&quot;skipFilter&quot;: false,
455455
&quot;snapshotFormat&quot;: {
456456
&quot;escapeString&quot;: false,

0 commit comments

Comments
 (0)