Skip to content

Commit df56aef

Browse files
committed
Prod docker
1 parent 676933a commit df56aef

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

Dockerfile

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
FROM node:20-alpine AS builder
2+
RUN apk add --no-cache openssl
3+
WORKDIR /usr/src/app
4+
5+
COPY package*.json ./
6+
COPY prisma ./prisma/
7+
8+
RUN npm ci
9+
10+
COPY . .
11+
RUN npx prisma generate
12+
RUN npm run build
13+
14+
FROM node:20-alpine AS runner
15+
WORKDIR /usr/src/app
16+
17+
RUN apk add --no-cache openssl && \
18+
addgroup --system --gid 1001 nodejs && \
19+
adduser --system --uid 1001 nodejs
20+
21+
COPY --from=builder --chown=nodejs:nodejs /usr/src/app/package.json ./
22+
COPY --from=builder --chown=nodejs:nodejs /usr/src/app/node_modules ./node_modules
23+
COPY --from=builder --chown=nodejs:nodejs /usr/src/app/dist ./dist
24+
COPY --from=builder --chown=nodejs:nodejs /usr/src/app/prisma ./prisma
25+
26+
USER nodejs
27+
28+
RUN npx prisma generate
29+
CMD [ "node", "dist/main.js" ]

docker-compose.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
services:
2+
backend:
3+
build:
4+
context: .
5+
dockerfile: Dockerfile
6+
ports:
7+
- "3000:3000"
8+
env_file:
9+
- .env
10+
restart: always
11+

0 commit comments

Comments
 (0)