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 c3896b2 commit 469c9ae
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions apps/api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,38 +47,42 @@ RUN cd apps/api && \
# Imagem de produção
FROM node:20-alpine

# Create user earlier and set permissions properly
RUN addgroup -S appgroup && adduser -S appuser -G appgroup

# Instalar OpenSSL na imagem de produção também
# Install OpenSSL in production image
RUN apk add --no-cache openssl

WORKDIR /app

RUN corepack enable && corepack prepare pnpm@latest --activate

# Copiar arquivos necessários do builder
# Copy files from builder
COPY --from=builder /app/package.json ./
COPY --from=builder /app/pnpm-workspace.yaml ./
COPY --from=builder /app/pnpm-lock.yaml ./
COPY --from=builder /app/apps/api/package.json ./apps/api/
COPY --from=builder /app/apps/api/dist ./apps/api/dist
COPY --from=builder /app/packages ./packages
COPY --from=builder /app/config ./config

# Copiar node_modules e garantir que o Prisma seja instalado corretamente
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/apps/api/node_modules ./apps/api/node_modules
COPY --from=builder /app/apps/api/prisma ./apps/api/prisma

# Instalar apenas as dependências de produção
# Install production dependencies
RUN pnpm install --prod --frozen-lockfile

# Set correct permissions for the app directory
RUN chown -R appuser:appgroup /app

# Switch to appuser after setting permissions
USER appuser

WORKDIR /app/apps/api

EXPOSE 3333

# Generate Prisma client and run migrations
RUN pnpm prisma generate --schema=./prisma/schema.prisma && \
pnpm prisma migrate deploy

Expand Down

0 comments on commit 469c9ae

Please sign in to comment.