Files
telegram-shop/Dockerfile
Z User de6f82bd00 feat: add Docker deployment (Dockerfile, docker-compose, .dockerignore) and update docs
- Multi-stage Dockerfile (node:22-slim, bun build, standalone output, non-root)
- docker-compose.yml with DB volume, healthcheck, memory limits
- .dockerignore to exclude dev artifacts from build context
- docs: full deployment guide with docker compose, manual docker, env vars,
  reverse proxy configs (Caddy/Nginx), update instructions, server requirements
- docs: comparison table old (Node.js bot) vs new (Next.js admin)
2026-08-05 23:27:35 +00:00

60 lines
1.2 KiB
Docker

# --- Stage 1: Build ---
FROM node:22-slim AS builder
WORKDIR /app
# Install bun for faster installs
RUN npm install -g bun
# Install dependencies
COPY package.json bun.lock ./
RUN bun install --frozen-lockfile
# Copy source
COPY prisma ./prisma/
COPY tsconfig.json next.config.ts postcss.config.mjs tailwind.config.ts components.json ./
COPY public ./public/
COPY src ./src/
# Generate Prisma client
RUN npx prisma generate
# Build Next.js (output: standalone)
RUN npx next build
# Copy static assets into standalone
RUN cp -r .next/static .next/standalone/.next/ && \
cp -r public .next/standalone/
# --- Stage 2: Production ---
FROM node:22-slim AS runner
WORKDIR /app
ENV NODE_ENV=production
ENV PORT=3000
ENV HOSTNAME="0.0.0.0"
# Create non-root user
RUN addgroup --system --gid 1001 nodejs && \
adduser --system --uid 1001 nextjs
# Copy standalone output
COPY --from=builder /app/.next/standalone ./
# Copy static files
COPY --from=builder /app/.next/standalone/.next ./.next
# Copy Prisma schema for potential migrations
COPY --from=builder /app/prisma ./prisma/
# Create db directory
RUN mkdir -p /app/db && chown nextjs:nodejs /app/db
# Switch to non-root
USER nextjs
EXPOSE 3000
CMD ["node", "server.js"]