Merge pull request #1605 from ToniShelby/patch-2

Update Dockerfile
This commit is contained in:
Davidson Gomes 2025-06-23 15:35:33 -03:00 committed by GitHub
commit 4be818a436
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,7 +1,7 @@
FROM node:20-alpine AS builder
RUN apk update && \
apk add --no-cache git ffmpeg wget curl bash openssl
apk add --no-cache git ffmpeg wget curl bash openssl dos2unix
LABEL version="2.3.0" description="Api to control whatsapp features through http requests."
LABEL maintainer="Davidson Gomes" git="https://github.com/DavidsonGomes"
@ -9,25 +9,44 @@ LABEL contact="contato@evolution-api.com"
WORKDIR /evolution
COPY ./package.json ./tsconfig.json ./
# Define variáveis de ambiente padrão para o build
ENV DOCKER_ENV=true
ENV DATABASE_PROVIDER=postgresql
ENV DATABASE_URL=postgresql://user:password@localhost:5432/evolution
RUN npm install
# Copia arquivos de configuração primeiro
COPY ./package*.json ./
COPY ./tsconfig.json ./
COPY ./tsup.config.ts ./
# Instala todas as dependências (incluindo dev para build)
RUN npm ci --silent
# Copia código fonte
COPY ./src ./src
COPY ./public ./public
COPY ./prisma ./prisma
COPY ./manager ./manager
COPY ./.env.example ./.env
COPY ./runWithProvider.js ./
COPY ./tsup.config.ts ./
# Copia scripts Docker
COPY ./Docker ./Docker
RUN chmod +x ./Docker/scripts/* && dos2unix ./Docker/scripts/*
# Cria um arquivo .env básico com as variáveis de ambiente para o build
RUN echo "DOCKER_ENV=true" > .env && \
echo "DATABASE_PROVIDER=${DATABASE_PROVIDER}" >> .env && \
echo "DATABASE_URL=${DATABASE_URL}" >> .env
# Executa o script de geração de banco - agora com variáveis definidas
RUN ./Docker/scripts/generate_database.sh
RUN npm run build
# Build do projeto
RUN npm run build:docker
# Remove devDependencies para reduzir tamanho
RUN npm prune --production
FROM node:20-alpine AS final
@ -35,6 +54,7 @@ RUN apk update && \
apk add tzdata ffmpeg bash openssl
ENV TZ=America/Sao_Paulo
ENV DOCKER_ENV=true
WORKDIR /evolution
@ -46,13 +66,13 @@ COPY --from=builder /evolution/dist ./dist
COPY --from=builder /evolution/prisma ./prisma
COPY --from=builder /evolution/manager ./manager
COPY --from=builder /evolution/public ./public
COPY --from=builder /evolution/.env ./.env
COPY --from=builder /evolution/Docker ./Docker
COPY --from=builder /evolution/runWithProvider.js ./runWithProvider.js
COPY --from=builder /evolution/tsup.config.ts ./tsup.config.ts
ENV DOCKER_ENV=true
# Cria arquivo .env vazio - as variáveis virão do Railway
RUN touch .env
EXPOSE 8080
ENTRYPOINT ["/bin/bash", "-c", ". ./Docker/scripts/deploy_database.sh && npm run start:prod" ]
ENTRYPOINT ["/bin/bash", "-c", ". ./Docker/scripts/deploy_database.sh && npm run start:prod" ]