nextjs-cmd / Dockerfile
diamond-in's picture
Create Dockerfile
748342b verified
raw
history blame contribute delete
598 Bytes
# Use a base image that makes it easy to install multiple tools
FROM node:20-slim
# 1. Install Python (and pip if needed)
RUN apt-get update && apt-get install -y \
python3 \
python3-pip \
&& rm -rf /var/lib/apt/lists/*
# 2. Set working directory
WORKDIR /app
# 3. Copy dependencies first (caching)
COPY package.json package-lock.json* ./
RUN npm install
# 4. Copy the rest of the app
COPY . .
# 5. Build the Next.js app
RUN npm run build
# 6. Expose the port (HF Spaces uses 7860)
EXPOSE 7860
ENV PORT=7860
ENV HOSTNAME="0.0.0.0"
# 7. Run the Next.js server
CMD ["npm", "start"]