mirror of
https://github.com/simstudioai/sim.git
synced 2026-09-21 13:00:04 +08:00
feat(bun): upgrade to bun, reduce docker image size by 95%, upgrade docs & ci (#371)
* migrate to bun * added envvars to drizzle * upgrade bun devcontainer feature to a valid one * added bun, docker not working * updated envvars, updated to bunder and esnext modules * fixed build, reinstated otel * feat: optimized multi-stage docker images * add coerce for boolean envvar * feat: add docker-compose configuration for local LLM services and remove legacy Dockerfile and entrypoint script * feat: add docker-compose files for local and production environments, and implement GitHub Actions for Docker image build and publish * refactor: remove unused generateStaticParams function from various API routes and maintain dynamic rendering * cleanup * upgraded bun * updated ci * fixed build --------- Co-authored-by: Aditya Tripathi <aditya@climactic.co>
This commit is contained in:
co-authored by
Aditya Tripathi
parent
e57d3f79a1
commit
717e17d02a
@@ -0,0 +1,62 @@
|
||||
# ========================================
|
||||
# Base Stage: Alpine Linux with Bun
|
||||
# ========================================
|
||||
FROM oven/bun:alpine AS base
|
||||
|
||||
# ========================================
|
||||
# Dependencies Stage: Install Dependencies
|
||||
# ========================================
|
||||
FROM base AS deps
|
||||
RUN apk add --no-cache libc6-compat
|
||||
WORKDIR /app
|
||||
|
||||
# Install turbo globally
|
||||
RUN bun install -g turbo
|
||||
|
||||
COPY package.json bun.lock ./
|
||||
RUN mkdir -p apps
|
||||
COPY apps/sim/package.json ./apps/sim/package.json
|
||||
|
||||
RUN bun install --omit dev --ignore-scripts
|
||||
|
||||
# ========================================
|
||||
# Builder Stage: Build the Application
|
||||
# ========================================
|
||||
FROM base AS builder
|
||||
WORKDIR /app
|
||||
|
||||
COPY --from=deps /app/node_modules ./node_modules
|
||||
COPY . .
|
||||
|
||||
# Installing with full context to prevent missing dependencies error
|
||||
RUN bun install --omit dev --ignore-scripts
|
||||
|
||||
# Required for standalone nextjs build
|
||||
WORKDIR /app/apps/sim
|
||||
RUN bun install sharp
|
||||
|
||||
ENV NEXT_TELEMETRY_DISABLED=1 \
|
||||
VERCEL_TELEMETRY_DISABLED=1 \
|
||||
DOCKER_BUILD=1
|
||||
|
||||
WORKDIR /app
|
||||
RUN bun run build
|
||||
|
||||
# ========================================
|
||||
# Runner Stage: Run the actual app
|
||||
# ========================================
|
||||
|
||||
FROM base AS runner
|
||||
WORKDIR /app
|
||||
|
||||
ENV NODE_ENV=production
|
||||
|
||||
COPY --from=builder /app/apps/sim/public ./apps/sim/public
|
||||
COPY --from=builder /app/apps/sim/.next/standalone ./
|
||||
COPY --from=builder /app/apps/sim/.next/static ./apps/sim/.next/static
|
||||
|
||||
EXPOSE 3000
|
||||
ENV PORT=3000 \
|
||||
HOSTNAME="0.0.0.0"
|
||||
|
||||
CMD ["bun", "apps/sim/server.js"]
|
||||
@@ -0,0 +1,28 @@
|
||||
# ========================================
|
||||
# Dependencies Stage: Install Dependencies
|
||||
# ========================================
|
||||
FROM oven/bun:alpine AS deps
|
||||
WORKDIR /app
|
||||
|
||||
# Copy only package files needed for migrations
|
||||
COPY package.json bun.lock turbo.json ./
|
||||
COPY apps/sim/package.json ./apps/sim/db/
|
||||
|
||||
# Install minimal dependencies in one layer
|
||||
RUN bun install --omit dev --ignore-scripts && \
|
||||
bun install --omit dev --ignore-scripts drizzle-kit drizzle-orm postgres next-runtime-env
|
||||
|
||||
# ========================================
|
||||
# Runner Stage: Production Environment
|
||||
# ========================================
|
||||
FROM oven/bun:alpine AS runner
|
||||
WORKDIR /app
|
||||
|
||||
# Copy only the necessary files from deps
|
||||
COPY --from=deps /app/node_modules ./node_modules
|
||||
COPY apps/sim/drizzle.config.ts ./apps/sim/drizzle.config.ts
|
||||
COPY apps/sim/db ./apps/sim/db
|
||||
COPY apps/sim/package.json ./apps/sim/package.json
|
||||
COPY apps/sim/lib/env.ts ./apps/sim/lib/env.ts
|
||||
|
||||
WORKDIR /app/apps/sim
|
||||
Reference in New Issue
Block a user