Spaces:
Sleeping
Sleeping
FROM node:18-slim | |
# Install required system dependencies | |
RUN apt-get update && apt-get install -y \ | |
build-essential \ | |
&& rm -rf /var/lib/apt/lists/* | |
ARG HF_TOKEN | |
ENV API_TOKEN=$HF_TOKEN | |
# Create app directory and set permissions | |
WORKDIR /app | |
# Create a non-root user | |
RUN addgroup --system --gid 1001 nodejs && \ | |
adduser --system --uid 1001 nextjs && \ | |
chown -R nextjs:nodejs /app | |
# Copy package files | |
COPY --chown=nextjs:nodejs package*.json ./ | |
# Install dependencies | |
RUN npm install | |
# Copy the rest of the application | |
COPY --chown=nextjs:nodejs . . | |
# Switch to non-root user | |
USER nextjs | |
# Build the Next.js application | |
RUN npm run build | |
# Expose the port the app runs on | |
EXPOSE 3001 | |
# Start the application | |
CMD ["npm", "start"] |