Skip to content

Commit 913175c

Browse files
authored
Merge pull request #14 from TalissonFV/dev
Adicionado Dockerfile
2 parents 9d5386b + e1432ed commit 913175c

File tree

5 files changed

+57
-3
lines changed

5 files changed

+57
-3
lines changed

Dockerfile

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
FROM node:22-slim as builder
2+
ENV PNPM_HOME="/pnpm"
3+
ENV PATH="$PNPM_HOME:$PATH"
4+
RUN corepack enable
5+
COPY . /app
6+
WORKDIR /app
7+
8+
COPY package*.json ./
9+
COPY prisma ./prisma/
10+
11+
FROM builder AS prod-deps
12+
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile
13+
14+
FROM builder AS build
15+
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
16+
RUN pnpm run build
17+
18+
FROM builder
19+
COPY --from=prod-deps /app/node_modules /app/node_modules
20+
COPY --from=build /app/dist /app/dist
21+
COPY --from=build /app/prisma ./prisma
22+
23+
EXPOSE 3000
24+
25+
RUN apt-get update -y && apt-get install -y openssl
26+
27+
CMD [ "pnpm", "run", "start:migrate:prod" ]

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
Encurtador de URL utilizando Nest e Prisma (SQLite). Criação e Autenticação de usuario utilizando Passport.js e JWT.
55
[Documentação](http://localhost:3000/api) pode ser acessada após rodar o app
66

7+
## Utilizando Docker Compose
8+
```bash
9+
$ docker compose build
10+
$ docker compose up
11+
```
12+
713
## Instalação nest e pnpm
814

915
```bash
@@ -143,3 +149,4 @@ O campo `urlId` pode ser obtido após listar todas as URLs criadas pelo usuario.
143149
## License
144150

145151
Nest is [MIT licensed](LICENSE).
152+

compose.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
version: "3.9"
2+
3+
services:
4+
web:
5+
build:
6+
context: .
7+
environment:
8+
DATABASE_URL: file:./prisma/dev.db
9+
ports:
10+
- 3000:3000
11+
volumes:
12+
- /app/prisma
13+
- .:/app
14+
- /app/node_modules
15+
16+

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"start:dev": "nest start --watch",
1313
"start:debug": "nest start --debug --watch",
1414
"start:prod": "node dist/main",
15+
"start:migrate:prod": "prisma migrate deploy && npm run start:dev",
1516
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
1617
"test": "jest",
1718
"test:watch": "jest --watch",
@@ -78,5 +79,6 @@
7879
],
7980
"coverageDirectory": "../coverage",
8081
"testEnvironment": "node"
81-
}
82+
},
83+
"packageManager": "pnpm@9.12.1+sha512.e5a7e52a4183a02d5931057f7a0dbff9d5e9ce3161e33fa68ae392125b79282a8a8a470a51dfc8a0ed86221442eb2fb57019b0990ed24fab519bf0e1bc5ccfc4"
8284
}

prisma/schema.prisma

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
// learn more about it in the docs: https://pris.ly/d/prisma-schema
33

44
generator client {
5-
provider = "prisma-client-js"
5+
provider = "prisma-client-js"
6+
binaryTargets = ["native", "linux-musl-openssl-3.0.x"]
67
}
78

89
datasource db {
@@ -17,7 +18,7 @@ model Url {
1718
createdAt DateTime
1819
updatedAt DateTime?
1920
deletedAt DateTime?
20-
creator User? @relation(fields: [createdBy], references: [id])
21+
creator User? @relation(fields: [createdBy], references: [id])
2122
createdBy String?
2223
clickedAmount Int
2324
}
@@ -29,3 +30,4 @@ model User {
2930
createdAt DateTime
3031
Url Url[]
3132
}
33+

0 commit comments

Comments
 (0)