Skip to content

Commit

Permalink
chore: fix dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
DiegoPorfirio01 committed Jan 2, 2025
1 parent 1dd8a79 commit 0f75452
Showing 1 changed file with 6 additions and 21 deletions.
27 changes: 6 additions & 21 deletions apps/api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,15 @@ RUN cd apps/api && \

# Gerar Prisma Client explicitamente
RUN cd apps/api && \
pnpm prisma generate --schema=./prisma/schema.prisma
pnpm dlx prisma generate --schema=./prisma/schema.prisma

# Build após garantir que o Prisma Client foi gerado
RUN cd apps/api && \
pnpm build

# Modificar a ordem e garantir geração do Prisma
RUN cd apps/api && \
pnpm install --frozen-lockfile && \
pnpm add [email protected] && \
pnpm add @prisma/[email protected] && \
pnpm prisma generate --schema=./prisma/schema.prisma && \
pnpm build

# Imagem de produção
FROM node:20-alpine

RUN addgroup -S appgroup && adduser -S appuser -G appgroup

# Instalar OpenSSL na imagem de produção também
RUN apk add --no-cache openssl
Expand All @@ -81,21 +72,15 @@ COPY --from=builder /app/apps/api/prisma ./apps/api/prisma
# Instalar apenas as dependências de produção
RUN pnpm install --prod --frozen-lockfile

# Adicionar estas linhas antes do CMD
RUN cd /app/apps/api && \
pnpm prisma generate --schema=./prisma/schema.prisma

# Garantir que o diretório .prisma existe e tem as permissões corretas
RUN chown -R appuser:appgroup /app/apps/api/node_modules/.prisma

USER appuser

WORKDIR /app/apps/api

EXPOSE 3333

HEALTHCHECK --interval=30s --timeout=3s \
CMD wget --no-verbose --tries=1 --spider http://localhost:3333/health || exit 1
# HEALTHCHECK --interval=30s --timeout=3s \
# CMD wget --no-verbose --tries=1 --spider http://localhost:3333/health || exit 1

RUN pnpm dlx prisma generate --schema=./prisma/schema.prisma
RUN pnpm dlx prisma migrate deploy

# Comando de inicialização
CMD ["pnpm", "start"]

0 comments on commit 0f75452

Please sign in to comment.