Skip to content

Commit 3391b2c

Browse files
authored
Update Dockerfile
1 parent 427c994 commit 3391b2c

File tree

1 file changed

+29
-9
lines changed

1 file changed

+29
-9
lines changed

Dockerfile

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,60 @@
11
FROM node:20-alpine AS builder
22

33
RUN apk update && \
4-
apk add git ffmpeg wget curl bash openssl
4+
apk add git ffmpeg wget curl bash openssl dos2unix
55

66
LABEL version="2.2.3" description="Api to control whatsapp features through http requests."
77
LABEL maintainer="Davidson Gomes" git="https://github.com/DavidsonGomes"
88
LABEL contact="[email protected]"
99

1010
WORKDIR /evolution
1111

12-
COPY ./package.json ./tsconfig.json ./
12+
# Define variáveis de ambiente padrão para o build
13+
ENV DOCKER_ENV=true
14+
ENV DATABASE_PROVIDER=postgresql
15+
ENV DATABASE_URL=postgresql://user:password@localhost:5432/evolution
16+
17+
# Copia arquivos de configuração primeiro
18+
COPY ./package*.json ./
19+
COPY ./tsconfig.json ./
20+
COPY ./tsup.config.ts ./
1321

14-
RUN npm install
22+
# Instala todas as dependências (incluindo dev para build)
23+
RUN npm ci --silent
1524

25+
# Copia código fonte
1626
COPY ./src ./src
1727
COPY ./public ./public
1828
COPY ./prisma ./prisma
1929
COPY ./manager ./manager
20-
COPY ./.env.example ./.env
2130
COPY ./runWithProvider.js ./
22-
COPY ./tsup.config.ts ./
2331

32+
# Copia scripts Docker
2433
COPY ./Docker ./Docker
2534

2635
RUN chmod +x ./Docker/scripts/* && dos2unix ./Docker/scripts/*
2736

37+
# Cria um arquivo .env básico com as variáveis de ambiente para o build
38+
RUN echo "DOCKER_ENV=true" > .env && \
39+
echo "DATABASE_PROVIDER=${DATABASE_PROVIDER}" >> .env && \
40+
echo "DATABASE_URL=${DATABASE_URL}" >> .env
41+
42+
# Executa o script de geração de banco - agora com variáveis definidas
2843
RUN ./Docker/scripts/generate_database.sh
2944

30-
RUN npm run build
45+
# Build do projeto
46+
RUN npm run build:docker
47+
48+
# Remove devDependencies para reduzir tamanho
49+
RUN npm prune --production
3150

3251
FROM node:20-alpine AS final
3352

3453
RUN apk update && \
3554
apk add tzdata ffmpeg bash openssl
3655

3756
ENV TZ=America/Sao_Paulo
57+
ENV DOCKER_ENV=true
3858

3959
WORKDIR /evolution
4060

@@ -46,13 +66,13 @@ COPY --from=builder /evolution/dist ./dist
4666
COPY --from=builder /evolution/prisma ./prisma
4767
COPY --from=builder /evolution/manager ./manager
4868
COPY --from=builder /evolution/public ./public
49-
COPY --from=builder /evolution/.env ./.env
5069
COPY --from=builder /evolution/Docker ./Docker
5170
COPY --from=builder /evolution/runWithProvider.js ./runWithProvider.js
5271
COPY --from=builder /evolution/tsup.config.ts ./tsup.config.ts
5372

54-
ENV DOCKER_ENV=true
73+
# Cria arquivo .env vazio - as variáveis virão do Railway
74+
RUN touch .env
5575

5676
EXPOSE 8080
5777

58-
ENTRYPOINT ["/bin/bash", "-c", ". ./Docker/scripts/deploy_database.sh && npm run start:prod" ]
78+
ENTRYPOINT ["/bin/bash", "-c", ". ./Docker/scripts/deploy_database.sh && npm run start:prod" ]

0 commit comments

Comments
 (0)