Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
WalissonPires committed Jul 17, 2024
2 parents adb64cc + 6216d3b commit 48b2ae0
Show file tree
Hide file tree
Showing 7 changed files with 617 additions and 27 deletions.
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/.vscode
/.github
/.next
/logs
node_modules
34 changes: 34 additions & 0 deletions .github/workflows/deploy-coolify.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# For more details, read this: https://coolify.io/docs/github-actions
name: Build and Deploy
on:
push:
branches: ["production"]
env:
REGISTRY: registry.dev.wprm.com.br
IMAGE_NAME: "wprm-notify"

jobs:
amd64:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v3
- name: Login to private docker registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_PASS }}
- name: Build image and push to registry
uses: docker/build-push-action@v4
with:
context: .
file: Dockerfile
platforms: linux/amd64
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
- name: Deploy to Coolify
run: |
curl --request GET '${{ secrets.COOLIFY_WEBHOOK }}' --header 'Authorization: Bearer ${{ secrets.COOLIFY_TOKEN }}'
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
name: Deploy App

on:
push:
branches: [ production ]
on: workflow_dispatch
#on:
# push:
# branches: [ production ]

jobs:

Expand Down
59 changes: 59 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
FROM node:18-alpine AS base

# Install dependencies only when needed
FROM base AS deps
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
WORKDIR /app

# Install dependencies based on the preferred package manager
COPY package.json package-lock.json ./
copy prisma ./
RUN npm ci

# Rebuild the source code only when needed
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .

# Next.js collects completely anonymous telemetry data about general usage.
# Learn more here: https://nextjs.org/telemetry
# Uncomment the following line in case you want to disable telemetry during the build.
ENV NEXT_TELEMETRY_DISABLED 1

RUN npm run build

# Production image, copy all the files and run next
FROM base AS runner
WORKDIR /app

ENV NODE_ENV production
# Uncomment the following line in case you want to disable telemetry during runtime.
ENV NEXT_TELEMETRY_DISABLED 1

RUN apk --no-cache add curl

RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs

COPY --from=builder /app/public ./public

# Set the correct permission for prerender cache
RUN mkdir .next
RUN chown nextjs:nodejs .next

# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static

USER nextjs

EXPOSE 3000

ENV PORT 3000

# server.js is created by next build from the standalone output
# https://nextjs.org/docs/pages/api-reference/next-config-js/output
CMD HOSTNAME="0.0.0.0" node server.js
13 changes: 11 additions & 2 deletions README.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ LOG_LEVEL="debug"
LOG_PATH="./logs"
DATABASE_URL="postgresql://johndoe:randompassword@localhost:5432/mydb?schema=public"
DIRECT_URL="postgresql://johndoe:randompassword@localhost:5432/mydb?schema=public"
COOKIE_PRIVATE_KEY="my-cookie-private-key"
COOKIE_PRIVATE_KEY="my-cookie-private-key-0123456789"

NEXT_PUBLIC_SEND_MESSAGE_API_URL="http://localhost:3000/"
NEXT_PUBLIC_SEND_MESSAGE_API_TOKEN="Bearer ACCESS_TOKEN"
Expand Down Expand Up @@ -59,9 +59,18 @@ Triggers(id, type(yearly, semi-annual, quarterly, biomonthly, monthly, daily), m

Notifications(id, scheduledAt, sendedAt, templateMessageId, content)

## Docker

Criar umage docker:

```sh
docker build -t wprm-notify:latest .
docker run -d -p 3000:3000 -e DATABASE_URL="postgresql://postgres:masterkey@host.docker.internal:5432/wprmnotify?schema=public" -e COOKIE_PRIVATE_KEY="my-cookie-private-key-0123456789" -e NEXT_PUBLIC_SEND_MESSAGE_API_URL="http://localhost:5000/" -e SEND_MESSAGE_API_URL="http://localhost:5000/" --add-host host.docker.internal:host-gateway wprm-notify:latest
```

## To DO

- [ ] - Alterar Modelo de mensagem
- [x] - Alterar Modelo de mensagem
- [ ] - Adicionar pesquisa nos modelos de mensagem (Pesquisa por nome e conteudo)
- [ ] - Adicionar pesquisa nas notificações (Pesquisa por nome cliente)
- [ ] - Adicionar filtros nas notificações (Enviadas/Agendadas/Todas, Por grupo, Por modelo mensagem, Por Data Envio range)
Expand Down
Loading

0 comments on commit 48b2ae0

Please sign in to comment.