Update Dockerfile

This commit is contained in:
shapefuture 2025-05-02 19:05:05 +04:00 committed by GitHub
parent 5cfb436b92
commit 5278a5dcc0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,41 +1,48 @@
# Dockerfile for Bolt.DIY - Revised for Render Deployment
# Use the desired Node.js version
ARG BASE=node:20.18.0
FROM ${BASE} AS base
# Set working directory
WORKDIR /app
# Install dependencies (this step is cached as long as the dependencies don't change)
# Install pnpm globally and copy dependency definitions
COPY package.json pnpm-lock.yaml ./
RUN npm install -g pnpm
#RUN npm install -g corepack@latest
# Install dependencies using pnpm (this layer is cached if lockfile doesn't change)
RUN pnpm install
#RUN corepack enable pnpm && pnpm install
RUN npm install -g pnpm && pnpm install
# Copy the rest of your app's source code
# Copy the rest of the application code
# Note: Ensure your .dockerignore file excludes node_modules and .git
COPY . .
# Expose the port the app runs on
# Expose the port the application will run on internally
EXPOSE 5173
# Production image
# --- Development Stage ---
# Defined here but NOT the final stage, so Render won't run this by default.
# Useful for local multi-stage builds if needed: docker build --target bolt-ai-development .
FROM base AS bolt-ai-development
# Add any ENV vars specifically needed only for the dev server, if any.
# The CMD starts the Vite development server.
CMD ["pnpm", "run", "dev", "--host"]
# --- End Development Stage ---
# --- Production Stage (FINAL STAGE) ---
# This is the stage Render will build and run by default.
FROM base AS bolt-ai-production
# Define environment variables with default values or let them be overridden
ARG GROQ_API_KEY
ARG HuggingFace_API_KEY
ARG OPENAI_API_KEY
ARG ANTHROPIC_API_KEY
ARG OPEN_ROUTER_API_KEY
ARG GOOGLE_GENERATIVE_AI_API_KEY
ARG OLLAMA_API_BASE_URL
ARG XAI_API_KEY
ARG TOGETHER_API_KEY
ARG TOGETHER_API_BASE_URL
ARG AWS_BEDROCK_CONFIG
ARG VITE_LOG_LEVEL=debug
ARG DEFAULT_NUM_CTX
# Define ARG variables that can be passed during build time (less relevant for Render runtime)
# ARG GROQ_API_KEY
# ... other build-time ARGs if needed ...
# Define ENV variables for runtime configuration.
# Render will set these based on render.yaml or dashboard settings.
ENV WRANGLER_SEND_METRICS=false \
# Ensure these ENV var names exactly match what Bolt.DIY expects at runtime
GROQ_API_KEY=${GROQ_API_KEY} \
HuggingFace_KEY=${HuggingFace_API_KEY} \
OPENAI_API_KEY=${OPENAI_API_KEY} \
@ -46,50 +53,29 @@ ENV WRANGLER_SEND_METRICS=false \
XAI_API_KEY=${XAI_API_KEY} \
TOGETHER_API_KEY=${TOGETHER_API_KEY} \
TOGETHER_API_BASE_URL=${TOGETHER_API_BASE_URL} \
AWS_BEDROCK_CONFIG=${AWS_BEDROCK_CONFIG} \
VITE_LOG_LEVEL=${VITE_LOG_LEVEL} \
DEFAULT_NUM_CTX=${DEFAULT_NUM_CTX}\
RUNNING_IN_DOCKER=true
MISTRAL_API_KEY=${MISTRAL_API_KEY} \
DEEPSEEK_API_KEY=${DEEPSEEK_API_KEY} \
COHERE_API_KEY=${COHERE_API_KEY} \
PERPLEXITY_API_KEY=${PERPLEXITY_API_KEY} \
AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID} \
AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY} \
AWS_REGION=${AWS_REGION} \
LMSTUDIO_BASE_URL=${LMSTUDIO_BASE_URL} \
OPENAI_LIKE_BASE_URL=${OPENAI_LIKE_BASE_URL} \
# VITE_LOG_LEVEL=info # Set a default log level for production if needed
# DEFAULT_NUM_CTX= # Set default context if needed
RUNNING_IN_DOCKER=true \
# Set NODE_ENV to production for Remix/other libraries
NODE_ENV=production
# Pre-configure wrangler to disable metrics
# Create wrangler config directory to disable metrics sending (optional but good practice)
RUN mkdir -p /root/.config/.wrangler && \
echo '{"enabled":false}' > /root/.config/.wrangler/metrics.json
# Build the production application artifacts
RUN pnpm run build
# Define the command to run the production server
# Ensure the 'dockerstart' script in package.json correctly starts the production server.
CMD [ "pnpm", "run", "dockerstart"]
# Development image
FROM base AS bolt-ai-development
# Define the same environment variables for development
ARG GROQ_API_KEY
ARG HuggingFace
ARG OPENAI_API_KEY
ARG ANTHROPIC_API_KEY
ARG OPEN_ROUTER_API_KEY
ARG GOOGLE_GENERATIVE_AI_API_KEY
ARG OLLAMA_API_BASE_URL
ARG XAI_API_KEY
ARG TOGETHER_API_KEY
ARG TOGETHER_API_BASE_URL
ARG VITE_LOG_LEVEL=debug
ARG DEFAULT_NUM_CTX
ENV GROQ_API_KEY=${GROQ_API_KEY} \
HuggingFace_API_KEY=${HuggingFace_API_KEY} \
OPENAI_API_KEY=${OPENAI_API_KEY} \
ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY} \
OPEN_ROUTER_API_KEY=${OPEN_ROUTER_API_KEY} \
GOOGLE_GENERATIVE_AI_API_KEY=${GOOGLE_GENERATIVE_AI_API_KEY} \
OLLAMA_API_BASE_URL=${OLLAMA_API_BASE_URL} \
XAI_API_KEY=${XAI_API_KEY} \
TOGETHER_API_KEY=${TOGETHER_API_KEY} \
TOGETHER_API_BASE_URL=${TOGETHER_API_BASE_URL} \
AWS_BEDROCK_CONFIG=${AWS_BEDROCK_CONFIG} \
VITE_LOG_LEVEL=${VITE_LOG_LEVEL} \
DEFAULT_NUM_CTX=${DEFAULT_NUM_CTX}\
RUNNING_IN_DOCKER=true
RUN mkdir -p ${WORKDIR}/run
CMD pnpm run dev --host
# --- End Production Stage ---