Team Ai
Apppublic

LetsTryGPT/agent4-implementation

sourceHugging Faceupdated 11mo agoView on Hugging Face
0likes
Dockerfile.multi-stage76 linesDownload Raw Back to root
1# Stage 1: Install dependencies and build the application2FROM --platform=$BUILDPLATFORM node:18-slim AS builder3 4# Set the working directory5WORKDIR /app6 7# Install build dependencies8RUN apt-get update && apt-get install -y --no-install-recommends \9    python3 \10    make \11    g++ \12    && rm -rf /var/lib/apt/lists/*13 14# Copy package files15COPY package*.json ./16COPY tsconfig.json ./17 18# Install all dependencies including devDependencies for building19RUN npm ci --no-audit --prefer-offline20 21# Copy source code22COPY . .23 24# Build the application25RUN npm run build26 27# Stage 2: Create the production image28FROM node:18-slim29 30# Set the working directory31WORKDIR /app32 33# Install runtime dependencies34RUN apt-get update && apt-get install -y --no-install-recommends \35    curl \36    && rm -rf /var/lib/apt/lists/*37 38# Create a non-root user39RUN groupadd -r myuser && useradd -r -g myuser myuser \40    && mkdir -p /home/myuser/app \41    && chown -R myuser:myuser /home/myuser42 43# Switch to non-root user44USER myuser45 46# Set environment variables47ENV NODE_ENV=production48ENV PORT=786049ENV NPM_CONFIG_UPDATE_NOTIFIER=false50ENV NPM_CONFIG_AUDIT=false51ENV NPM_CONFIG_FUND=false52 53# Copy package files and install only production dependencies54COPY --chown=myuser:myuser package*.json ./55RUN npm ci --only=production --omit=dev --no-audit --prefer-offline56 57# Copy built files from builder58COPY --chown=myuser:myuser --from=builder /app/dist ./dist59 60# Copy other necessary files61COPY --chown=myuser:myuser .env.example .env62COPY --chown=myuser:myuser huggingface.yaml ./63 64# Create a health check endpoint65RUN echo 'const express = require("express"); const app = express(); app.get("/health", (req, res) => res.json({ status: "ok" })); app.listen(8080);' > health.js66 67# Health check68HEALTHCHECK --interval=30s --timeout=3s \69  CMD curl -f http://localhost:7860/health || exit 170 71# Expose the port the app runs on72EXPOSE 786073 74# Command to run the application75CMD ["node", "dist/index.js"]76