mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-16 04:02:54 -06:00
commit
4be818a436
38
Dockerfile
38
Dockerfile
@ -1,7 +1,7 @@
|
|||||||
FROM node:20-alpine AS builder
|
FROM node:20-alpine AS builder
|
||||||
|
|
||||||
RUN apk update && \
|
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 version="2.3.0" description="Api to control whatsapp features through http requests."
|
||||||
LABEL maintainer="Davidson Gomes" git="https://github.com/DavidsonGomes"
|
LABEL maintainer="Davidson Gomes" git="https://github.com/DavidsonGomes"
|
||||||
@ -9,25 +9,44 @@ LABEL contact="contato@evolution-api.com"
|
|||||||
|
|
||||||
WORKDIR /evolution
|
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 ./src ./src
|
||||||
COPY ./public ./public
|
COPY ./public ./public
|
||||||
COPY ./prisma ./prisma
|
COPY ./prisma ./prisma
|
||||||
COPY ./manager ./manager
|
COPY ./manager ./manager
|
||||||
COPY ./.env.example ./.env
|
|
||||||
COPY ./runWithProvider.js ./
|
COPY ./runWithProvider.js ./
|
||||||
COPY ./tsup.config.ts ./
|
|
||||||
|
|
||||||
|
# Copia scripts Docker
|
||||||
COPY ./Docker ./Docker
|
COPY ./Docker ./Docker
|
||||||
|
|
||||||
RUN chmod +x ./Docker/scripts/* && dos2unix ./Docker/scripts/*
|
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 ./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
|
FROM node:20-alpine AS final
|
||||||
|
|
||||||
@ -35,6 +54,7 @@ RUN apk update && \
|
|||||||
apk add tzdata ffmpeg bash openssl
|
apk add tzdata ffmpeg bash openssl
|
||||||
|
|
||||||
ENV TZ=America/Sao_Paulo
|
ENV TZ=America/Sao_Paulo
|
||||||
|
ENV DOCKER_ENV=true
|
||||||
|
|
||||||
WORKDIR /evolution
|
WORKDIR /evolution
|
||||||
|
|
||||||
@ -46,13 +66,13 @@ COPY --from=builder /evolution/dist ./dist
|
|||||||
COPY --from=builder /evolution/prisma ./prisma
|
COPY --from=builder /evolution/prisma ./prisma
|
||||||
COPY --from=builder /evolution/manager ./manager
|
COPY --from=builder /evolution/manager ./manager
|
||||||
COPY --from=builder /evolution/public ./public
|
COPY --from=builder /evolution/public ./public
|
||||||
COPY --from=builder /evolution/.env ./.env
|
|
||||||
COPY --from=builder /evolution/Docker ./Docker
|
COPY --from=builder /evolution/Docker ./Docker
|
||||||
COPY --from=builder /evolution/runWithProvider.js ./runWithProvider.js
|
COPY --from=builder /evolution/runWithProvider.js ./runWithProvider.js
|
||||||
COPY --from=builder /evolution/tsup.config.ts ./tsup.config.ts
|
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
|
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" ]
|
||||||
|
Loading…
Reference in New Issue
Block a user