git actions v2

This commit is contained in:
Davidson Gomes 2024-06-09 14:41:02 -03:00
parent 35aa19853c
commit 71a97e047a
3 changed files with 39 additions and 11 deletions

View File

@ -30,7 +30,8 @@ CLEAN_STORE_CONTACTS=true
CLEAN_STORE_CHATS=true
DATABASE_ENABLED=false
DATABASE_PROVIDER=mongodb # postgresql, mysql, mongodb
DATABASE_PROVIDER=postgresql # postgresql, mysql
DATABASE_PROVIDER=mongodb # postgresql, mysql
DATABASE_CONNECTION_URI='mongodb://root:root@mongodb:27017/?authSource=admin&readPreference=primary&ssl=false&directConnection=true'
DATABASE_CONNECTION_CLIENT_NAME=evolution
DATABASE_SAVE_DATA_INSTANCE=true

View File

@ -1,22 +1,31 @@
FROM node:20.7.0-alpine AS builder
FROM node:20-bullseye-slim AS base
RUN apt-get update -y
RUN apt-get upgrade -y
RUN apt-get install -y git tzdata ffmpeg wget curl
RUN npm i -g npm@latest
FROM base AS builder
LABEL version="1.8.0" description="Api to control whatsapp features through http requests."
LABEL maintainer="Davidson Gomes" git="https://github.com/DavidsonGomes"
LABEL contact="contato@agenciadgcode.com"
RUN apk update && apk upgrade && \
apk add --no-cache git tzdata ffmpeg wget curl
WORKDIR /evolution
COPY ./package.json .
COPY ./package.json ./tsconfig.json ./
RUN npm install
COPY . .
RUN chmod +x ./deploy_database.sh
ENV DATABASE_CONNECTION_URI=postgres://postgres:pass@localhost/evolution
RUN npx prisma generate
RUN ./deploy_database.sh
RUN npm run build
@ -26,11 +35,13 @@ ENV TZ=America/Sao_Paulo
WORKDIR /evolution
COPY --from=builder /evolution/package.json ./package.json
COPY --from=builder /evolution/package-lock.json ./package-lock.json
RUN npm install --omit=dev
COPY --from=builder /evolution .
ENV DOCKER_ENV=true
RUN npx prisma migrate deploy
RUN npx prisma generate
CMD [ "node", "./dist/src/main.js" ]
ENTRYPOINT ["/bin/bash", "-c", ". ./scripts/run_database_operation_deploy.sh && npm run start:prod" ]

16
deploy_database.sh Normal file
View File

@ -0,0 +1,16 @@
#!/bin/bash
source ./scripts/env_functions.sh
if [ "$DOCKER_ENV" != "true" ]; then
export_env_vars
fi
if [[ "$DATABASE_PROVIDER" == "postgresql" || "$DATABASE_PROVIDER" == "mysql" ]]; then
export DATABASE_URL
echo "Database URL: $DATABASE_URL"
./node_modules/.bin/prisma generate --schema=prisma/$DATABASE_PROVIDER-schema.prisma
else
echo "Error: Database provider $DATABASE_PROVIDER invalid."
exit 1
fi