Skip to content

Commit b692f2a

Browse files
committed
Revert "Revert "fix/docker""
This reverts commit 41a1b2d.
1 parent 41a1b2d commit b692f2a

File tree

2 files changed

+39
-27
lines changed

2 files changed

+39
-27
lines changed

Dockerfile

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,32 @@
1-
# Use the official Node.js image as the base image
2-
FROM node:18-alpine
3-
4-
# Set the working directory inside the container
1+
FROM node:18-alpine AS dependences
52
WORKDIR /app
63

7-
# Copy package.json and package-lock.json to the working directory
8-
COPY package*.json ./
4+
COPY package.json yarn.lock ./
5+
RUN yarn install --production --frozen-lockfile
6+
7+
FROM node:18-alpine AS builder
8+
WORKDIR /app
99

10-
# Install dependencies
11-
RUN npm install
10+
COPY package.json yarn.lock ./
11+
RUN yarn --frozen-lockfile
1212

13-
# Copy the rest of the application code to the working directory
1413
COPY . .
1514

16-
# Build the NestJS application
17-
RUN npm run build
15+
RUN npx prisma generate
16+
RUN NODE_OPTIONS="--max-old-space-size=4096" yarn build
17+
18+
FROM node:18-alpine AS runner
19+
WORKDIR /app
20+
21+
ARG NODE_ENV=production
22+
ENV NODE_ENV=${NODE_ENV}
23+
24+
COPY --from=dependences /app/node_modules ./node_modules
25+
COPY --from=builder /app/dist ./dist
26+
COPY entrypoint.sh prisma/* ./
27+
28+
RUN chmod +x entrypoint.sh
1829

19-
# Expose the port your NestJS application listens on
20-
EXPOSE 8080
30+
EXPOSE 8000
2131

22-
# Define the command to run your NestJS application
23-
CMD ["node", "--max-old-space-size=4096", "dist/main.js"]
32+
ENTRYPOINT [ "./entrypoint.sh" ]

docker-compose.yml

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
version: "3.8"
2-
services:
3-
dev-db:
2+
services:
3+
dev-db:
44
image: mysql:latest
55
ports:
66
- 3306:3306
@@ -11,21 +11,24 @@ services:
1111
MYSQL_DATABASE: gatewaydb
1212
networks:
1313
- mysql-network
14+
healthcheck:
15+
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
16+
interval: 10s
17+
timeout: 5s
18+
retries: 5
1419

15-
nest-app:
16-
build:
17-
context: .
18-
dockerfile: Dockerfile # Points to your Dockerfile
20+
gateway-server:
21+
image: controller_webapp_backend-nest-app
22+
container_name: gateway-server
23+
env_file:
24+
- ./production.env
1925
ports:
20-
- 8080:8080
26+
- "8080:8080"
2127
depends_on:
22-
- dev-db
23-
environment:
24-
DATABASE_URL: mysql://root:dtth2802@dev-db:3306/gatewaydb
25-
NODE_ENV: .env
28+
dev-db:
29+
condition: service_healthy
2630
networks:
2731
- mysql-network
28-
#command: ["node", "dist/main"] # Starts your NestJS app
2932

3033
networks:
3134
mysql-network:

0 commit comments

Comments
 (0)