Skip to content

Commit

Permalink
adicionando container docker
Browse files Browse the repository at this point in the history
  • Loading branch information
fernandes-natanael committed Dec 8, 2023
1 parent 4f269e3 commit 6e0ffc5
Show file tree
Hide file tree
Showing 16 changed files with 190 additions and 16 deletions.
3 changes: 2 additions & 1 deletion .env.exemplo
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
DATABASE_URL=postgresql://<usuario-banco>:<senha>@<url-de-acesso-a-base>/<nome-da-base-de-dados>
DATABASE_URL_POSTGRES="postgresql://postgres:postgres@localhost:5432/printgo-local"
DATABASE_URL_COCKROACHDB=
8 changes: 4 additions & 4 deletions .github/workflows/migrate_database_dev.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: Prisma CI/CD Dev

on:
push:
branches:
- main
# on:
# push:
# branches:
# - main

jobs:
deploy:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/migrate_database_prod.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: Prisma CI/CD Prod

on:
push:
branches:
- main
# on:
# push:
# branches:
# - main

jobs:
deploy:
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/publish-github-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

name: Node.js Package

on:
push:
branches:
- main
release:
types: [created]
# on:
# push:
# branches:
# - main
# release:
# types: [created]

jobs:
build:
Expand Down
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,23 @@
# 2023.2-PrintGo-Prisma


## Executando container

1. Instale dependencias do projeto

```bash
npm install
```

2. Para executar o container execute o comando:

```bash
docker-compose up --build -d
```

3. Container do banco rodando execute as migrações da base de dados:

```bash
npm run migrate
```

File renamed without changes.
115 changes: 115 additions & 0 deletions cockroach-prisma/schema.prisma
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
generator client {
provider = "prisma-client-js"
binaryTargets = ["native", "debian-openssl-3.0.x"]
}

datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}

model User {
id String @id @default(cuid())
email String @unique
nome String
senha String
documento String
unidade_id String?
resetPasswordToken String?
resetPasswordExpires String?
cargos Cargo[] @default([USER])
impressoes Impressao[]
impressoras Impressora[]
@@map("users")
}

model Padrao {
id String @id @default(cuid())
tipo String
marca String
modeloImpressora String?
modelo String
numeroSerie String
versaoFirmware String
totalDigitalizacoes String
totalCopiasPB String
totalCopiasColoridas String
totalImpressoesPb String
totalImpressoesColoridas String
totalGeral String
enderecoIp String
status PadraoStatus @default(ATIVO)
tempoAtivoSistema String
impressoras Impressora[]
num String?
@@map("padroes")
}

model Impressora {
id String @id @default(cuid())
ip String @unique
numeroSerie String @unique
padrao_id String
codigoLocadora String?
locadora_id String?
contadorInstalacao Int @default(0)
dataInstalacao DateTime?
ultimoContador Int @default(0)
dataUltimoContador DateTime?
contadorRetiradas Int @default(0)
dataContadorRetirada DateTime?
unidadeId String?
status ImpressoraStatus @default(ATIVO)
impressoes Impressao[]
locadora User? @relation(fields: [locadora_id], references: [id])
padrao Padrao @relation(fields: [padrao_id], references: [id])
contadores Contador[]
@@map("impressoras")
}

model Impressao {
id String @id @default(cuid())
impressora_id String
user_id String
data_impressao DateTime @default(now())
nome_documento String
numero_paginas Int
impressora Impressora @relation(fields: [impressora_id], references: [id])
user User @relation(fields: [user_id], references: [id])
@@map("impressoes")
}

model Contador {
id String @id @default(cuid())
numeroSerie String
contadorCopiasPB String
contadorImpressoesPB String
contadorCopiasColoridas String?
contadorImpressoesColoridas String?
contadorGeral String
dataHoraEmissaoRelatorio DateTime
pdfAnexo String?
serie Impressora @relation(fields: [numeroSerie], references: [numeroSerie])
@@map("contadores")
}

enum ImpressoraStatus {
ATIVO
DESATIVADO
}

enum PadraoStatus {
ATIVO
DESATIVADO
}

enum Cargo {
USER
ADMIN
LOCADORA
}

35 changes: 35 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
version: "3"

services:
postgres:
image: postgres:alpine
container_name: schedula_location_db
ports:
- "5432:5432"
volumes:
- ./.ignore/postgres/postgres:/var/lib/postgresql/data
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=printgo-local
networks:
- printgo_network

pgadmin:
image: dpage/pgadmin4
environment:
PGADMIN_DEFAULT_EMAIL: "[email protected]"
PGADMIN_DEFAULT_PASSWORD: "printgo123!"
ports:
- "16544:80"
depends_on:
- postgres
networks:
- printgo_network


networks:
printgo_network:
driver: bridge
driver_opts:
com.docker.network.bridge.enable_icc: "true"
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"gen": "prisma generate",
"db:deploy": "prisma db pull && prisma db push && prisma migrate deploy ",
"db:migrate": "prisma migrate",
"migrate": "prisma db push --force-reset",
"postinstall": "prisma generate"
},
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ generator client {
}

datasource db {
provider = "cockroachdb"
provider = "postgresql"
url = env("DATABASE_URL")
}

Expand Down

0 comments on commit 6e0ffc5

Please sign in to comment.