Skip to content

Commit 68ac954

Browse files
committed
fix: Dockerfile for all services
1 parent 8a9d480 commit 68ac954

File tree

16 files changed

+208
-165
lines changed

16 files changed

+208
-165
lines changed

server/auth-service/Dockerfile

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,10 @@
1-
# FROM node:21-alpine3.18 as builder
2-
3-
# WORKDIR /app
4-
# COPY package.json ./
5-
# COPY tsconfig.json ./
6-
# COPY src ./src
7-
# COPY tools ./tools
8-
# RUN npm install -g npm@latest
9-
# RUN npm run ci && npm install -g nodemon
10-
11-
12-
# FROM node:21-alpine3.18
13-
14-
# WORKDIR /app
15-
# RUN apk add --no-cache curl
16-
# COPY package.json ./
17-
# COPY tsconfig.json ./
18-
# COPY src ./src
19-
# RUN npm install -g pm2 npm@latest
20-
# RUN npm ci --production
21-
# COPY --from=builder /app/build ./build
22-
23-
# EXPOSE 4002
24-
25-
# CMD ["npm", "run", "dev"]
261
# Stage 1: Build the application
272
FROM node:20-alpine AS builder
283

294
WORKDIR /usr/src/app
305

316
# Copy package files first for better caching
327
COPY package*.json ./
33-
COPY yarn.lock* ./
348

359
# Install dependencies (including devDependencies for building)
3610
RUN npm install
@@ -50,17 +24,12 @@ WORKDIR /usr/src/app
5024
COPY package*.json ./
5125
RUN npm install --only=production
5226

53-
COPY --from=builder /usr/src/app/build ./build
5427
# Copy built assets from builder stage
55-
# COPY --from=builder /usr/src/app/build ./build
56-
# COPY --from=builder /usr/src/app/node_modules ./node_modules
57-
58-
# Copy other necessary files (like config, public folder, etc.)
59-
# COPY --from=builder /usr/src/app/public ./public
60-
# COPY --from=builder /usr/src/app/server.js ./
28+
COPY --from=builder /usr/src/app/build ./build
29+
COPY --from=builder /usr/src/app/node_modules ./node_modules
6130

6231
# Expose the port your app runs on
63-
EXPOSE 4000
32+
EXPOSE 4002
6433

6534
# Command to run the server
6635
CMD ["npm", "run","start"]

server/chat-service/.eslintignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,4 +146,5 @@ Dockerfile
146146
Dockerfile.dev
147147
.dockerignore
148148
.npmrc
149-
Jenkinsfile
149+
Jenkinsfile
150+
build

server/chat-service/Dockerfile

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,35 @@
1-
FROM node:21-alpine3.18 as builder
1+
# Stage 1: Build the application
2+
FROM node:20-alpine AS builder
23

3-
WORKDIR /app
4-
COPY package.json ./
5-
COPY tsconfig.json ./
6-
COPY src ./src
7-
COPY tools ./tools
8-
RUN npm install -g npm@latest
9-
RUN npm run ci && npm install -g nodemon
4+
WORKDIR /usr/src/app
105

6+
# Copy package files first for better caching
7+
COPY package*.json ./
118

12-
FROM node:21-alpine3.18
9+
# Install dependencies (including devDependencies for building)
10+
RUN npm install
1311

14-
WORKDIR /app
15-
RUN apk add --no-cache curl
16-
COPY package.json ./
17-
COPY tsconfig.json ./
18-
COPY src ./src
19-
RUN npm install -g pm2 npm@latest
20-
RUN npm ci --production
21-
COPY --from=builder /app/build ./build
12+
# Copy all source files
13+
COPY . .
2214

15+
# Build the application (adjust this to match your build script)
16+
RUN npm run build
17+
18+
# Stage 2: Serve the application
19+
FROM node:20-alpine
20+
21+
WORKDIR /usr/src/app
22+
23+
# Install production dependencies only
24+
COPY package*.json ./
25+
RUN npm install --only=production
26+
27+
# Copy built assets from builder stage
28+
COPY --from=builder /usr/src/app/build ./build
29+
COPY --from=builder /usr/src/app/node_modules ./node_modules
30+
31+
# Expose the port your app runs on
2332
EXPOSE 4005
2433

25-
CMD ["npm", "run", "dev"]
34+
# Command to run the server
35+
CMD ["npm", "run","start"]

server/follow-service/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,4 +141,5 @@ dist
141141
# SvelteKit build / generate output
142142
.svelte-kit
143143

144-
# End of https://www.toptal.com/developers/gitignore/api/node
144+
# End of https://www.toptal.com/developers/gitignore/api/node
145+
build

server/follow-service/Dockerfile

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,34 @@
1-
FROM node:21-alpine3.18 as builder
1+
FROM node:20-alpine AS builder
22

3-
WORKDIR /app
4-
COPY package.json ./
5-
COPY tsconfig.json ./
6-
COPY src ./src
7-
COPY tools ./tools
8-
RUN npm install -g npm@latest
9-
RUN npm run ci && npm install -g nodemon
3+
WORKDIR /usr/src/app
104

5+
# Copy package files first for better caching
6+
COPY package*.json ./
117

12-
FROM node:21-alpine3.18
8+
# Install dependencies (including devDependencies for building)
9+
RUN npm install
1310

14-
WORKDIR /app
15-
RUN apk add --no-cache curl
16-
COPY package.json ./
17-
COPY tsconfig.json ./
18-
COPY src ./src
19-
RUN npm install -g pm2 npm@latest
20-
RUN npm ci --production
21-
COPY --from=builder /app/build ./build
11+
# Copy all source files
12+
COPY . .
2213

14+
# Build the application (adjust this to match your build script)
15+
RUN npm run build
16+
17+
# Stage 2: Serve the application
18+
FROM node:20-alpine
19+
20+
WORKDIR /usr/src/app
21+
22+
# Install production dependencies only
23+
COPY package*.json ./
24+
RUN npm install --only=production
25+
26+
# Copy built assets from builder stage
27+
COPY --from=builder /usr/src/app/build ./build
28+
COPY --from=builder /usr/src/app/node_modules ./node_modules
29+
30+
# Expose the port your app runs on
2331
EXPOSE 4004
2432

25-
CMD ["npm", "run", "dev"]
33+
# Command to run the server
34+
CMD ["npm", "run","start"]

server/gateway-service/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,4 +142,5 @@ dist
142142
# SvelteKit build / generate output
143143
.svelte-kit
144144

145-
# End of https://www.toptal.com/developers/gitignore/api/node
145+
# End of https://www.toptal.com/developers/gitignore/api/node
146+
build

server/gateway-service/Dockerfile

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,34 @@
1-
FROM node:21-alpine3.18 as builder
1+
FROM node:20-alpine AS builder
22

3-
WORKDIR /app
3+
WORKDIR /usr/src/app
4+
5+
# Copy package files first for better caching
46
COPY package*.json ./
5-
COPY tsconfig.json ./
6-
COPY src ./src
7-
RUN npm install -g npm@10.5.0
8-
RUN npm ci && npm run build
97

10-
FROM node:21-alpine3.18
8+
# Install dependencies (including devDependencies for building)
9+
RUN npm install
10+
11+
# Copy all source files
12+
COPY . .
13+
14+
# Build the application (adjust this to match your build script)
15+
RUN npm run build
1116

12-
WORKDIR /app
13-
RUN apk add --no-cache curl
17+
# Stage 2: Serve the application
18+
FROM node:20-alpine
19+
20+
WORKDIR /usr/src/app
21+
22+
# Install production dependencies only
1423
COPY package*.json ./
15-
COPY tsconfig.json ./
16-
RUN npm install -g pm2@latest npm@10.5.0
17-
RUN npm ci --production
18-
COPY --from=builder /app/build ./build
24+
RUN npm install --only=production
25+
26+
# Copy built assets from builder stage
27+
COPY --from=builder /usr/src/app/build ./build
28+
COPY --from=builder /usr/src/app/node_modules ./node_modules
1929

30+
# Expose the port your app runs on
2031
EXPOSE 4000
2132

22-
CMD [ "npm", "run", "start" ]
33+
# Command to run the server
34+
CMD ["npm", "run","start"]

server/notification-service/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,4 +142,5 @@ dist
142142
# SvelteKit build / generate output
143143
.svelte-kit
144144

145-
# End of https://www.toptal.com/developers/gitignore/api/node
145+
# End of https://www.toptal.com/developers/gitignore/api/node
146+
build
Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,34 @@
1-
FROM node:21-alpine3.18 as builder
1+
FROM node:20-alpine AS builder
22

3-
WORKDIR /app
4-
COPY package.json ./
5-
COPY tsconfig.json ./
6-
COPY src ./src
7-
COPY tools ./tools
8-
RUN npm install -g npm@latest
9-
RUN npm run ci && npm install -g nodemon
3+
WORKDIR /usr/src/app
104

5+
# Copy package files first for better caching
6+
COPY package*.json ./
117

12-
FROM node:21-alpine3.18
8+
# Install dependencies (including devDependencies for building)
9+
RUN npm install
1310

14-
WORKDIR /app
15-
RUN apk add --no-cache curl
16-
COPY package.json ./
17-
COPY tsconfig.json ./
18-
COPY src ./src
19-
RUN npm install -g pm2 npm@latest
20-
RUN npm ci --production
21-
COPY --from=builder /app/build ./build
11+
# Copy all source files
12+
COPY . .
2213

14+
# Build the application (adjust this to match your build script)
15+
RUN npm run build
16+
17+
# Stage 2: Serve the application
18+
FROM node:20-alpine
19+
20+
WORKDIR /usr/src/app
21+
22+
# Install production dependencies only
23+
COPY package*.json ./
24+
RUN npm install --only=production
25+
26+
# Copy built assets from builder stage
27+
COPY --from=builder /usr/src/app/build ./build
28+
COPY --from=builder /usr/src/app/node_modules ./node_modules
29+
30+
# Expose the port your app runs on
2331
EXPOSE 4001
2432

25-
CMD ["npm", "run", "dev"]
33+
# Command to run the server
34+
CMD ["npm", "run","start"]

server/post-service/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,4 +141,5 @@ dist
141141
# SvelteKit build / generate output
142142
.svelte-kit
143143

144-
# End of https://www.toptal.com/developers/gitignore/api/node
144+
# End of https://www.toptal.com/developers/gitignore/api/node
145+
build

0 commit comments

Comments
 (0)