Skip to content

Commit 5ccc81f

Browse files
committed
Refactor: Optimize Dockerfile for multi-stage builds and update docker-compose configuration
1 parent 1241623 commit 5ccc81f

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

Dockerfile

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:20-alpine
1+
FROM node:20-alpine AS builder
22

33
WORKDIR /app
44

@@ -11,6 +11,13 @@ COPY . .
1111

1212
RUN yarn build
1313

14-
EXPOSE 8000
14+
FROM node:20-alpine AS runner
1515

16-
CMD [ "yarn", "start" ]
16+
WORKDIR /app
17+
COPY --from=builder --chown=node:node /app/dist ./dist
18+
COPY --from=builder --chown=node:node /app/node_modules ./node_modules
19+
20+
ENV NODE_ENV=production
21+
USER node
22+
23+
CMD ["node", "dist/main.js"]

docker-compose.yml

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ services:
1111
volumes:
1212
- .:/app
1313
- node_modules:/app/node_modules
14-
command: yarn start
1514

1615
postgres:
1716
image: postgres

0 commit comments

Comments
 (0)