Files
vitrify-me/Dockerfile
Vladimir nett00n Budylnikov 5a890ac253
Some checks failed
Docker Build / docker (push) Failing after 1m16s
Docker Build / docker (pull_request) Failing after 1m22s
2025-09-16 17:12:14+04:00
2025-09-16 17:12:14 +04:00

71 lines
2.0 KiB
Docker

# Stage 1: Dependencies
FROM node:20-alpine AS deps
WORKDIR /app
RUN npm install -g pnpm@9.0.0
# Copy all package.json files for proper dependency resolution
COPY package.json pnpm-lock.yaml turbo.json pnpm-workspace.yaml ./
COPY apps/web/package.json ./apps/web/
COPY apps/pocketbase/package.json ./apps/pocketbase/
COPY packages/*/package.json ./packages/
# Create the directory structure that might be missing
RUN mkdir -p packages/ui packages/eslint-config packages/typescript-config
# Copy package.json files to their correct locations
COPY packages/ui/package.json ./packages/ui/
COPY packages/eslint-config/package.json ./packages/eslint-config/
COPY packages/typescript-config/package.json ./packages/typescript-config/
RUN pnpm install --frozen-lockfile
# Stage 2: Builder
FROM node:20-alpine AS builder
WORKDIR /app
RUN npm install -g pnpm@9.0.0
# Copy dependencies and source
COPY --from=deps /app/node_modules ./node_modules
COPY --from=deps /app/pnpm-lock.yaml ./
COPY . .
# Build only the web app
RUN pnpm turbo build --filter=web
# Stage 3: Runtime
FROM node:20-alpine AS runtime
WORKDIR /app
RUN npm install -g pnpm@9.0.0
# Copy package files for production install
COPY package.json pnpm-lock.yaml turbo.json ./
COPY apps/web/package.json ./apps/web/
COPY packages/*/package.json ./packages/
# Install only production dependencies
RUN pnpm install --prod --frozen-lockfile
# Copy built Next.js application
COPY --from=builder /app/apps/web/.next ./apps/web/.next
COPY --from=builder /app/apps/web/public ./apps/web/public
COPY --from=builder /app/apps/web/next.config.js ./apps/web/
COPY --from=builder /app/apps/web/package.json ./apps/web/
# Copy other necessary files
COPY --from=builder /app/apps/web/lib ./apps/web/lib
COPY --from=builder /app/apps/web/messages ./apps/web/messages
# Create non-root user
RUN addgroup -g 1001 -S nodejs && \
adduser -S nextjs -u 1001
# Change ownership of the app directory
RUN chown -R nextjs:nodejs /app
USER nextjs
EXPOSE 3000
# Use Next.js start command
CMD ["pnpm", "--filter=web", "start"]