MEDICAL / Dockerfile
VIATEUR-AI's picture
Create Dockerfile
37122d8 verified
# Build stage
FROM node:20-slim AS builder
WORKDIR /app
# Copy package files
COPY package.json yarn.lock ./
# Install dependencies
RUN yarn install --frozen-lockfile
# Copy source code
COPY . .
# Build the app
RUN yarn build
# Production stage - Node.js server with caching
FROM node:20-slim
# Install required packages for HF Spaces Dev Mode
RUN apt-get update && \
apt-get install -y \
bash \
git git-lfs \
wget curl procps \
htop vim nano && \
rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy package files and install production dependencies only
COPY package.json yarn.lock ./
RUN yarn install --frozen-lockfile --production
# Copy server code
COPY server ./server
# Copy built files from builder stage
COPY --from=builder /app/dist ./dist
# Copy source for Dev Mode (so you can edit and rebuild)
COPY --from=builder /app/src ./src
COPY --from=builder /app/public ./public
COPY --from=builder /app/vite.config.js ./
COPY --from=builder /app/index.html ./
# Make /app owned by user 1000 for Dev Mode
RUN chown -R 1000:1000 /app
# Expose port
EXPOSE 7860
# Set environment
ENV NODE_ENV=production
ENV PORT=7860
# Use CMD (required by Dev Mode, not ENTRYPOINT)
CMD ["node", "server/index.js"]