Skip to content

Commit 88a62ff

Browse files
committed
feat: conteinerizando a API com Docker
1 parent 7fda67f commit 88a62ff

7 files changed

Lines changed: 186 additions & 478 deletions

File tree

Dockerfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM node:20.12-alpine AS build
2+
RUN apk add --no-cache python3 make g++ libc-dev musl-dev
3+
WORKDIR /build
4+
COPY prisma/ ./prisma
5+
COPY package*.json ./
6+
RUN npm install
7+
COPY . .
8+
RUN npm run build
9+
10+
FROM node:20.12-alpine AS production
11+
WORKDIR /app
12+
COPY --from=build /build/node_modules ./node_modules
13+
COPY --from=build /build/package*.json ./
14+
COPY --from=build /build/dist ./dist
15+
COPY --from=build /build/tsconfig.json ./
16+
COPY --from=build /build/prisma ./prisma
17+
EXPOSE 3000
18+
CMD ["sh", "-c", "npx prisma migrate deploy && npx prisma generate && npm run start:dev"]

docker-compose.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,25 @@ services:
77
POSTGRES_DB: ${DATABASE_NAME}
88
ports:
99
- 5432:5432
10+
networks:
11+
- my-bridge
12+
13+
backend-challenge:
14+
build:
15+
context: .
16+
dockerfile: Dockerfile
17+
ports:
18+
- 3000:3000
19+
environment:
20+
PORT: ${PORT}
21+
JWT_SECRET: ${JWT_SECRET}
22+
DATABASE_NAME: ${DATABASE_NAME}
23+
DATABASE_URL: ${DATABASE_URL}
24+
depends_on:
25+
- postgres
26+
networks:
27+
- my-bridge
28+
29+
networks:
30+
my-bridge:
31+
driver: bridge

0 commit comments

Comments
 (0)