feat: add Telegram album purchase bot
This commit is contained in:
+25
-42
@@ -1,60 +1,43 @@
|
||||
# Multi-stage build for Next.js application with Bun
|
||||
ARG BUN_VERSION=1.3.11
|
||||
|
||||
# Stage 1: Dependencies
|
||||
FROM oven/bun:1-alpine AS deps
|
||||
FROM oven/bun:${BUN_VERSION}-alpine AS base
|
||||
WORKDIR /app
|
||||
|
||||
# Copy package files
|
||||
COPY package.json bun.lockb* ./
|
||||
ENV NEXT_TELEMETRY_DISABLED=1
|
||||
|
||||
# Install dependencies with Bun
|
||||
FROM base AS dependencies
|
||||
|
||||
COPY package.json bun.lock ./
|
||||
RUN bun install --frozen-lockfile
|
||||
|
||||
# Stage 2: Builder
|
||||
FROM oven/bun:1-alpine AS builder
|
||||
WORKDIR /app
|
||||
FROM base AS builder
|
||||
|
||||
# Copy dependencies from deps stage
|
||||
COPY --from=deps /app/node_modules ./node_modules
|
||||
ENV NODE_ENV=production
|
||||
|
||||
COPY --from=dependencies /app/node_modules ./node_modules
|
||||
COPY . .
|
||||
|
||||
# Set environment variables for build
|
||||
ENV NEXT_TELEMETRY_DISABLED=1
|
||||
ENV NODE_ENV=production
|
||||
# package.json forces the Next.js CLI to execute with Bun.
|
||||
RUN bun run build
|
||||
|
||||
# Build the application with --bun flag to use Bun runtime
|
||||
RUN bun --bun run build
|
||||
FROM base AS runner
|
||||
|
||||
# Stage 3: Runner
|
||||
FROM oven/bun:1-alpine AS runner
|
||||
WORKDIR /app
|
||||
ENV NODE_ENV=production \
|
||||
HOSTNAME=0.0.0.0 \
|
||||
PORT=3000
|
||||
|
||||
ENV NODE_ENV=production
|
||||
ENV NEXT_TELEMETRY_DISABLED=1
|
||||
COPY --from=builder --chown=bun:bun /app/public ./public
|
||||
COPY --from=builder --chown=bun:bun /app/.next/standalone ./
|
||||
COPY --from=builder --chown=bun:bun /app/.next/static ./.next/static
|
||||
|
||||
# Create a non-root user
|
||||
RUN addgroup --system --gid 1001 nodejs
|
||||
RUN adduser --system --uid 1001 nextjs
|
||||
# bun:sqlite writes the database and WAL files here.
|
||||
RUN mkdir -p /app/data && chown -R bun:bun /app/data
|
||||
|
||||
# Copy necessary files from builder
|
||||
COPY --from=builder /app/public ./public
|
||||
COPY --from=builder /app/.next/standalone ./
|
||||
COPY --from=builder /app/.next/static ./.next/static
|
||||
USER bun
|
||||
|
||||
# Create data directory for SQLite database
|
||||
RUN mkdir -p /app/data && chown -R nextjs:nodejs /app/data
|
||||
|
||||
# Change ownership to nextjs user
|
||||
RUN chown -R nextjs:nodejs /app
|
||||
|
||||
# Switch to non-root user
|
||||
USER nextjs
|
||||
|
||||
# Expose port 3000
|
||||
EXPOSE 3000
|
||||
|
||||
ENV PORT=3000
|
||||
ENV HOSTNAME="0.0.0.0"
|
||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
|
||||
CMD bun -e "fetch('http://127.0.0.1:3000').then(response => process.exit(response.ok ? 0 : 1)).catch(() => process.exit(1))"
|
||||
|
||||
# Start the application with Bun runtime
|
||||
CMD ["bun", "--bun", "run", "server.js"]
|
||||
CMD ["bun", "server.js"]
|
||||
|
||||
Reference in New Issue
Block a user