happy-server/Dockerfile
2025-07-12 17:57:05 -07:00

45 lines
1.1 KiB
Docker

# Stage 1: Building the application
FROM node:20 AS builder
# Install dependencies
RUN apt-get update && apt-get install -y python3 ffmpeg make g++ build-essential && rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy package.json and yarn.lock
COPY package.json yarn.lock ./
COPY ./prisma ./prisma
# Install dependencies
RUN yarn install --frozen-lockfile --ignore-engines
# Copy the rest of the application code
COPY ./tsconfig.json ./tsconfig.json
COPY ./vitest.config.ts ./vitest.config.ts
COPY ./sources ./sources
# Build the Next.js application
RUN yarn build
# Stage 2: Runtime
FROM node:20 AS runner
WORKDIR /app
# Install dependencies
RUN apt-get update && apt-get install -y python3 ffmpeg && rm -rf /var/lib/apt/lists/*
# Set environment to production
ENV NODE_ENV=production
# Copy necessary files from the builder stage
COPY --from=builder /app/tsconfig.json ./tsconfig.json
COPY --from=builder /app/package.json ./package.json
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/sources ./sources
# Expose the port the app will run on
EXPOSE 3000
# Command to run the application
CMD ["yarn", "start"]